07.12.2012, 17:30
ok so if you want to create a timer for a player then:
That is it really
just to explain, you can forward any variables with the SetTimerEx
Example
everything is explained in the WIKI
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;
}
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