Clock using timer?
#3

ingame clock moves a minute once per second. so you'd have to update quite frequently since it will change a lot. It's best to just make you're own using textdraws

pawn Код:
new Text:WorldTime;
new Hour,Minute,Second;
forward UpdateWorldTime();
CalculateTime(&hour,&minute,&second)
{
  label:
  if(second>=60){second-=60;minute++;goto label;}
  if(second<=-1){second+=60;minute--;goto label;}
  if(minute>=60){minute-=60;hour++;goto label;}
  if(minute<=-1){minute+=60;hour--;goto label;}
  if(hour>=13){hour-=12;goto label;}
  if(hour<=0){hour+=12;goto label;}
}
//ongamemodeinit or onfilterscriptinit
WorldTime=TextDrawCreate(10,450,"BACON!"); // change the location and the text doesn't really matter
gettime(Hour,Minute,Second);
Second--;
UpdateWorldTime();
SetTimer("UpdateWorldTime",1000,1);
//anywhere outside of a callback
public UpdateWorldTime()
{
  Second++;
  CalculateTime(Hour,Minute,Second);
  new tmpstr[10];
  format(tmpstr,sizeof(tmpstr),"%02d:%02d:%02d",Hour,Minute,Second);
  TextDrawSetString(WorldTime,tmpstr);
}
That should allow you to choose to stay with the server's time, or make you're own by changing the Hour,Minute, and Second variables in a command

Don't forget to TextDrawShowForPlayer(playerid,WorldTime); under OnPlayerConnect


EDIT* You may have noticed about 6 different changes since I first posted this lol, I haven't tested it and I'm correcting / rewriting
EDIT** editted again lol, had a infinite loop
Reply


Messages In This Thread
Clock using timer? - by Yuryfury - 18.02.2009, 02:13
Re: Clock using timer? - by Mikep - 18.02.2009, 02:14
Re: Clock using timer? - by Joe Staff - 18.02.2009, 02:31

Forum Jump:


Users browsing this thread: 4 Guest(s)