Custom GUI Inventory not stopping to work?

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

zKutari

Member
Sep 3, 2022
4
1
3
24
Hey!

So I created a custom GUI on join of my server to display rules, you can either accept them or deny them, second one will lead to a kick. Now my problem: Even after I accepted the rules, the custom GUI still seems to be applying to my normal inventory, ender chests etc... it basically is like having the rule gui slots, but not knowing which one is which and sometimes I even get kicked because I clicked the slot defined with "Deny"... so here's my code:

Code:
on join:
    make player execute command "/serverrules"

command /serverrules:
    trigger:
        set metadata tag "serverrules" of player to chest inventory with 5 rows named "&e&l[Server-Rules]"
        set slot 18 of metadata tag "serverrules" of player to book named "&4&lNO mods/hacks." with lore "&e&lThat give you an unfair advantage."
        set slot 19 of metadata tag "serverrules" of player to book named "&4&lNO racial slur."
        set slot 20 of metadata tag "serverrules" of player to book named "&4&lNO toxic behaviour."
        set slot 21 of metadata tag "serverrules" of player to book named "&4&lDo not annoy the owners/helper!" with lore "&e&lDo /emsg <NameOfHelper/Owner for support!."
        set slot 22 of metadata tag "serverrules" of player to book named "&4&lNO naked killing." with lore "&e&lExcept if the naked guy attacks first/has a piece of armour!"
        set slot 23 of metadata tag "serverrules" of player to book named "&4&lNO begging for loot!" with lore "&e&lYou will get enough create keys at player goals!"
        set slot 24 of metadata tag "serverrules" of player to book named "&4&lNO shulker box stealing!" with lore "&e&lIf the victim send proof of someone stealing, the thief will get jailed!"
        set slot 25 of metadata tag "serverrules" of player to book named "&4&lNO spamming in chat."
        set slot 26 of metadata tag "serverrules" of player to book named "&4&lInstructions from the owners must be followed."
        set slot 31 of metadata tag "serverrules" of player to emerald named "&a&lBy clicking this, you are &4&lACCEPTING &a&lall of the rules above."
        set slot 40 of metadata tag "serverrules" of player to barrier named "&a&lI do not accept the rules (KICK)"
        set metadata tag "rulesopen" of player to true
        open (metadata tag "serverrules" of player) to player
        
        

on inventory click:
    if index of event-slot is 31:
        send "&e&l[RULES]: &a&lYou succesfully acceptet the rules. Stay safe!" to player
        delete metadata tag "rulesopen" of player
        cancel event
        close player's inventory
    if index of event-slot is 18:
        cancel event
    if index of event-slot is 19:
        cancel event
    if index of event-slot is 20:
        cancel event
    if index of event-slot is 21:
        cancel event
    if index of event-slot is 22:
        cancel event
    if index of event-slot is 23:
        cancel event
    if index of event-slot is 24:
        cancel event
    if index of event-slot is 25:
        cancel event
    if index of event-slot is 26:
        cancel event
    if index of event-slot is 40:
        delete metadata tag "rulesopen" of player
        close (metadata tag "serverrules" of player)
        kick player
            
on inventory close:
    if metadata tag "rulesopen" of player is true:
        play sound "entity.villager.no" to player
        wait 2 ticks
        open (metadata tag "serverrules" of player) to player
 
Before checking index slots, in inventory click event check:
if metadata tag "rulesopen" of player is true

Code:
on join:
    make player execute command "/serverrules"

command /serverrules:
    trigger:
        set metadata tag "serverrules" of player to chest inventory with 5 rows named "&e&l[Server-Rules]"
        set slot 18 of metadata tag "serverrules" of player to book named "&4&lNO mods/hacks." with lore "&e&lThat give you an unfair advantage."
        set slot 19 of metadata tag "serverrules" of player to book named "&4&lNO racial slur."
        set slot 20 of metadata tag "serverrules" of player to book named "&4&lNO toxic behaviour."
        set slot 21 of metadata tag "serverrules" of player to book named "&4&lDo not annoy the owners/helper!" with lore "&e&lDo /emsg <NameOfHelper/Owner for support!."
        set slot 22 of metadata tag "serverrules" of player to book named "&4&lNO naked killing." with lore "&e&lExcept if the naked guy attacks first/has a piece of armour!"
        set slot 23 of metadata tag "serverrules" of player to book named "&4&lNO begging for loot!" with lore "&e&lYou will get enough create keys at player goals!"
        set slot 24 of metadata tag "serverrules" of player to book named "&4&lNO shulker box stealing!" with lore "&e&lIf the victim send proof of someone stealing, the thief will get jailed!"
        set slot 25 of metadata tag "serverrules" of player to book named "&4&lNO spamming in chat."
        set slot 26 of metadata tag "serverrules" of player to book named "&4&lInstructions from the owners must be followed."
        set slot 31 of metadata tag "serverrules" of player to emerald named "&a&lBy clicking this, you are &4&lACCEPTING &a&lall of the rules above."
        set slot 40 of metadata tag "serverrules" of player to barrier named "&a&lI do not accept the rules (KICK)"
        set metadata tag "rulesopen" of player to true
        open (metadata tag "serverrules" of player) to player
    
    

on inventory click:
    if metadata tag "rulesopen" of player is true:
        if index of event-slot is 31:
            send "&e&l[RULES]: &a&lYou succesfully acceptet the rules. Stay safe!" to player
            delete metadata tag "rulesopen" of player
            cancel event
            close player's inventory
        else if index of event-slot is 40:
            cancel event
            delete metadata tag "rulesopen" of player
            close (metadata tag "serverrules" of player)
            kick player
        else if index of event-slot is between 18 and 26:
            cancel event
        
on inventory close:
    if metadata tag "rulesopen" of player is true:
        play sound "entity.villager.no" to player
        wait 2 ticks
        open (metadata tag "serverrules" of player) to player
 
Status
Not open for further replies.