Difference between revisions of "GetItemCount - ObjectReference"
Jump to navigation
Jump to search
imported>Perdev |
imported>Zartar |
||
Line 32: | Line 32: | ||
endIf | endIf | ||
</source> | </source> | ||
== Notes == | |||
* If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( [http://forums.bethsoft.com/topic/1441239-cant-getitemcount-on-the-pc-via-formlist-of-keywords/page__pid__22196680#entry22196680/ Source]). | |||
== See Also == | == See Also == |
Revision as of 18:03, 4 February 2013
Member of: ObjectReference Script
Returns how many of the specified item is in this reference's inventory.
Syntax
int Function GetItemCount(Form akItem) native
Parameters
- akItem: The item to look for in this reference's inventory.
- If a reference, will look for just that particular reference.
- If a base object (like armor or a weapon), it will count the how many instances of that base object are in the container
- If a form list, it will count how many of each item in the form list is in the container and sum it all up
- If a keyword, it will count how many items with that keyword are in the container
Return Value
How many of said item is in this reference's inventory.
Examples
if (Game.GetPlayer().GetItemCount(WeapTypeSwordKeyword) == 0)
Debug.Trace("Player has no swords")
endIf
if (Game.GetPlayer().GetItemCount(SuperSecretPotionReference) == 0)
Debug.Trace("Player doesn't have the super-secret potion")
endIf
Notes
- If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( Source).