save the time left of a timer
#2

Here's an example,you need to code the timer like this:

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;
}
And when the player disconnects,check:

pawn Code:
if(countn[playerid]!=0)//The timer is actually on
{
   //store countn[playerid] in your DataBase
}
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
Reply


Messages In This Thread
save the time left of a timer - by Jstylezzz - 21.07.2012, 14:44
Re: save the time left of a timer - by Cjgogo - 21.07.2012, 15:08
Re: save the time left of a timer - by Jstylezzz - 21.07.2012, 17:07
Re: save the time left of a timer - by Cjgogo - 22.07.2012, 03:19

Forum Jump:


Users browsing this thread: 1 Guest(s)