Kill a timer within a function?
#7

Since you create a global array to store the timer ID for every player, the KillTimer does not have to be in the stock function that you use to create the timer.

But one thing that your code in the 1st post gets wrong is what SetTimerEx returns. SetTimerEx returns the timer's ID, not anything else. If you want to decrement a variable in there, you should create another array to store the data for players.

pawn Код:
new playerTimerID[MAX_PLAYERS],
    playerTimerVariable[MAX_PLAYERS];

stock MakeSomeTimer(playerid)
{
    playerTimerVariable[playerid] = 10;
    playerTimerID[playerid] = SetTimerEx("SomeTimer", 1000, true, "i", playerid);
}

forward SomeTimer(playerid);
public SomeTimer(playerid)
{
    playerTimerVariable[playerid] --;
    if(playerTimerVariable[playerid] == 0)
    {
        KillTimer(playerTimerID[playerid]);
    }
}
Reply


Messages In This Thread
Kill a timer within a function? - by Ranama - 29.06.2012, 20:56
Re: Kill a timer within a function? - by [A]ndrei - 29.06.2012, 20:57
Re: Kill a timer within a function? - by Ranama - 29.06.2012, 21:04
Re: Kill a timer within a function? - by [KHK]Khalid - 29.06.2012, 21:08
Re: Kill a timer within a function? - by Ranama - 29.06.2012, 21:11
Re: Kill a timer within a function? - by [KHK]Khalid - 29.06.2012, 21:14
Re: Kill a timer within a function? - by AndreT - 29.06.2012, 21:24

Forum Jump:


Users browsing this thread: 1 Guest(s)