SA-MP Forums Archive
Online 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: Online Time (/showthread.php?tid=329293)



Online Time - Luis- - 28.03.2012

Is this correct?
pawn Код:
forward PlayerHour(playerid);
public PlayerHour(playerid) {
    PlayerInfo[playerid][pSecond]++;
    if(PlayerInfo[playerid][pSecond] == 60) {
        PlayerInfo[playerid][pMinute]++;
        PlayerInfo[playerid][pSecond] = 0;
    }
    else if(PlayerInfo[playerid][pMinute] == 60) {
        PlayerInfo[playerid][pMinute] = 0;
        PlayerInfo[playerid][pHour]++;
    }
    printf("TIME ONLINE(%s): %d:%d:%d", Name(playerid), PlayerInfo[playerid][pHour], PlayerInfo[playerid][pMinute], PlayerInfo[playerid][pSecond]);
    return 1;
}
My Timer:
pawn Код:
HourStat[playerid] = SetTimerEx("PlayerHour", 1000, true, "i", playerid);



Re: Online Time - Lynn - 28.03.2012

Looks correct, how ever I'd suggest using
<= 60
not
== 60
simply for the fact that it may skip the variable, for what-ever reason.
Other then that it looks fine.