Requesting Support - Cancelling a skript

Discussion in 'Skript' started by devJordan, Jan 31, 2018.

  1. So I have a skript that replaces the /restart command to run a broadcast telling the server that it will restart in 1 minute, then wait 60 seconds then run /spigot:restart, however I'd love to also have a /cancel command that can be done while the timer is going. If anyone knows how to do this please let me know even if it means changing the timer or something about the current skript, I don't mind.
    Code (Text):
    command restart:
        permission: infamous.restart
        permission message: &4Insufficient Permissions! &cinfamous.restart
        trigger:
            Broadcast "&3[&bRestart&3] &bA restart has been issued! The server will restart in &l1 minute&b."
            wait 60 seconds
            execute command "/spigot:restart"
     
  2. set a default for a variable like 'doRestart' that's false.
    When the timer starts, set it to true.
    When the time get interrupted with a cancel command, let that command also set it to false.
    When the timer is actually up.. it can check against true/false and runs the restart command accordingly?

    This might be a patchy way to achieve that.
     
  3. Code (Text):
    command restart:
        permission: infamous.restart
        permission message: &4Insufficient Permissions! &cinfamous.restart
        trigger:
            set {SERVER.RESTART} to true
            Broadcast "&3[&bRestart&3] &bA restart has been issued! The server will restart in &l1 minute&b."  
            set {_loop} to 60
            loop 60 times:
                if {SERVER.RESTART} is true:
                    remove 1 from {_loop}
                    wait 1 seconds
                    if {_loop} = 0:
                        execute command "/spigot:restart"  
                else:
                    Broadcast "&3[&bRestart&3] &bSTOPPED"  
                    stop loop
                   
                       
    command cancelrestart:
        permission: infamous.restart
        permission message: &4Insufficient Permissions! &cinfamous.restart
        trigger:
            set {SERVER.RESTART} to false

       
     
     
    • Useful Useful x 1