Trying to make a cooldown timer
#1

Trying to make a cooldown timer for an engine.

What people do at the moment is they can spam start/stop engine.


How would I do so?
Reply
#2

First of all its a wrong section.

Secondly you should use gettime() and assign it to players variable (can be SetPVarInt), then when he tries to turn/shut the engine check if the specified time has passed.

pawn Код:
SetPVarInt(playerid, "Time", gettime() + 5); // <--- 5 seconds

//---

if(gettime() > GetPVarInt(playerid, "Time"))
//do the code
Reply
#3

Or you can do this:

pawn Код:
// At the top of script
new EngineTimer[MAX_PLAYERS];
// Add this where it will stop them.
if(EngineTimer[playerid] > 0)  return 0;
// Add this to whenever the engine starts.
EngineTimer[playerid] = 1;
SetTimerEx("ResetEngine", 3000, false, "i", playerid);
Now the function.
pawn Код:
foward ResetEngine(playerid);
public ResetEngine(playerid)
{
    EngineTimer[playerid] = 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)