IG clock problem
#1

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


Forum Jump:


Users browsing this thread: 1 Guest(s)