Timers
#2

ok so if you want to create a timer for a player then:
pawn Code:
//variables needed
new PlayerTimer[MAX_PLAYERS];//this variable will effect every player on the server(once assigned!)

//When ever you start the timer e.g. on player command:
PlayerTimer[playerid] = SetTimerEx("OnTimerFinish", 10000, true, "i", playerid);//this a 10 sec timer. Also (true) makes the timer repeat
//the call back
forward OnTimerFinish(playerid);
public OnTimerFinish(playerid)
{
     //Timer finished,do what ever you want
     KillTimer(PlayerTimer[playerid]);//This will kill the players timer.
     return 1;
}
That is it really

just to explain, you can forward any variables with the SetTimerEx
Example
pawn Code:
//inside a function, and you have a NON public variable.
new Var=22;//you want to pass this to the finish of the timer
PlayerTimer[playerid] = SetTimerEx("OnTimerFinish", 10000, false, "ii", playerid,Var);//Again 10sec.
//And added another "i" and "Var" to the parameters
everything is explained in the WIKI
Reply


Messages In This Thread
Timers - by 69 - 07.12.2012, 17:18
Re: Timers - by park4bmx - 07.12.2012, 17:30

Forum Jump:


Users browsing this thread: 1 Guest(s)