About GUIs

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

evawwolf

Member
Dec 16, 2020
3
0
1
23
I have looked everywhere for GUI skript tutorials but I can't seem to find what I'm looking for exactly.

I want to know how to: when a gui is opened, click on an item, and open another gui with more content.
and how to "unlock" slots. for example, once you've done a certain thing ingame, you unlock the item thats displayed in the gui, that was previously locked, and now has an item in its place. im asking this for multiple items in one chest/gui, having up to around 25 locked items in each chest and you can unlock them by doing things ingame.
thank you!
 
Not sure if knowing when a gui is opened is possible. (P.S Im using SkQuery for this code)

click on item:

Code:
on inventory click:
    if event-slot is smth named "smth":
        do smth

completed things (Not Tested):
Code:
command /gui:
    trigger:
        open chest with 3 rows named "smth" to player
         if {variable here} = 1:
             format slot 0 of player with green stained glass pane named "Unlocked" to be unstealable
        else:
             format slot 0 of player with red stained glass pane named "Locked" to be unstealable

^^ that just displays a green stained glass pane that shows if its unlocked or not

Hope I helped :^)
If you need extra help contact me on discord with your SkUnity name and problem at Swevb#4079
 
Not sure if knowing when a gui is opened is possible. (P.S Im using SkQuery for this code)

click on item:

Code:
on inventory click:
    if event-slot is smth named "smth":
        do smth

completed things (Not Tested):
Code:
command /gui:
    trigger:
        open chest with 3 rows named "smth" to player
         if {variable here} = 1:
             format slot 0 of player with green stained glass pane named "Unlocked" to be unstealable
        else:
             format slot 0 of player with red stained glass pane named "Locked" to be unstealable

^^ that just displays a green stained glass pane that shows if its unlocked or not

Hope I helped :^)
If you need extra help contact me on discord with your SkUnity name and problem at Swevb#4079

Format slot is extremely broken. I'd use set slot instead:

Code:
function GUI(p: player, page: integer):
    if {_page} is 1:
        open chest with 3 rows named "Home:" to {_p}
        set slot 0 of {_p}'s current inventory to compass named "Open GUI"

    if {_page} is 2:
        open chest with 3 rows named "Unlocks:" to {_p}
        #Loop amount of unlocks total
        set {_o} to 1
        loop 10 times:
            if {unlock.%{_p}%::%{_o}%} is false:
                set slot 0 of {_p}'s current inventory to lime stained glass pane named "Unlock ##%{_o}%"
            else:
                set slot 0 of {_p}'s current inventory to red stained glass pane named "Unlock ##%{_o}%" with lore "&7Already unlocked"
            add 1 to {_p}

on inventory click:
    name of player's current inventory is "Home:":
        name of clicked item is "Open GUI":
            cancel event
            GUI(player, 2)

command /gui:
    trigger:
        GUI(player, 1)

Our code here checks if the variable {unlock.player::1-10} is set. If true(the player has unlocked it), the glass pane will be red, otherwise it will be green. You'd need to maker another function for unlocking the actual things:

Code:
#The unlock function. Specifiy the player and the number of the unlock that it should receive
function unlock(p: player, i: integer):
    set {unlock.%{_p}%::%{_i}%} to true
    send "You unlocked ##%{_i}%"

#The attacking player will unlock #1 when killing a zombie
on death of zombie:
    attacker is a player:
        if {unlock.%attacker%::1} is set:
            stop
        else:
            unlock(attacker, 1)
 
Status
Not open for further replies.