Solved Creating a timer

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

Lordcre_

Supporter
May 7, 2017
22
3
0
I'm trying to create a timer using SharpSK that will constantly run, the problem is that I need a way to restart the timer after a server restart with the time remaining on the timer at the moment of the server restart.

I'm currently using local variables to set the duration and the type of time because it doesn't like regular variables- which, in reality, is what I want to use.

code_language.skript:
options:
    interval: 10
    type: seconds

on timer complete:
    if event-string is "test":
        wait 1 tick
        create timer "test" for {@interval} {@type}
 
I'm trying to create a timer using SharpSK that will constantly run, the problem is that I need a way to restart the timer after a server restart with the time remaining on the timer at the moment of the server restart.

I'm currently using local variables to set the duration and the type of time because it doesn't like regular variables- which, in reality, is what I want to use.

code_language.skript:
options:
    interval: 10
    type: seconds

on timer complete:
    if event-string is "test":
        wait 1 tick
        create timer "test" for {@interval} {@type}
What do you mean it doesn't like global variables?
 
What do you mean it doesn't like global variables?
It couldn't understand the syntax. I ended up ditching SharpSK's timer and just made one. Not sure why it isn't working though.

code_language.skript:
function timerGo(n: number) :: number:
    set {_t} to {wr.interval}
    loop {_t} times:
        broadcast "%{_t}%"
        wait 1 second
        remove 1 from {_t}
        if {_t} = 0:
            timerGo(1)
 
It couldn't understand the syntax. I ended up ditching SharpSK's timer and just made one. Not sure why it isn't working though.

code_language.skript:
function timerGo(n: number) :: number:
    set {_t} to {wr.interval}
    loop {_t} times:
        broadcast "%{_t}%"
        wait 1 second
        remove 1 from {_t}
        if {_t} = 0:
            timerGo(1)
I'm willing to bet you weren't giving it a timespan
 
Sharpsk's timer
Ah okay. You may be right, but I think it'll be to my benefit to use this alternate method (if I can ever figure out why it's not working)

code_language.skript:
function timerGo(n: number) :: number:
    set {_t} to {wr.interval}
    loop {_t} times:
        broadcast "%{_t}%"
        wait 1 second
        remove 1 from {_t}
        if {_t} = 0:
            timerGo(1)
 
Status
Not open for further replies.