Time Error. Clock Restarts. -
David5290 - 28.01.2011
Okay my clock shows but it starts at 16:30 and then it goes to like 17:30 then it restarts at 16:30 again.
I tried messing with it, to sync my clock to WorldTime, and I messed it up it seems.
Here's the codes that I have in my GameMode.
Could someone check these codes and make sure they are correct, if they aren't could you please fix them in a reply.
Код:
public OnGameModeInit()
{
SetTimer("UpdateTime",65009, 1);
Код:
public OnPlayerConnect(playerid)
{
TogglePlayerClock(playerid, 1);
gettime(hour, minute);
PlayerInfo[playerid][logminute] = 0;
SetPlayerTime(playerid,hour,minute);
Код:
public OnPlayerSpawn(playerid)
gettime(hour, minute);
SetPlayerTime(playerid,hour,minute);
Код:
new worldTime;
public UpdateTime()
{
gettime(hour, minute);
worldTime++;
worldTime%=24;
SetWorldTime(hour);
new x=0;
while(x!=MAX_PLAYERS)
{
if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE)
{
SetPlayerTime(x,hour,minute);
}
x++;
}
if(minute < 1)
{
new string[128];
format(string, 128, "Game Time: %02d:00", minute);
SendClientMessageToAll(COLOR_GREEN, string);
Re: Time Error. Clock Restarts. -
David5290 - 28.01.2011
Any suggestions?
Re: Time Error. Clock Restarts. -
David5290 - 28.01.2011
Help? The time went to 18 and it stops at 19 and restarts back to 18 again, any ideas? V_V
Re: Time Error. Clock Restarts. -
David5290 - 28.01.2011
Time is in sync with worldtime, but it keeps restarting..
AW: Time Error. Clock Restarts. -
Nero_3D - 29.01.2011
JUST WAIT till someone knows whats wrong
I can only say that I dont see why it goes back and forth
I can only tell that there is some part missing at the end of UpdateTime in your post
And that this part is nonsense for me
pawn Код:
if(minute < 1)
{
new string[128];
format(string, 128, "Game Time: %02d:00", minute);
SendClientMessageToAll(COLOR_GREEN, string);
Or why 65009 ?, instead of 60000 (1 min)
pawn Код:
SetTimer("UpdateTime",65009, 1);
Re: AW: Time Error. Clock Restarts. -
David5290 - 29.01.2011
Quote:
Originally Posted by Nero_3D
JUST WAIT till someone knows whats wrong
I can only say that I dont see why it goes back and forth
I can only tell that there is some part missing at the end of UpdateTime in your post
And that this part is nonsense for me
pawn Код:
if(minute < 1) { new string[128]; format(string, 128, "Game Time: %02d:00", minute); SendClientMessageToAll(COLOR_GREEN, string);
Or why 65009 ?, instead of 60000 (1 min)
pawn Код:
SetTimer("UpdateTime",65009, 1);
|
I forgot to edit the post. And SetTimre to 6000, didn't really do anything, still keeps restarting.
Re: Time Error. Clock Restarts. -
David5290 - 29.01.2011
Bump
Re: Time Error. Clock Restarts. -
Antonio [G-RP] - 29.01.2011
STOP BUMPING THE POST.
Re: Time Error. Clock Restarts. -
David5290 - 29.01.2011
Fixed, but now, I want the in-game clock to match the worldtime on my server.
Код:
public UpdateTime()
{
gettime(hour, minute);
worldTime++;
worldTime%=24;
SetWorldTime(worldTime);
}
AW: Time Error. Clock Restarts. -
Nero_3D - 29.01.2011
holy just do
pawn Код:
//OnGameModeInit
SetTimer("UpdateTime", 60 * 1000, true);
pawn Код:
//OnPlayerConnect
TogglePlayerClock(playerid, true);
SetPlayerTime(playerid, hour, minute);
pawn Код:
//OnPlayerSpawn
SetPlayerTime(playerid, hour, minute);
pawn Код:
forward UpdateTime();
public UpdateTime()
{
gettime(hour, minute);
for(new i; i != MAX_PLAYERS; i++) SetPlayerTime(i, hour, minute);
SetWorldTime(hour);
}
That will sync the time for all players and sets the world time to the time on the clock
And I dont know where the f****** problem was with that