KillTimer - 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: KillTimer (
/showthread.php?tid=638302)
KillTimer -
Amit1998 - 29.07.2017
Hi,
I'm using the following timer to set a repetitive checkpoint;
PHP код:
PlayerTemp[playerid][CPTimer] = SetTimerEx("TracenCP", 2000, true, "dd", playerid, targetID);
This is the function:
PHP код:
function:TracenCP(playerid, targetID)
{
if(IsPlayerInAnyInterior(targetID) || PlayerTemp[targetID][phoneoff] != 0 || !IsPlayerConnected(targetID))
{
DisablePlayerCheckpoint(playerid);
KillTimer(PlayerTemp[playerid][CPTimer]);
SendClientWarning(playerid, "Tracing failed.");
return 1;
}
new Float:position[3];
GetPlayerPos(targetID, position[0], position[1], position[2]);
SetPlayerCheckpoint(playerid, position[0], position[1], position[2], 2.0);
return 1;
}
If the tracing fails it should display the msg once and stop the timer but it doesnt.
Sometimes( I havent found the cause yet) it bugs it out completely and spams everyone Tracing Failed.
I'm killing the timer on a player spawn and disconnection aswell.
Thanks
Re: KillTimer -
Paulice - 29.07.2017
When you set the timer also kill it beforehand.
Re: KillTimer -
iamjems - 29.07.2017
Try it without the timer repeating.
PHP код:
// Somewhere in your script...
PlayerTemp[playerid][CPTimer] = SetTimerEx("TracenCP", 2000, false, "dd", playerid, targetID);
function:TracenCP(playerid, targetID)
{
if(IsPlayerInAnyInterior(targetID) || PlayerTemp[targetID][phoneoff] != 0 || !IsPlayerConnected(targetID))
{
DisablePlayerCheckpoint(playerid);
SendClientWarning(playerid, "Tracing failed.");
return 1;
}
new Float:position[3];
GetPlayerPos(targetID, position[0], position[1], position[2]);
SetPlayerCheckpoint(playerid, position[0], position[1], position[2], 2.0);
PlayerTemp[playerid][CPTimer] = SetTimerEx("TracenCP", 2000, false, "dd", playerid, targetID);
return 1;
}