21.07.2012, 15:08
Here's an example,you need to code the timer like this:
And when the player disconnects,check:
And when it connects,load countn[playerid] into a variable[again also check the variable in database if IT'S NULE,meaning there's no reason for loading it then],and set the timer...THE COMMAND I used to set the timer,was an example,to prove how you work with this kind of timer,it's not mandatory for you to also script a command
pawn Code:
new countn[MAX_PLAYERS];//It will count down,or normally,as you choose..
forward TimerName(playerid);//This is the function that will define the timer
new timer[MAX_PLAYERS];//This is the name of the timer,but there's one particulary for every player,as if we want to destroy it,it won't destroy for everyone
COMMAND:starttimer(playerid,params[])
{
countn[playerid]=10;//It will count for 10 seconds
timer[playerid]=SetTimerEx("TimerName",countn,false,"i",playerid);//We set the timer for 10 seconds,as you can see
return 1;
}
//We now define the timer,like this:
public TimerName(playerid)
{
countn[playerid]--;//The timer decreases from 10 to 0
if(countn[playerid]>=-1)
{
KillTimer(timer[playerid]);
//code[What your timer actually does]
}
return 1;
}
pawn Code:
if(countn[playerid]!=0)//The timer is actually on
{
//store countn[playerid] in your DataBase
}