Author Topic: Cooldowns with schedule(); ?  (Read 653 times)

How can I create a cooldown for a servercmd using schedule(); and variables?
schedule(3000,0,%client.PMcooldown = 0); is not working.

Let's say you have a server command called "serverCmdDoStuff"

You could put, at the start of said command:
Code: [Select]
if($Sim::Time - %client.doStuffCooldown < (delay in seconds))
{
    return;
}

And at the end of the function:
Code: [Select]
%client.doStuffCooldown = $Sim::Time;
I'm sorry to be spoonfeeding here but that's really all there is to it, you check if difference between the current time and the last time they used the command is less than a predetermined number, and if so, denies use of the command. Once the command has been successfully executed, it sets the last time they used the command to the current time.

Nvm, fixed it
Thanks!
« Last Edit: April 22, 2015, 10:23:30 PM by -Setro- »