SA-MP Forums Archive
Set player weather according to 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: Set player weather according to time... (/showthread.php?tid=143940)



Set player weather according to time... - IamNotKoolllll - 24.04.2010

i got the time enabled with TogglePlayerClock(playerid, 1); but its not setting the weather to the time like making it dark


Re: Set player weather according to time... - Nero_3D - 25.04.2010

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