1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Update GUI slot

Discussion in 'Skript' started by Mattllama987, Jan 13, 2020.

  1. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    73
    Likes Received:
    0
    Hello, i need help with a little something. Ive never really understood how to make a GUI auto update a slot. Im working on a Admin Menu, and want to check a few things that would need to be updated in a slot in the gui. What i have now gives no errors, but wont format the slot. It just stays blank and the players skull isnt there. So if someone know how to fix this, please let me know ASAP.

    Server: 1.14.4
    Skript: 2.4.1

    Thanks!
    ~Matt

    Also not sure why the indentation is off :emoji_slight_smile:

    Code (Text):
    1. while name of player's current inventory is "&c&lAdmin Menu":
    2.                     set slot 13 of current inventory of player to player's skull named "" with lore "%player's ping%"
    3.                     wait 1 seconds
     
  2. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    185
    Likes Received:
    7
    Can you give us a bit more code, if this was meant to be an event, there is no event as such.
     
  3. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    73
    Likes Received:
    0
    Ill post the full thing. But the part at the bottom is what im stuck on. The While part.


    Code (Text):
    1. command /menu:
    2.     trigger:
    3.         if player has permission "admin.menu":
    4.             open chest with 6 rows named "&c&lAdmin Menu" to player
    5.             format gui slot 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 50, 51, 52 and 53 of player with black stained glass pane named ""
    6.             set {_num} to 0
    7.             loop 10 times:
    8.                 format gui slot {_num} of player with black stained glass pane named ""
    9.                 add 1 to {_num}
    10.             format gui slot 49 of player with barrier named "&c&lClose" to close
    11.             format gui slot 10 of player with lever named "&a&lRestart Server" with lore "&5&lThis will restart the server" and "&5&land kick all players!" to run:
    12.                 execute console command "restart"
    13.             format gui slot 11 of player with glowing paper named "&a&lReset everyone's balance" with lore "&7&lThis will reset all player's" and "&7&lbalances on the server" to run:
    14.                 execute command "/eco reset **"
    15.                 send "&c&l[Menu] &7Reset everyones balance!"
    16.             format gui slot 12 of player with redstone named "&c&lChange GameMode" with lore "&7&lChange your gamemode" to run:
    17.                 if player's gamemode is creative:
    18.                     set player's gamemode to survival
    19.                     send "&c&l[Menu] &7You are now in Survival!"
    20.                 else if player's gamemode is survival:
    21.                     set player's gamemode to creative
    22.                     send "&c&l[Menu] &7You are now in Creative!"
    23.                 while name of player's current inventory is "&c&lAdmin Menu":
    24.                     set slot 13 of current inventory of player to player's skull named "" with lore "%player's ping%"
    25.                     wait 1 seconds
    --- Double Post Merged, Jan 16, 2020, Original Post Date: Jan 14, 2020 ---
    Bump
     
  4. Drioz

    Drioz Active Member

    Joined:
    Jun 10, 2018
    Messages:
    27
    Likes Received:
    2
    A possible solution would be to set a variable when the player opens the gui, then delete it once they close the gui.
    And then say

    Code (Text):
    1. while {temp.%player%} is set:
    2.     set slot...
    3.     wait 1 second
     
  5. Mattllama987

    Mattllama987 Well-Known Member

    Joined:
    Aug 5, 2018
    Messages:
    73
    Likes Received:
    0
    That sure did it! Thank you, and have a fantastic day! :emoji_slight_smile:
    --- Double Post Merged, Jan 16, 2020, Original Post Date: Jan 16, 2020 ---
    Okay, but now it shows the slot in every GUI i open. Ive tried a few ways to not let that happen. But every menu i open, slot 13 will be the players head.
    --- Double Post Merged, Jan 16, 2020 ---
    Here is what i have now:

    Code (Text):
    1. command /menu:
    2.     trigger:
    3.         if player has permission "admin.menu":
    4.             open chest with 6 rows named "&c&lAdmin Menu" to player
    5.             set {temp::%player%} to true
    6.             format gui slot 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 50, 51, 52 and 53 of player with black stained glass pane named ""
    7.             set {_num} to 0
    8.             loop 10 times:
    9.                 format gui slot {_num} of player with black stained glass pane named ""
    10.                 add 1 to {_num}
    11.             format gui slot 49 of player with barrier named "&c&lClose" to close
    12.             format gui slot 10 of player with lever named "&a&lRestart Server" with lore "&5&lThis will restart the server" and "&5&land kick all players!" to run:
    13.                 execute console command "restart"
    14.             format gui slot 11 of player with glowing paper named "&a&lReset everyone's balance" with lore "&7&lThis will reset all player's" and "&7&lbalances on the server" to run:
    15.                 execute command "/eco reset **"
    16.                 send "&c&l[Menu] &7Reset everyones balance!"
    17.             format gui slot 12 of player with redstone named "&c&lChange GameMode" with lore "&7&lChange your gamemode" to run:
    18.                 if player's gamemode is creative:
    19.                     set player's gamemode to survival
    20.                     send "&c&l[Menu] &7You are now in Survival!"
    21.                 else if player's gamemode is survival:
    22.                     set player's gamemode to creative
    23.                     send "&c&l[Menu] &7You are now in Creative!"
    24.             format gui slot 14 of player with glowing paper named "&bAdd &a$1M" to run:
    25.                 add 1000000 to player's balance
    26.             while {temp::%player%} is true:
    27.                 set slot 13 of current inventory of player to player's skull named "" with lore "&6Ping: &a%player's ping%" and "&6Balance: &a%player's balance%"
    28.                 wait 1 ticks
    29. on inventory close:
    30.     set {temp::%player%} to false
    EDIT: I think i might have found the issue.
     
    #5 Mattllama987, Jan 16, 2020
    Last edited: Jan 16, 2020
  6. Goose

    Goose Well-Known Member

    Joined:
    Nov 23, 2019
    Messages:
    185
    Likes Received:
    7
    You can use
    Code (Text):
    1. if name of player's current inventory is "blah blah"
     
Loading...