Clock Troubles - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Clock Troubles (
/showthread.php?tid=86755)
Clock Troubles -
StrickenKid - 15.07.2009
whats the best way to sync the game clock? right now i have a 1000 mil sec (1 sec) timer setting the second ++ every second to make sure all players clocks are synced... but the sky flashes allot and its really annoying... is there any way to fix this / better way to sync the clock?
i also had it synced to every minute before, but within that minute all the cocks get off of sync.....
any ideas?
Re: Clock Troubles -
StrickenKid - 15.07.2009
i guess no one has any ideas
Re: Clock Troubles -
ledzep - 15.07.2009
AFAIK the player clock that is used in single-player can only count minutes as real-life seconds (and hours as real-life minutes) and there's no changing that. So if you wanted it to be real-time, the clock would keep trying to increase 1 minute every second and you would have to reset it constantly for it to be accurate.
That's why I would just disable the player clock, create a textdraw that looks similar to the player clock, and use TextDrawSetString to update it.
I'm not too sure why your sky would flash though. Post your code?
Re: Clock Troubles -
Rizard - 30.09.2009
BUMB!
Having the same problem, my clock makes the sky flash 2, and realy like every second (ANOYING!
![Angry](images/smilies/evil.gif)
)
Here is my code, hope you guys can figure out why the sky flashes, (it would be a miracle)
somewhere in OnGameModeInit()
pawn Код:
SetTimer("ClockSync", 1000, 1);
bit furder down in my code
pawn Код:
forward ClockSync(playerid);
public ClockSync(playerid)
{
new string[128];
Minute = Minute + 1;
if (Minute == 60)
{
Time = Time + 1;
Minute = 0;
}
if (Time == 24)
{
Time = 0;
}
for(new i; i<MAX_PLAYERS; i++)
SetPlayerTime(i, Time, Minute);
format(string, sizeof(string), "The time [%d] [%d]", Time, Minute);
//print(string); // testing only.
print("achtenveertigste bericht - tot hier ok");
return 1;
}
Grts Riz
Re: Clock Troubles -
CracK - 30.09.2009
I suggest you not to use SetPlayerTime. SetWorldTime is better, it doesn't need to be synced and the time doesn't go until you do SetWorldTime once again.
Re: Clock Troubles -
Rizard - 30.09.2009
How are you suggesting me to use SetWorldTime(hour); since it only has one param ?
Grts Riz
Re: Clock Troubles -
CracK - 30.09.2009
Weather does not actually differ a lot during 1 hour. So you can make your own clock with textdraw and use gettime(); to set minutes and hours(+SetWorldTime) to that textdraw.
Re: Clock Troubles -
Rizard - 30.09.2009
Ok, so you're saying, I should just make my own textdraw and each hour(rl minute) set the world time so the weather changes with it?
Fine by me but, anyone has the
coцrdinates of a textdraw at the spot of the playertime? (right-top corner)
Grts Riz
Re: Clock Troubles -
CracK - 30.09.2009
Look here -
http://forum.sa-mp.com/index.php?topic=84349.0
Re: Clock Troubles -
Rizard - 30.09.2009
Ok thnx man
Appreciate it
Grts Riz
Re: Clock Troubles -
Desert - 30.09.2009
Ohai rizzy
I just wonder. Why should your string be posted in the console?
That would spam it alot unneccesary