Morrowind Mod:GetItemCount
GetItemCount
GetItemCount, ObjectID Where: ObjectID = ID of object to get the count for Type: Object Returns: short? Example: if ( player->GetItemCount, "gold_001" == 11171 ) if ( GetItemCount, "blessed_shield" > 0 ) short ObjectCount set ObjectCount to ( Player->GetItemCount, "wraithguard" ) Scripts: blueScript DagothTaunt_1
Returns the number of the objectID contained in the calling object. May not work correctly if the calling object has more than 32267 of the given item (unconfirmed).
There is a bug with this function when used on containers (possibly related to the AddItem/RemoveItem bug). If the player chooses the Take All button on the container then subsequent GetItemCount calls on the container will return the number of items in the container before the player took everything.
One way to get around this bug is to set the chest as persistant and use a temporary persistant ingredient in the chest. The persistant ingredient is hidden in the sense that it is added initially to the chest from a script, removed when the player opens the container, and added back again when the container is closed. See the below script for an example:
begin HidePersistant short doOnce if ( onActivate == 1 ) RemoveItem, "PersistantIngredient", 1 set doOnce to 1 endif if ( doOnce == 1 ) If ( onActivate == 1 ) ; do nothing elseif ( Activate == 1 ) ; do nothing elseif ( MenuMode == 1 ) ; do nothing else AddItem, "PersistantIngredient", 1 Set doOnce to 0 return endif endif end
bugs
note: the following code in a global script causes crashes in my game as of 2005-04-11
short grn set grn to ( player->getitemcount, "misc_soulgem_grand" )
however, this works (note the lack of a comma following getitemcount)
short grn set grn to ( player->getitemcount "misc_soulgem_grand" )
--Halo112358 22:48, 11 Apr 2005 (EDT)