Long timers question
#1

Hey guys, can you help me with some links regarding long timers or some examples?

For example, I want to make a drug system, and there is a medical drug that will hold off the drug effect for 4 hours?

Do I make something like this?:
PHP код:
new drugtimer[MAX_PLAYERS] = 60
And a timer that will lower it by 1 every minute?
Reply
#2

I think you could use a timestamp. You could do something like this:

On getting drug effect:
Код:
DrugTimeStamp[playerid] = gettime() + 14400; // thats 4hours in seconds
           Druged[playerid] = 1;
Then if you have a global timer in the server you could do something like this:
Код:
public MinuteTimer()
{
     foreach(new i : Player)
     {
            if(Druged[playerid] == 1)
            {
                 if(DrugTimeStamp[i] < gettime())
                 {
                          //Wear off the drugs
                  }
             }
      }
      return 1;
}
Though if you did this and the player disconnected, and connected 5 hours later the drugs would have worn off. (Also sorry for messy code)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)