counting items in player's inventory?

Discussion in 'Skript' started by nktfh100, May 5, 2017.

  1. counting items in player's inventory?

    so i tried this:
    Code (Text):
     
    every 2 seconds:
    loop all players:
        if name of loop-player's tool contains "&e&lAmmo bag":
            loop players in radius 4 of the loop-player:
                set {ammov.%loop-player-2%} to 0
                loop all items in the loop-player-2's inventory:
                    if loop-item's name is "&eAmmo":
                        add 1 to {ammov.%loop-player-2%}
                        wait 1 tick
                     send "%{ammov.%loop-player-2%}%" to loop-player-2
     
    but beacause the "item" is stacked it doesnt work....
    i want to to check like if the player has 34 diamonds(in 1 stack)
    any way to fix it?

    well bad english...
     
  2. You need to install Skellett or I think a new Bensku edit

    Then this will work.
    Code (Text):
    every 2 seconds:
        loop all players:
            if name of loop-player's tool contains "&e&lAmmo bag":
                loop players in radius 4 of the loop-player:
                    set {ammov.%loop-player-2%} to 0
                    loop all items in loop-player-2's inventory:
                        if loop-item's name is "&eAmmo":
                            add amount of item loop-item to {ammov.%loop-player-2%}
                            wait a tick
                        send "%{ammov.%loop-player-2%}%" to loop-player-2
     
    • Like Like x 2
  3. Thanks

    i will check this out