SA-MP Forums Archive
Checkpoint Timer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Checkpoint Timer (/showthread.php?tid=655440)



Checkpoint Timer - div - 21.06.2018

How to add a cooldown at checkpoints? like im getting tped in and out again and again..


Re: Checkpoint Timer - Sew_Sumi - 21.06.2018

There is OnPlayerLeaveCheckpoint...

You just need to make a variable for the players (Which is likely to be an array), and set it to 10 or something when they enter the checkpoint.

Код:
new PCooldown[MAX_PLAYERS];
So you make a ticktimer (being 1 second timer), that goes through all players, checking that variable and if 'positive', minus 1 of it.

Код:
if(PCooldown[playerid])
{
    PCooldown[playerid]--;
}
Then in OnPlayerEnterCheckpoint, you check the variable is 0, or just less than 1, before allowing the callback to execute, and after this check, you then set their position, and set the variable to 10.

In OnPlayerLeaveCheckpoint you could set the variable to 0, but it'd be better to simply have the cooldown expire so they can't exploit interiors.



Now this is an old way of doing this.


Here's something else, just remember that variable is what you'll be using anyway, all it really is is how you are going to count down the time as such, so you know when the cooldown expires.

https://sampforum.blast.hk/showthread.php?tid=370955

This does it via tickcount, and could be something to look at as well, and likely better than what I've shown as timers, are unreliable for larger projects, or accurate timekeeping.