# GetItemInHand

TIP

  • getItemInHand(<player>)
  • Returns the item a player is holding as an array with the following elements:
  • ["name"] Item's name
  • ["custom_name"] Item's custom name
  • ["id"] Item's ID
  • ["meta"] Item's meta
  • ["amount"] Item's amount
  • ["nbt"] Item's NBT
  • ["slot"] Item's slot

# Parameters

  • <player> The player to get the item they're holding as string

# Example

1: $item$ = getItemInHand($player$)
2: if ($item$['id'] = 264) {
3:    sendMessage($player$, "You're holding a diamond")
4:    exit()
5: }
6: sendMessage($player$, "You're not holding a diamond")