PDA

View Full Version : Checkpoint Timer


div
21/06/2018, 07:20 AM
How to add a cooldown at checkpoints? like im getting tped in and out again and again..

Sew_Sumi
21/06/2018, 07:56 AM
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.

http://forum.sa-mp.com/showthread.php?t=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.