KillTimer
#1

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
Reply
#2

When you set the timer also kill it beforehand.
Reply
#3

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)