SA-MP Forums Archive
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"2000true"dd"playeridtargetID); 
This is the function:
PHP код:
function:TracenCP(playeridtargetID)
{
    if(
IsPlayerInAnyInterior(targetID) || PlayerTemp[targetID][phoneoff] != || !IsPlayerConnected(targetID))
    {
        
DisablePlayerCheckpoint(playerid);
        
KillTimer(PlayerTemp[playerid][CPTimer]);
        
SendClientWarning(playerid"Tracing failed.");
        return 
1;
    }
    new 
Float:position[3];
    
GetPlayerPos(targetIDposition[0], position[1], position[2]);
    
SetPlayerCheckpoint(playeridposition[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"2000false"dd"playeridtargetID);  
function:
TracenCP(playeridtargetID

    if(
IsPlayerInAnyInterior(targetID) || PlayerTemp[targetID][phoneoff] != || !IsPlayerConnected(targetID)) 
    { 
        
DisablePlayerCheckpoint(playerid); 
        
SendClientWarning(playerid"Tracing failed."); 
        return 
1
    } 
    new 
Float:position[3]; 
    
GetPlayerPos(targetIDposition[0], position[1], position[2]); 
    
SetPlayerCheckpoint(playeridposition[0], position[1], position[2], 2.0);
    
PlayerTemp[playerid][CPTimer] = SetTimerEx("TracenCP"2000false"dd"playeridtargetID);  
    return 
1