Action occurs if certain item in inventory (SOLVED)

Started by Zoolander, Thu 06/04/2006 04:22:52

Previous topic - Next topic

Zoolander

Hi everyone.  I'm sure this is possible, I just can't find it in the manual.  How is it done so that an action will take place only if a certain item is in inventory? 

For example, if an NPC asked if I had a coin.  If the coin was in the inventory, the player character would say yes, otherwise the answer is no.

Vince Twelve

QuoteInventoryQuantity property
(Formerly known as character[].inv, which is now obsolete)

int Character.InventoryQuantity[]

Gets/sets the quantity of the specified inventory item that the character currently has. The array index is the inventory item number, from the Inventory pane in the editor.
Usually, you should use the AddInventory and LoseInventory functions to modify the character's inventory; however, if you need to add or remove a large number of items in one go, directly changing this array can be an easier method.

If you change this array directly, the on-screen inventory will not be updated. In this case, you must call UpdateInventory to see any new or removed items.

Example:

Display("The player has $%d.", player.InventoryQuantity[iCash.ID]);

will display how many inventory items of type iCash the player has.
See Also: UpdateInventory, Character.AddInventory, Character.LoseInventory


Something like:

Code: ags

if(player.InventoryQuantity[iSomething.ID]>0){
  //do something
}

Zoolander


SMF spam blocked by CleanTalk