Time Error. Clock Restarts.
#1

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);
Reply
#2

Any suggestions?
Reply
#3

Help? The time went to 18 and it stops at 19 and restarts back to 18 again, any ideas? V_V
Reply
#4

Time is in sync with worldtime, but it keeps restarting..
Reply
#5

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);
Reply
#6

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.
Reply
#7

Bump
Reply
#8

STOP BUMPING THE POST.
Reply
#9

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);
}
Reply
#10

holy just do
pawn Код:
new hour, minute;
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)