why is this not working?

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

JohniClark

Member
Feb 19, 2017
31
2
0
25
so i have a skript that has a command that sets a time variable to a int, and everysecond if an other variable is true, it adds 1 to a timepast variable, and if the timepast varible is more or equal to the time variable it should kick all players and after 2 seconds shutdown the server, i put the skript on my server i dont get any errors while reloading the skript, but it isnt working. here is the skript.

code_language.skript:
every 1 second:
    if {timeset} is true:
        add 1 to {timepast}
        if {timepast} is more than or equal to {timeleft.left}:
            loop all players:
                kick the loop-player
            wait 2 seconds
            execute console command "/stop"
        
command /timeleft [<int>]:
    trigger:
        if player does not have permission "timeleft.left":
            message "{@prefix} &4Keine Rechte!"
            stop
        else:
            if {timeset} is "false" or not set:
                set {timeleft.left} to arg
                set {timeset} to true
                message "{@prefix} &bDie Zeit Wurde auf &c%arg% &bGesetzt!"
                stop

PS: Ignore the german messages.
 
Sorry, but your code is really bad. Just do somelike this way:

code_language.skript:
command /timeleft [<int>]:
    trigger:
        if player does not have permission "timeleft.left":
            message "{@prefix} &4Keine Rechte!"
            stop
        else:
            if {timeset} is "false" or not set:
                set {timeleft.left} to "%arg-1%" parsed as number #to make be sure
                message "{@prefix} &bDie Zeit Wurde auf &c%arg% &bGesetzt!"
            while {timeleft.left} is not 0:
                subtract 1 from {timeleft.left}
                wait a seconds
                if {timeleft.left} is 3 or 2 or 1:
                    broadcast "Server wird in %{timeleft.left}% Sekunde neugestartet"
            loop all players:
               kick loop-player
               #im not sure but its too enough with under line
            #kick all players
            wait 2 seconds
            delete {timeleft.left}
            execute console command "/stop"


P.s Du braucht nicht überall "stop" einfügen...

P.s You don't need put "stop"
 
something is wrong with this code, if i type /timeleft 3, its fine it counts down and shutdowns the server. but when i type any number more than 3 it instantly shutdowns the server
 
still not working
[doublepost=1493991143,1493991024][/doublepost]i just saw the code is completly worng, this cant work.
 
You could do something like this:

Code:
command /timeleft [<int>]:
    trigger:
        set {timerstart} to now
        set {timerend} to arg 1

every second:
    set {timewaited} to difference between {timerstart} and now
    If {timewaited} is greater than {timerend} seconds:
        #do whatever
 
Does this work? If not, tell me what doesn't work.

code_language.skript:
every 1 second:
    if {timeset} is true:
        add 1 to {timepast}
        if {timepast} is more than or equal to {timeleft.left}:
            loop all players:
                kick the loop-player
            wait 2 seconds
            execute console command "/stop"
            set {timeset} to false
      
command /timeleft [<int>]:
    trigger:
        if player does not have permission "timeleft.left":
            message "{@prefix} &4Keine Rechte!"
            stop
        else:
            if {timeset} is false or not set:
                set {timeleft.left} to arg
                set {timeset} to true
                set {timepast} to 0
                message "{@prefix} &bDie Zeit Wurde auf &c%arg% &bGesetzt!"
 
Status
Not open for further replies.