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 out 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.

Set Slot - Execute command not working

Discussion in 'Skript' started by GToTheG, Mar 26, 2021.

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

    GToTheG Member

    Joined:
    Jan 26, 2017
    Messages:
    35
    Likes Received:
    0
    Hello,

    I'm trying to execute a player command when clicking on a item in a GUI.

    My code:
    Code (Text):
    1. set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a" then execute player command "/test"
    2.            
    It won't accept this, nor with "then run command", or "then run player command".

    Running the latest ver. of skript, skquery and skellet. 1.16.5
    Error is just "a slot can't be set to bla. bla. bla." - all my code is working fine if i just remove the execution part, that im trying to figure out.

    Someone can help me out here? Couldn't find anything on the docs about this.
     
  2. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    There is no such syntax. If you want to check the clicked slot in vanilla inventories, you have to do this:

    If the inventory has a metadata, then:
    Code (Skript):
    1. on inventory click:
    2.     event-inventory = (metadata tag "MetadataOfInventory" of player):
    3.        index of event-slot is 20:
    4.            player command "test"
    if has name:

    Code (Skript):
    1. on inventory click:
    2.    if name of current player's inventory is "Name of the inventory":
    3.        clicked slot is 20:
    4.            player command "test"
     
  3. GToTheG

    GToTheG Member

    Joined:
    Jan 26, 2017
    Messages:
    35
    Likes Received:
    0

    Sorry, I think you misunderstood me.

    I've done this many times a long time ago, just came back and started doing skript, have to freshen up my memory a bit. I may have done this with format slot perhaps?

    I'm trying to make a GUI.

    Code (Text):
    1. command /gui:
    2.     trigger:
    3.             open chest with 6 rows named "&6Server" to player
    4.             set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a"  then execute player command "/test"
    5.            
     
  4. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    I know, but "then execute player command "/test "" doesn't work in that case. That's why you have to verify the inventory clicked with the event "on inventory click".
     
  5. GToTheG

    GToTheG Member

    Joined:
    Jan 26, 2017
    Messages:
    35
    Likes Received:
    0
    I have never done it like that before in the past?

    Is this something new and changed to skript?

    I have always done it in one set slot/format slot line, in the past. I sadly don't have any of my old skripts laying around.
     
  6. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    To create a gui inventory you have to do this:

    Code (Skript):
    1. command /test:
    2.    trigger:
    3.        set metadata tag "TestMetadata" of player to chest inventory with 6 rows named "&6Server"
    4.        set slot 20 of metadata tag "TestMetadata" of player to spawner named "&6Spawner" with lore ""
    5.        open (metadata tag "TestMetadata" of player) to player
    6.  
    7. on inventory click:
    8.    event-inventory = (metadata tag "TestMetadata" of player):
    9.        index of event-slot is 20:
    10.            #do stuff
     
  7. GToTheG

    GToTheG Member

    Joined:
    Jan 26, 2017
    Messages:
    35
    Likes Received:
    0
    Thanks for the help. But this is not what I am looking for. :emoji_slight_smile:
     
  8. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    714
    Likes Received:
    31
    So what do you want?
     
  9. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    240
    Likes Received:
    14
    @couger44 is right. That way of doing inventories has been deprecated a long time ago and you should go with what he said. You don't necessarily need to use metadata though, maybe that's what's confusing you. Here goes a simplified way of doing it:
    Code (Text):
    1. command /gui:
    2.     trigger:
    3.         set {_menu} to chest with 2 rows named "Test"
    4.         set slot 0 of {_menu} to apple named "Click me!"
    5.         open {_menu} to {_p}
    6.        
    7. on inventory click:
    8.     name of event-inventory is "Test"
    9.     cancel event
    10.     if name of event-slot is "Click me!":
    11.         send "I'm an apple"
     
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...