How to set time without clock?
#1

Im trying to make an clock, but just on time change:

Код:
forward relogio(playerid);
Код:
 
Public OnFilterScriptInit()
{
  SetTimer("relogio", 2000, false);
  return 1;  
}
Код:
public relogio(playerid)
{

  for(new i = 0; i < MAX_PLAYERS; i++)
  {
  new hour,minute;
  GetPlayerTime(i, hour, minute);
  SetPlayerTime(i, hour, minute+1);
  if(minute == 59)
  {
	 SetPlayerTime(i, hour+1, 0);
  }
  }
  SetTimer("relogio", 2000, true);


  return 1;
}
It's like setting the minute of server time by 1min per 2seconds on real life, and if minute = 59, add hour+1 and set minute to 0. It's like an clock which updates every 2 seconds on real life, for each player, and changing server time
Reply
#2

Personally, I would do this:
pawn Код:
forward relogio();
public relogio()
{
       minutes = minutes + 1;
       if(minutes == 60)
       {
            minutes = 0;
            hours = hours + 1;
            SetWorldTime(hours);
       }
       if(hours == 24)
       {
             minutes = 0;
             hours = 0;
       }
}
That's how it was done for me, I hope this helps a bit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)