Set Slot - Execute command not working

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

GToTheG

Member
Jan 26, 2017
35
0
8
23
Hello,

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

My code:
Code:
set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a" then execute player command "/test"

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.
 
Hello,

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

My code:
Code:
set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a" then execute player command "/test"

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.
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_language.skript:
on inventory click:
    event-inventory = (metadata tag "MetadataOfInventory" of player):
       index of event-slot is 20:
           player command "test"

if has name:

code_language.skript:
on inventory click:
   if name of current player's inventory is "Name of the inventory":
       clicked slot is 20:
           player command "test"
 
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_language.skript:
on inventory click:
    event-inventory = (metadata tag "MetadataOfInventory" of player):
       index of event-slot is 20:
           player command "test"

if has name:

code_language.skript:
on inventory click:
   if name of current player's inventory is "Name of the inventory":
       clicked slot is 20:
           player command "test"


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:
command /gui:
    trigger:
            open chest with 6 rows named "&6Server" to player
            set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a"  then execute player command "/test"
 
Sorry, I think you misunderstood me.

I'm trying to make a GUI.

Code:
command /gui:
    trigger:
            open chest with 6 rows named "&6Server" to player
            set slot 20 of player's current inventory to spawner named "&6Spawner" with lore "&a"  then execute player command "/test"
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".
 
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".

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.
 
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.
To create a gui inventory you have to do this:

code_language.skript:
command /test:
   trigger:
       set metadata tag "TestMetadata" of player to chest inventory with 6 rows named "&6Server"
       set slot 20 of metadata tag "TestMetadata" of player to spawner named "&6Spawner" with lore ""
       open (metadata tag "TestMetadata" of player) to player

on inventory click:
   event-inventory = (metadata tag "TestMetadata" of player):
       index of event-slot is 20:
           #do stuff
 
To create a gui inventory you have to do this:

code_language.skript:
command /test:
   trigger:
       set metadata tag "TestMetadata" of player to chest inventory with 6 rows named "&6Server"
       set slot 20 of metadata tag "TestMetadata" of player to spawner named "&6Spawner" with lore ""
       open (metadata tag "TestMetadata" of player) to player

on inventory click:
   event-inventory = (metadata tag "TestMetadata" of player):
       index of event-slot is 20:
           #do stuff

Thanks for the help. But this is not what I am looking for. :emoji_slight_smile:
 
@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:
command /gui:
    trigger:
        set {_menu} to chest with 2 rows named "Test"
        set slot 0 of {_menu} to apple named "Click me!"
        open {_menu} to {_p}
        
on inventory click:
    name of event-inventory is "Test"
    cancel event
    if name of event-slot is "Click me!":
        send "I'm an apple"
 
  • Like
Reactions: GToTheG
Status
Not open for further replies.