SA-MP Forums Archive
Server 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)
+--- Thread: Server Time (/showthread.php?tid=463283)



Server Time - Hade. - 11.09.2013

Hey everyone!

Is it possible to have the same time in the server thats in the real world? Also with a clock textdraw.


Re: Server Time - Eyce - 11.09.2013

Depends on the timezone of where your server is hosted. And yes, it is possible to create a text-draw for it.


Re: Server Time - Slice - 11.09.2013

You could just enable the in-game clock and set its value.

pawn Код:
public OnGameModeInit() {
    // run UpdateTime every 1000ms
    // 1000ms = 1 second
    // repeating: true
    SetTimer("UpdateTime", 1000, true);
}

public OnPlayerConnect(playerid) {
    // Show the clock for the player
    TogglePlayerClock(playerid, true);

    return 1;
}

forward UpdateTime();
public UpdateTime() {
    new hour, minute;

    // gettime will save the values into the variables
    gettime(hour, minute);

    // loop all players
    for (new p = 0; p < MAX_PLAYERS; p++) {
        if (IsPlayerConnected(p)) {
            // set the in-game time and
            SetPlayerTime(p, hour, minute);
        }
    }
}