KillTimer Error
#1

Hmm... When I try and Kill a Timer I have, I am greeted by:

C:\Users\Brad\****.pwn(3249) : error 076: syntax error in the expression, or invalid function call

Line in Question:

pawn Код:
KillTimer(Drag);
Set Timer Code:

pawn Код:
SetTimerEx("Drag",2000,true,"i",id);
Reply
#2

You can't kill timer for a function name... Timers return timer handles, you need to store them in a variable, then you can unset them.

pawn Код:
new
      vTimer;

vTimer = SetTimerEx("Drag",2000,true,"i",id);
KillTimer(vTimer);
Reply
#3

The Issue is, I'm setting the timer in one command a killing it in another.
Reply
#4

Here's the command:

pawn Код:
dcmd_drag(playerid,params[])
{
    new Drag;
    new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_LVPD) return     SendClientMessage(playerid,ORANGE,"Law Enforcement command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /drag <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s Takes %s by the wrist and start's leading them",n,on);
    Drag = SetTimerEx("Drag",2000,true,"i",id); // Sets Timer
    return 1;
}

dcmd_stopdrag(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_LVPD) return SendClientMessage(playerid,ORANGE,"Law Enforcement command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /drag <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s Stops Leading %s",n,on);
    TogglePlayerControllable(id,0);
       KillTimer(Drag); // Kills timer
    return 1;
}
Reply
#5

Quote:
Originally Posted by [UG]Scripter
Посмотреть сообщение
The Issue is, I'm setting the timer in one command a killing it in another.
I fail to see how you couldn't have just turned it in to a variable w/ MAX_PLAYER cells yourself...

pawn Код:
new
    playerTimerHandle[MAX_PLAYERS];

dcmd_drag(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_LVPD) return     SendClientMessage(playerid,ORANGE,"Law Enforcement command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /drag <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s Takes %s by the wrist and start's leading them",n,on);
    playerTimerHandle[playerid] = SetTimerEx("Drag",2000,true,"i",id); // Sets Timer
    return 1;
}

dcmd_stopdrag(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_LVPD) return SendClientMessage(playerid,ORANGE,"Law Enforcement command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /drag <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s Stops Leading %s",n,on);
    TogglePlayerControllable(id,0);
    KillTimer(playerTimerHandle[playerid]); // Kills timer
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)