I was messing with it could do work but only charged one item regardless of the amount
Code:
bool FrontendWarZ::UpdateInventoryWithBoughtItem()
{
int numItem = gUserProfile.ProfileData.NumItems;
// check if we bought consumable
int quantityToAdd = storecat_GetItemBuyStackSize(mStore_BuyItemID);
int totalQuantity = 1;
// see if we already have this item in inventory
bool found = false;
uint32_t inventoryID = 0;
int var1 = -1;
int var2 = 0;
int var3 = wiInventoryItem::MAX_DURABILITY;
for(int i=0; i<numItem; ++i)
{
if(gUserProfile.ProfileData.Inventory[i].InventoryID == m_inventoryID)
{
inventoryID = uint32_t(gUserProfile.ProfileData.Inventory[i].InventoryID);
var1 = gUserProfile.ProfileData.Inventory[i].Var1;
var2 = gUserProfile.ProfileData.Inventory[i].Var2;
var3 = gUserProfile.ProfileData.Inventory[i].Var3;
gUserProfile.ProfileData.Inventory[i].quantity += quantityToAdd;
totalQuantity = gUserProfile.ProfileData.Inventory[i].quantity;
found = true;
break;
}
}
if(!found)
{
wiInventoryItem* itm = gUserProfile.getFreeInventorySlot();
if(!itm)
{
Scaleform::GFx::Value var[2];
var[0].SetString(gLangMngr.getString("InGameUI_ErrorMsg_NoInventorySpace"));
var[1].SetBoolean(true);
gfxMovie.Invoke("_root.api.showInfoMsg", var, 2);
return true;
}
itm->InventoryID = m_inventoryID;
itm->itemID = mStore_BuyItemID;
itm->quantity = quantityToAdd;
itm->Var1 = var1;
itm->Var2 = var2;
itm->Var3 = var3;
inventoryID = uint32_t(itm->InventoryID);
totalQuantity = quantityToAdd;
}
Scaleform::GFx::Value var[7];
var[0].SetUInt(inventoryID);
var[1].SetUInt(mStore_BuyItemID);
var[2].SetNumber(totalQuantity);
var[3].SetNumber(var1);
var[4].SetNumber(var2);
var[5].SetBoolean(false);
var[6].SetString(getAdditionalDescForItem(mStore_BuyItemID, var1, var2, var3));
gfxMovie.Invoke("_root.api.addInventoryItem", var, 7);
return found;
}
Here I managed to come by quantity. but I undid the problem to charge one