schedule(%time,0,%function,[%arg1, [... %argN]]);
%object.schedule(%time,%function,[%arg1, [... %argN]]);
These functions will schedule a specific function to be called in a certain time, in milliseconds. The 0 in the first function indicates that it is a schedule for a global (non object specific) function. For instance:
%minigame.schedule(5000,reset); - Will reset a minigame 5 seconds from being called
schedule(1000,0,messageAll,'',"Hello!"); - Will message all clients "Hello!" in one second
Each function returns a schedule ID that you can use in various other functions:
%sched1 = schedule(...); - Stores the ID of a normal schedule in [i]%sched1[/i]
%sched2 = %object.schedule(...); - Stores the ID of an object schedule in [i]%sched2[/i]
cancel(%sched1); - Cancels [i]%sched1[/i] so it never occurs.
isEventPending(%sched2); - Returns whether %sched2 exists and is still going to occur
These can be used to start and stop events after a specified time. For instance:
%sched = schedule(10000,0,crash); - Game crash in 10 seconds! Quick, stop it!
if(isEventPending(%sched)) - %sched is still going to occur, return is 1
echo("We're doomed!"); - so this echoes
cancel(%sched);
if(isEventPending(%sched)) - %sched has been stopped, return is 0
echo("It's not working!"); - so this doesn't echo
else
echo("Cancelled."); - this echoes