UpdateInventory() when player has more than 1 inventories.

Started by mchammer, Sat 10/03/2007 21:35:26

Previous topic - Next topic

mchammer

There was couple old topics about this problem but there wasnt clear solutions.

I use invisible npc's inventory as a secondary inventory to the player, but when i add items to the secondary inventory, sometimes items are invisible even if i use update inventory. In this topic someone said that multiply inventories dont work in earlier versions of AGS, but i use version 2.72.

Code where I add item to inventory:
Code: ags
if (player.activeinv == 5) {
player.LoseInventory(iHamburger);
cRefrigerator3.AddInventory(iHamburger);
}  


if (player.activeinv == 10) {
player.LoseInventory(iGroundmeat);
cRefrigerator3.AddInventory(iGroundmeat);
} 

(its in object's "use inventory on object" script)


Code where you "open the fridge" and inventory is displayed:
Code: ags

object[1].SetView(5);
object[1].Animate(0, 5, eOnce, eNoBlock, eForwards);
Wait(10);
gRefrigerator2.Visible = true;
UpdateInventory();
SetGlobalInt(eGRefrigeratorOpenClosed, 1);



and code when you take items from secondary inventory:
Code: ags

if (GetGlobalInt(eGRefrigeratorOpenClosed) == 1) {
 cRefrigerator3.LoseInventory(iHamburger);
 player.AddInventory(iHamburger);
 UpdateInventory();
 }  

(its in inventory object's "other click on inventory item" script.)


thnx for any help.


EDIT: Forgot to say that items are invisible only sometimes, usually everything works fine.
My 40 bullets - An action/war game.

Khris

As long as you use Character.AddInventory and Character.LoseInventory, there's no need to call UpdateInventory afterwards.
QuoteIf you add or remove inventory items manually (ie. by using the InventoryQuantity array rather than the AddInventory/LoseInventory functions), the display may not get updated. In this case call this function after making your changes, to update what is displayed to the player.
Try removing it.

SMF spam blocked by CleanTalk