Solved Change GUI slot

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

I've made a gui and I'd like to make something where when you click on a gui slot, it will change a variable to true instead of false. Then lets say it was grey dye when you clicked on it, it'd turn to green dye. But then everytime the same player opened it the same one would still be green.

I hope this makes sense.

Thanks,

- TheCringleYT

P.S: If you need a better explanation just ask me :emoji_wink:
 
Hi,

I've made a gui and I'd like to make something where when you click on a gui slot, it will change a variable to true instead of false. Then lets say it was grey dye when you clicked on it, it'd turn to green dye. But then everytime the same player opened it the same one would still be green.

I hope this makes sense.

Thanks,

- TheCringleYT

P.S: If you need a better explanation just ask me :emoji_wink:
Code:
# Requires Skript 2.3+
function gui(p: player):
    set {_gui} to a new chest inventory with 1 row with name "Gui Test"
    if {gui_dye::%{_p}%} is not set:
        set slot 0 of {_gui} to gray dye
        set {gui_dye::%{_p}%} to false
    else if {gui_dye::%{_p}%} is true:
        set slot 0 of {_gui} to light green dye
    else if {gui_dye::%{_p}%} is false:
        set slot 0 of {_gui} to gray dye
    open {_gui} to {_p}
command /gui:
    trigger:
        gui(player)
 
on inventory click:
    if name of event-inventory is "Gui Test":
        if index of event-slot = 0:
            cancel event
            if {gui_dye::%player%} is true:
                set {gui_dye::%player%} to false
                #code when is true
                gui(player)
            else if {gui_dye::%player%} is false:
                set {gui_dye::%player%} to true
                #code when is false
                gui(player)
 
  • Like
Reactions: Raymond
Thanks!
[doublepost=1600620567,1600618977][/doublepost]How can I make multiple of those or add like more items, can you give an example?
Something like this?
Code:
command /gui:
    trigger:
        gui(player)
 
on inventory click:
    if name of event-inventory is "Gui Test":
        if index of event-slot = 0:
            cancel event
            if {gui_dye::%player%} is "gray":
                set {gui_dye::%player%} to "lime"
                #code when is gray
                gui(player)
            else if {gui_dye::%player%} is "lime":
                set {gui_dye::%player%} to "red"
                #code when is lime
                gui(player)
            else if {gui_dye::%player%} is "red":
                set {gui_dye::%player%} to "gray"
                #code when is red
                gui(player)
[doublepost=1600623390][/doublepost]
Something like this?
Code:
command /gui:
    trigger:
        gui(player)
 
on inventory click:
    if name of event-inventory is "Gui Test":
        if index of event-slot = 0:
            cancel event
            if {gui_dye::%player%} is "gray":
                set {gui_dye::%player%} to "lime"
                #code when is gray
                gui(player)
            else if {gui_dye::%player%} is "lime":
                set {gui_dye::%player%} to "red"
                #code when is lime
                gui(player)
            else if {gui_dye::%player%} is "red":
                set {gui_dye::%player%} to "gray"
                #code when is red
                gui(player)
Or semething like this ?
Code:
# Requires Skript 2.3+
function gui(p: player):
    set {_gui} to a new chest inventory with 1 row with name "Gui Test"
    if {gui_dye::0::%{_p}%} is not set:
        set slot 0 of {_gui} to gray dye
    else if {gui_dye::0::%{_p}%} is "lime":
        set slot 0 of {_gui} to light green dye
    else if {gui_dye::0::%{_p}%} is "gray":
        set slot 0 of {_gui} to gray dye
    else if {gui_dye::0::%{_p}%} is "red":
        set slot 0 of {_gui} to red dye
        
        #slot 1 of gui
    if {gui_dye::1::%{_p}%} is not set:
        set slot 1 of {_gui} to gray dye
    else if {gui_dye::1::%{_p}%} is "lime":
        set slot 1 of {_gui} to light green dye
    else if {gui_dye::1::%{_p}%} is "gray":
        set slot 1 of {_gui} to gray dye
    else if {gui_dye::1::%{_p}%} is "red":
        set slot 1 of {_gui} to red dye
    open {_gui} to {_p}
command /gui:
    trigger:
        gui(player)
 
on inventory click:
    if name of event-inventory is "Gui Test":
        if index of event-slot = 0:
            cancel event
            if {gui_dye::0::%player%} is "gray":
                set {gui_dye::0::%player%} to "lime"
                #code when is gray
            else if {gui_dye::0::%player%} is "lime":
                set {gui_dye::0::%player%} to "red"
                #code when is lime
            else if {gui_dye::0::%player%} is "red":
                set {gui_dye::0::%player%} to "gray"
                #code when is red
            else if {gui_dye::0::%player%} is not set:
                set {gui_dye::0::%player%} to "lime"
        if index of event-slot = 1:
            cancel event
            if {gui_dye::1::%player%} is "gray":
                set {gui_dye::1::%player%} to "lime"
                #code when is gray
            else if {gui_dye::1::%player%} is "lime":
                set {gui_dye::1::%player%} to "red"
                #code when is lime
            else if {gui_dye::1::%player%} is "red":
                set {gui_dye::1::%player%} to "gray"
            else if {gui_dye::1::%player%} is not set:
                set {gui_dye::1::%player%} to "lime"
        gui(player)
 
Status
Not open for further replies.