Error with clock/time
#1

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)