SA-MP Forums Archive
IG clock problem - 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: IG clock problem (/showthread.php?tid=215631)



IG clock problem - Outcast - 23.01.2011

Well , I used the example posted on the Wiki page for TogglePlayerClock (https://sampwiki.blast.hk/wiki/TogglePlayerClock), to sync the clock with all players and to make it realtime. But, whenever I log in, the clock is set to 00:00 and every one second minutes 00x are increased by 1. I don't see what may be the problem. Here's the code.

pawn Код:
public OnPlayerSpawn(playerid)
{
    TogglePlayerClock(playerid, 1);
    return 1;
}

public ProcessGameTime()
{
    i_ServerSeconds++;

    // One minute has passed...
    if(i_ServerSeconds == 60)
    {
        // Reset the second counter
        i_ServerSeconds = 0;

        // Increment the minute counter
        i_ServerMinutes++;

        // One hour has passed
        if(i_ServerMinutes == 60)
        {
            i_ServerMinutes = 0;
            i_ServerHours++;

            if(i_ServerHours == 24)
            {
                // One day has passed
                i_ServerHours = 0;
            }
        }
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    UpdatePlayerTime(playerid);
}


stock UpdatePlayerTime(playerid)
{
    SetPlayerTime(playerid, i_ServerHours, i_ServerMinutes);
}
On the top of my script (below includes) I put static i_ServerHours, i_ServerMinutes, i_ServerSeconds.

This is my timer that is set on gamemode init:

pawn Код:
SetTimer("ProcessGameTime", 1000, 1);