SA-MP Forums Archive
KillTimer Error - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: KillTimer Error (/showthread.php?tid=176432)



KillTimer Error - [UG]Scripter - 13.09.2010

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);



Re: KillTimer Error - Calgon - 13.09.2010

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);



Re: KillTimer Error - [UG]Scripter - 13.09.2010

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


Re: KillTimer Error - [UG]Scripter - 13.09.2010

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;
}



Re: KillTimer Error - Calgon - 13.09.2010

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;
}