SA-MP Forums Archive
Error with clock/time - 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: Error with clock/time (/showthread.php?tid=129674)



Error with clock/time - bajskorv123 - 23.02.2010

Ok, I want my clock to have a automatic day/night loop (I think it is by default)
When i spawn, my clock shows 0, when it should show something else because i dont spawn directly after the server starts >_>
And when i die, then spawn again, the clock has gone forward by 12 hours, how to prevent this?
pawn Код:
public OnGameModeInit()
{
  SetWorldTime(0);
}

public OnPlayerSpawn(playerid)
{
  TogglePlayerClock(playerid, true);
  return 1;
}



Re: Error with clock/time - lameguy - 23.02.2010

You could try this:

pawn Код:
new ClockMinutes;
new ClockHours;
Код:
public OnGameModeInit()
{
	ClockMinutes = 0;
	ClockHours = 0;
	
	SetTimer("Clock", 1000, true);
	SetTimer("SetTime", 1000, true);
	return 1;
}
Код:
forward SetTime();
public SetTime()
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
	{
	  SetPlayerTime(i, ClockHours, ClockMinutes);
	}
	return 1;
}

forward Clock();
public Clock()
{
	ClockMinutes ++;
	if(ClockMinutes >= 60)
	{
	  ClockHours ++;
	  ClockMinutes = 0;
	}
	return 1;
}



Re: Error with clock/time - Jakku - 25.02.2010

Quote:
Originally Posted by Johnson_boy
You could try this:

pawn Код:
new ClockMinutes;
new ClockHours;
Код:
public OnGameModeInit()
{
	ClockMinutes = 0;
	ClockHours = 0;
	
	SetTimer("Clock", 1000, true);
	SetTimer("SetTime", 1000, true);
	return 1;
}
Код:
forward SetTime();
public SetTime()
{
	for(new i = 0; i < MAX_PLAYERS; i ++)
	{
	  SetPlayerTime(i, ClockHours, ClockMinutes);
	}
	return 1;
}

forward Clock();
public Clock()
{
	ClockMinutes ++;
	if(ClockMinutes >= 60)
	{
	  ClockHours ++;
	  ClockMinutes = 0;
	}
	return 1;
}
That won't work. You have to define new ClockMinutes & ClockHours as a float.

This line causes the warnings / errors:

pawn Код:
SetPlayerTime(i, ClockHours, ClockMinutes);