Time in GUI

Discussion in 'Skript' started by Revivalo, Apr 17, 2017.

  1. Hello there!
    I wanna ask if someone of you know that, how times in skript GUI go less without refresh the menu. For example "Starting in %time% second(s)".
     
  2. Not. You will have to update the menu. You can however make it so only that one item is updated, and not the entire menu.
     
    • Friendly Friendly x 1
  3. Like @Darthmineboy said, but in practise.

    Code (Text):
    command /game:
        trigger:
            open chest with 1 row named "Game starting in" to player #Opens a chest GUI with 1 row
            set {inv.gamecount.%player%} to true #Sets the variable for later to a dummy value really..
            wait 1 tick #Lets the items below spawn in the GUI
            format slot 4 of player with clock named "&bGame is starting in" with lore "&8> &6%{time.left}%" to be unstealable #Set slot 4 to a clock with the value from the variable {time.left}
    on inventory close: #When someone closes their inventory
        delete {inv.gamecount.%player%} #It will delete the variable that is used later

    on quit: #When someone quits
        delete {inv.gamecount.%player%} #It will delete the variable that is used later

    every second in "world": #Every second in the world "world"
        if {time.left} is set: #If the variable {time.left} has a value or exists
            remove 1 from {time.left} #Remove 1 (second) from the value
            loop all players: #Loop through every online player
                if {inv.gamecount.%loop-player%} is set: #If the variable is set in the GUI command block exists or has a value
                    format slot 4 of loop-player with clock named "&bGame is starting in" with lore "&8> &6%{time.left}%" to be unstealable #Do the format slot code with the new time
            stop #stop the code from repeating
        delete {time.left} #deletes the variable {time.left} for memory saving and for the code