Timers Usage 1.1 - Sharpjaws/SharpSK GitHub Wiki
Introduced since 1.6.1B
Quickbar:
For SharpSK's Variable-less timers you don't need to store variables for all of your timer variables in the skript database. This saves alot of work and it prevents alot of code cluttering from setting up complex timer variable systems.
Instead sharpsk's timers are actually temporarily running background threads handled by Java and sharpsk itself. You can create as many timers as you want, Just be careful not to create too many as this could possibly lag out your server depending on how much your computer/server can handle. It's important to not create timers you are not going to need in your scripts.
To create a timer you can simply do this:
create timer "testtimer" for 30 seconds
This will create a timer instance that is now active and running in the background. You can have multiple instances running at the same time but you can't create a timer with the same name twice. This is intentional and its purpose is to avoid confusion or possible bugs in the timer system.
Now that we have timer runnning we can now interact with it with these 2 events:
on timer tick:
In the timer tick event we can use event-time(Since 1.6.2.1)/event-number to get the amount of time left on a timer.
event-string can also be used here to get the timer's name.
on timer complete:
We can also use event-string to get the timer's name in a timer complete event so we can track which timer is finished counting.
The timer will call the timer tick event every time once a second has passed. We can use this to make something like a minigame countdown or something else. The timer complete event will trigger once the timer has finished its countdown. After it hits the timer complete event it is no longer active and you can no longer interact with it.
If you need the time of a timer outside of the events we can use this expression to get the time:
time of timer %string%
This will get the remaining time of a timer.
If you forgot which timers you had active or running you can always get a list of them with this expression:
[(the|all)] [of] [the] [running] timers
Example:
broadcast "%all running timers%"
Its possible to stop timers when you really need it without waiting for the countdown to finish, this is also called a force-stop. If you do this the timer complete event will not trigger as it has been purposely stopped.
Use this to stop a timer:
stop timer %string%
Not only can you create and stop timers its also possible to temporarily pause and resume them. This is very useful if you need to temporarily put a timer on hold or you need a delay a timer for resuming later on. Keep in mind that pausing a timer does not actually mean that you stopped a timer completely. It's basically the same as putting a timer inside a waiting queue for use later.
This can be done by the following syntaxes:
pause timer %string%
resume timer %string%