#amount of items

1 messages · Page 1 of 1 (latest)

unborn nexus
#

Hi! I need to get amount of items in player's inventory.

I found answers to this question on the forums, but for some reason they all do not count the number of items in one slot!

plz help 🥲

white timber
#

i would loop every slot the player has, make smth like {_x} be the amount of items he has in that slot then add it to a diff variable like {_total}

white timber
#

i was bored so i coded it

#
function totalItems(p: player):
  loop 36 times:
    if {_y} is not set:
      set {_y} to 0
    set {_x} to item amount of slot loop-value - 1 of {_p}'s inventory
    add {_x} to {_y}
  send "You have &2&l%{_y}% &r&aitems in your inventory!" to {_p}

command /tallyinventory [<player>]:
  trigger:
    if argument is set:
      totalItems(argument)
    else:
      totalItems(player)
#

check if this works

nocturne moat
unborn nexus
white timber
#

just item amount of slot {_somevar} should also work but you can also do smth like amount of {var_item} in player's inventory

#

also amount of stick named "lolxd" in player's inventory and stuff liek that work too

unborn nexus
white timber
#

oh these are like expressions and not actual pieces of code

#

you should keep training on seeing how skript format looks

#

you can apply these for example:

command /testing <player> <number>:
  if argument-2 is 1:
    set {_x} to amount of stick named "lolxd" in argument-1's inventory
  else if argument-2 is 2:
    set {_testvar} to stick named "lolxd"
    set {_x} to amount of {_testvar} in argument-1's inventory
  else:
    send "&cInvalid test number!" to argument-1
    stop
  if argument-1 is player:
    send "&aYou have &2&l%{_x}% &r&aof that stick!" to player
    stop
  send "&e%argument-1% &ahas &2&l%{_x}% &r&aof that stick!" to player
  send "&aYou have &2&l%{_x}% &r&aof that stick!" to argument-1


on inventory click:
  event-item is stick named "lolxd"
  set {_x} to event-itemstack
  send "&aYou clicked on a stack of &2&l%{_x}%&r&a custom sticks!"
#

just some examples

#

try to wrap your head around the code