25.04.2010, 00:37
I dont prefer this clock because (Note: Time will automatically advance 6 hours when the player dies.)
But there is a good example (on the wiki page) how to sync it with all players
We only need to add SetWorldTime in the timer ProcessGameTime
Here the example (removed the text)
But there is a good example (on the wiki page) how to sync it with all players
We only need to add SetWorldTime in the timer ProcessGameTime
Here the example (removed the text)
pawn Код:
static i_ServerSeconds;
static i_ServerMinutes;
static i_ServerHours;
forward ProcessGameTime();
public OnGameModeInit()
{
SetWorldTime(i_ServerHours);
SetTimer("ProcessGameTime", 1000, 1);
}
public ProcessGameTime()
{
if(++i_ServerSeconds == 60)
{
if(++i_ServerMinutes == 60)
{
if(++i_ServerHours == 24)
{
i_ServerHours = 0;
}
SetWorldTime(i_ServerHours);
i_ServerMinutes = 0;
}
i_ServerSeconds = 0;
}
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
SetPlayerTime(playerid, i_ServerHours, i_ServerMinutes);
}