/stats
#7

Well here's an example that might help you:

pawn Код:
enum pInfo { //
    Seconds,
    Minutes,
    Hours,
}
PlayerInfo Variable:
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
OnPlayerConnect or OnPlayerSpawn:
pawn Код:
SetTimerEx("GameTime",1000,1,"i",playerid); // Player Total Online Time every one second, seconds = + 1
pawn Код:
forward GameTime(playerid);
public GameTime(playerid) {
    PlayerInfo[playerid][Seconds]++; // When GameTime is being called, seconds are updated +1
    if(PlayerInfo[playerid][Seconds] == 60) { // If the total seconds = 60
        PlayerInfo[playerid][Minutes]++; // + 1 minute
        PlayerInfo[playerid][Seconds] = 0; // reset seconds to 0
    }
    if(PlayerInfo[playerid][Minutes] == 60) { // If the total minutes = 60
        PlayerInfo[playerid][Hours]++; // + 1 hour
        PlayerInfo[playerid][Minutes] = 0; // reset minutes to 0
        PlayerInfo[playerid][Seconds] = 0; // reset minutes to 0
    }
    return 1;
}
If you wanted to put it into a /stats command (ZCMD & sscanf):

pawn Код:
CMD:stats(playerid, params[]) {
    new id;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /stats [id]");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
    format(szString, sizeof(szString), "* Total Online Time: %i hours, %i minutes, and %i seconds", PlayerInfo[id][Hours], PlayerInfo[id][Minutes], PlayerInfo[id][Seconds]);
    SendClientMessage(playerid, COLOR_YELLOW, szString);
    return 1;
}
Reply


Messages In This Thread
/stats - by Edvin - 04.12.2011, 19:01
Re: /stats - by Sascha - 04.12.2011, 19:03
Re: /stats - by BleverCastard - 04.12.2011, 19:05
Re: /stats - by Sascha - 04.12.2011, 19:07
Re: /stats - by Edvin - 04.12.2011, 19:32
Re: /stats - by Edvin - 04.12.2011, 20:04
Re: /stats - by dr.pepper - 04.12.2011, 20:17
Re: /stats - by Edvin - 05.12.2011, 11:56

Forum Jump:


Users browsing this thread: 1 Guest(s)