Best way to make timers.
#2

I don't like to use many timers:

pawn Code:
new
  Second,
  Minute,
  Hour;
pawn Code:
public OnGameModeInit()
{
  SetTimer("OneSecondTimer", 1000, true);
  return 1;
}
pawn Code:
public OneSecondTimer()
{
  Second ++;

  if(Second == 60) // one minute
  {
    SendClientMessage(playerid, COLOR, "60 Seconds.");
    Minute ++;
    Second == 0;
  }
  else if(Minute == 60) // one hour
  {
    SendClientMessage(playerid, COLOR, "60 Minutes.");
    Hour ++;
    Minute == 0;  
  }
  return 1;
}
Just remember if you want things to happen only once, reset the variables:

pawn Code:
Variable == 0;

Reply


Messages In This Thread
Best way to make timers. - by CaHbKo - 06.01.2010, 20:38
Re: Best way to make timers. - by Miguel - 06.01.2010, 22:51

Forum Jump:


Users browsing this thread: 1 Guest(s)