Timers
#1

Need help on player timers. I want a timer to appear to a player upon doing a command, and then sending a wad of text. I also need to know how to kill timers and all that needs to be told about timers. Timers are cool. I like timers. Timers make SAMP what it is.
Thanks for the timer help.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)