Determines the next item in an object's inventory.
- The object that has the inventory. (Default: OBJECT_SELF)
Returns the next item in oTarget's inventory or OBJECT_INVALID if the caller is not a creature, item, placeable or store, or if no more items are found.
GetFirstItemInInventory() should be called on oTarget before this function is be called.
When an item with an inventory (such as a bag of holding) is returned using the GetFirstItemInInventory() and GetNextItemInInventory() functions, the next call to GetNextItemInInventory() will start to look inside the nested inventory (e.g. the bag of holding's inventory). You can also specifically just search a given inventory bag/container, by starting a new loop with GetFirstItemInInventory(oItemContainer); which will preserve the original loop on the given creature or placeable.
//(The number of items in a stackable count toward the total)
int nItems = 0;
object oItem = GetFirstItemInInventory(GetFirstPC());
while (GetIsObjectValid(oItem) == TRUE)
nItems = nItems + GetNumStackedItems(oItem);
oItem = GetNextItemInInventory(GetFirstPC());
author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Ian Christie