30.01.2014, 12:46
If you don't want players to spam, then an anti spam would be the solution:
GetTickCount() returns the amount of milliseconds since server started, you can do the following
You assign a variable the current time+500 MS. When the key is pressed again, it will check if the current time is less than that variable that you previously set, and this means that 500 MS haven't passed.
By using timers, without this kind of checks what you're going to achieve is that the timer gets sent multiple times.
However if you just want to delay the action (players would still be able to spam it), refeer to the post above.
GetTickCount() returns the amount of milliseconds since server started, you can do the following
pawn Код:
if(KEYS == KEY_NO)
{
if(GetPVarInt(playerid,"lastpress") > GetTickCount())
return 1;
// insert your code
SetPVarInt(playerid,"lastpress", GetTickCount()+500); //500 MS before the function can be executed again.
}
By using timers, without this kind of checks what you're going to achieve is that the timer gets sent multiple times.
However if you just want to delay the action (players would still be able to spam it), refeer to the post above.