SA-MP Forums Archive
Timer isn't getting killed! - 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: Timer isn't getting killed! (/showthread.php?tid=581630)



Timer isn't getting killed! - Dan. - 14.07.2015

FIXED. Problem was in fixes.inc file which was from 2012.


Re: Timer isn't getting killed! - Lordzy - 14.07.2015

Set your "PlayerZoneTimer" array's default value to be -1. While setting it, if it's not equal to -1 (which means it's already active), don't call the timer. Timers can be repeating in case if duplicates are created.

pawn Код:
if(mytimer == -1)
    SetTimer(...); //else I'm not setting the timer.



Re: Timer isn't getting killed! - notime - 14.07.2015

I myself never used KillTimer because I dont trust it. I've noticed in the past that it doesnt always work. It's a known bug and after 8 years I'm very dissapointed to hear its still not fixed.
How I used to do it is set a variable in the callback of the timer and keep setting the timer over and over again. Once the variable isnt 1 anymore it wouldnt set the timer anymore. If that makes sense to you?

So basically:
pawn Код:
new TimerVar;
Ofcourse you can make it player bound aswel with [MAX_PLAYERS], in that case you have to use SetTimerEx to get the playerid.
Basically at the spot you set the timer dont forget to set the TimerVar(so when he enters the zone):
pawn Код:
SetTimer("GangCount", 1000, false, "iis", playerid, checkpointid, zonename);
TimerVar = 1;
Then your stuff(im not gonna fully copy and paste it though):
pawn Код:
forward GangCount(playerid, checkpointid, zonename);
public GangCount(playerid, checkpointid, zonename)
{
   If TimerVar == 1
   {
      SetTimer("GangCount", 1000, false, "iis", playerid, checkpointid, zonename);
   }
   Your stuff here
}
Then at the spot you placed KillTimer, simply Set the TimerVar = 0; and it stops the timer.