Solved Change GUI Item on click

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

JustADev

Well-Known Member
Apr 8, 2017
379
9
18
22
code_language.skript:
command /settings:
    description: Settings Command
    trigger:
        wait 1 tick
        open chest with 1 row named "&nSettings Menu" to player
        wait 2 ticks
        format gui slot 0 of player with 1 paper named "&c&lJoin Messages" with lore "||&7Condition: &aTrue" to close
        format gui slot 1 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 2 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 3 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 4 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 5 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 6 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 8 of player with 1 barrier named "&cClose Menu" to close
      
on block place of player head:
    cancel event
  
on inventory click:
    if name of clicked item is "&c&lJoin Messages":
        if {Joinmessages} is not set:
            set {Joinmessages} to "True"
            set slot 0 of clicked inventory to 1 paper named "&c&lJoin Messages" with lore "||&7Condition: &aEnabled"
            send "&cSettings &8&l» &7You have &a&nenabled&r &7Join Messages"
        else:
            if {Joinmessages} is set:
                delete {Joinmessages}
                set slot 0 of clicked inventory to 1 paper named "&c&lJoin Messages" with lore "||&7Condition: &cDisabled"
                send "&cSettings &8&l» &7You have &c&ndisabled&r &7Join Messages"
[doublepost=1502747653,1502746557][/doublepost]Ok, I have fixed it by myself, but how do I make it so that when the clicked dye is changed, it stays that way when reopening the inventory?

Code:
code_language.skript:
command /settings:
    description: Settings Command
    trigger:
        wait 1 tick
        open chest with 1 row named "&nSettings Menu" to player
        wait 2 ticks
        format gui slot 0 of player with 1 gray dye named "&eJoin Messages" with lore "||&7Condition: &7N/A"
        format gui slot 1 of player with 1 gray dye named "&eLeave Messages" with lore "||&7Condition: &7N/A"
        format gui slot 3 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 4 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 5 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 6 of player with 1 gray dye named "&cComing Soon" to close
        format gui slot 8 of player with 1 barrier named "&cClose Menu" to close
        
on block place of player head:
    cancel event
    
on inventory click:
    if name of clicked item is "&eJoin Messages":
        if {Joinmessages} is not set:
            set {Joinmessages} to "True"
            set slot 0 of clicked inventory to 1 light green dye named "&eJoin Messages" with lore "||&7Condition: &aEnabled"
            send "&cSettings &8&l» &7You have &a&nenabled&r &7Join Messages"
        else:
            if {Joinmessages} is set:
                delete {Joinmessages}
                set slot 0 of clicked inventory to 1 gray dye named "&eJoin Messages" with lore "||&7Condition: &cDisabled"
                send "&cSettings &8&l» &7You have &c&ndisabled&r &7Join Messages"
    if name of clicked item is "&eLeave Messages":
        if {Leavemessages} is not set:
            set {Leavemessages} to "True"
            set slot 1 of clicked inventory to 1 light green dye named "&eLeave Messages" with lore "||&7Condition: &aEnabled"
            send "&cSettings &8&l» &7You have &a&nenabled&r &7Leave Messages"
        else:
            if {Leavemessages} is set:
                delete {Leavemessages}
                set slot 1 of clicked inventory to 1 gray dye named "&eLeave Messages" with lore "||&7Condition: &cDisabled"
                send "&cSettings &8&l» &7You have &c&ndisabled&r &7Leave Messages"
 
instead of setting the slot down in the inventory click event, make the line make the player execute your /settings command to refresh the GUI, then underneath where you have slot 0 formatted, add an IF statement to check if the variable is true. And if it is format the slot to green dye with your enabled lore etc^-^
 
  • Like
Reactions: iAstora
Status
Not open for further replies.