1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cannot loop player's inventory

Discussion in 'Skript' started by lucasmooon, Aug 5, 2018.

Thread Status:
Not open for further replies.
  1. lucasmooon

    lucasmooon Member

    Joined:
    Feb 4, 2017
    Messages:
    16
    Likes Received:
    0
    Hello : )

    I'm trying to get all the player's items and their quantity. Once before you could loop the player's inventory and get the items and the amount, but now what the message returns is "inventory slot {number} of {player}".

    Version: dev37c
    Spigot 1.12.2

    Code

    Code (Skript):
    1. command loop:
    2.     trigger:
    3.         loop all items in player's inventory:
    4.             send "%loop-item%" to player
    [​IMG]


    EDIT: This image shows a 1.8 Skript with running this code

    [​IMG]
     
    #1 lucasmooon, Aug 5, 2018
    Last edited: Aug 5, 2018
  2. jaylawl

    jaylawl Well-Known Member

    Joined:
    Jan 29, 2017
    Messages:
    173
    Likes Received:
    31
    "inventory slot X" actually still represents the looped item. just use "send loop-item's name" in your code you'll see

    i consider this somehwat misleading and there is an open issue about this in bensku's github: https://github.com/SkriptLang/Skript/issues/1312
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,106
    Likes Received:
    150
    I got lost on this, like Jaylawl said it should work.
    Anyways I tried loop items name and it didnt work, so i tried type and it worked
    Code (Skript):
    1. command loop:
    2.     trigger:
    3.         loop all items in the inventory of player:
    4.             send "item: %loop-item's type%" to player
     
  4. jaylawl

    jaylawl Well-Known Member

    Joined:
    Jan 29, 2017
    Messages:
    173
    Likes Received:
    31
    What will always work (but is not recommended) is setting the item to a local variable first:
    Code (Skript):
    1. loop player's inventory:
    2.     set {_item} to loop-item
    3.     broadcast "%{_item}%"
     
Thread Status:
Not open for further replies.
Loading...