Difference between revisions of "GetItemCount - ObjectReference"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>RobinHood70
 
imported>Jbrowne
m (Made text more specific.)
 
Line 20: Line 20:


== Return Value ==
== Return Value ==
How many of said item is in this reference's inventory.
An int equal to the number of said item is in this reference's inventory.


== Examples ==
== Examples ==

Latest revision as of 01:55, 23 January 2017

Member of: ObjectReference Script

Returns how many of the specified item is in this reference's inventory.

Syntax[edit | edit source]

int Function GetItemCount(Form akItem) native

Parameters[edit | edit source]

  • 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
    • If None, will count how many items are in the container in total
    • Default: None

Return Value[edit | edit source]

An int equal to the number of said item is in this reference's inventory.

Examples[edit | edit source]

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

See Also[edit | edit source]