Jump to content

Checking player invemtory - remind me please.


Recommended Posts

How do I write the IF statement that checks player inventory?

Something like 'If player has x amount of x' and what are the syntaxes s oi can create one long IF statement like 'If player has x amount of x and y amount of y and...etc.

I remember && being AND what are the others for doesn't have, has less/more than?

A complete example as opposed to an explanation would be appreciated.

Thank you.

Link to comment
Share on other sites

Use GetItemCount to obtain the number of a specified object within the specified container or actor's inventory. Example usage within both examples below.

 

Example of comparison operators (i.e. equals, greater than, less than, etc)

 

 

MiscObject Property SomeObject Auto

Event OnInit() ;event used solely for example purposes
  Int SOCount = Game.GetPlayer().GetItemCount(SomeObject)
  If SOCount == 10 ;has exactly ten
    Debug.Trace("Player has exactly 10")
  ElseIf SOCount > 20
    Debug.Trace("Player has more than 20")
  ElseIf SOCount >= 11
    Debug.Trace("Player has 11 or more")
  ElseIf SOCount < 10
    Debug.Trace("Player has less than 10")
  ElseIf SOCount <= 5 
    Debug.Trace("Player has 5 or less")
  EndIf
EndEvent

 

 

 

Example of logical operators (i.e. AND and OR)

 

 

MiscObject Property SomeObject Auto
Weapon Property SomeWeapon Auto

Event OnInit() ;event used solely for example purposes
  Actor PlayerRef = Game.GetPlayer()
  Int SOCount = PlayerRef.GetItemCount(SomeObject)
  Int SWCount = PlayerRef.GetItemCount(SomeWeapon)
  If SOCount == 10 && SWCount == 10
    Debug.Trace("Player has exactly 10 of SomeObject and SomeWeapon")
  ElseIf SOCount > 20 || SWCount > 20
    Debug.Trace("Player has more than 20 of SomeObject or SomeWeapon")
  EndIf
EndEvent

 

 

 

You can get further explanation as well as examples with regards to the various operators here: https://www.creationkit.com/index.php?title=Operator_Reference

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...