Author Topic: Add delay after use of function  (Read 650 times)

Alright, I'm just going to set an example here.

Code: [Select]
hi()
{

     echo("Hi!"); //echo only if the time delay is over
}

How do I make it so that this function can't be spammed over and over again?
Like if a player used it, how can you make them wait 5 seconds before they can
activate it again?

Code: [Select]
$lastUse = 0;
function hi()
{
    if(getSimTime() - $lastUse > 5000)
    {
        echo("hi");
        $lastUse = getSimTime();
    }
    else
    {
        //Wait some more
    }
}