Time Spent In Game
#2

Use this code as a timer (so set this as a timer in OnGameModeInit):

pawn Code:
forward conTimeTimer();
public conTimeTimer() {
    foreach(Player, x) {
        SetPVarInt(x, "playerTime", GetPVarInt(x, "playerTime") + 1);
    }
    return 1;
}
Then your function:
pawn Code:
CMD:timespent(playerid, params[]) {
    new
        szMessage[64];

    switch(GetPVarInt(playerid, "playerTime")) {
        case 0..59: {
            format(szMessage, sizeof(szMessage), "You have been online for: %d seconds.", GetPVarInt(playerid, "playerTime"));
        }
        case 60..3599: {
            format(szMessage, sizeof(szMessage), "You have been online for: %d minutes.", GetPVarInt(playerid, "playerTime") / 60);
        }
        case 3600..86399: {
            format(szMessage, sizeof(szMessage), "You have been online for: %d hours.", GetPVarInt(playerid, "playerTime") / 60);
        }
        case 86400..604800: {
            format(szMessage, sizeof(szMessage), "You have been online for approximately %d days.", GetPVarInt(playerid, "playerTime") / 60 / 60 / 24);
        }
    }

    SendClientMessage(playerid, 0, szMessage);
    return 1;
}
I haven't tested this, but most of it should work, if not it should be suitable as pseudo-code to work from.
Reply


Messages In This Thread
Time Spent In Game - by Serifukas - 06.07.2011, 14:41
Re: Time Spent In Game - by Calgon - 06.07.2011, 14:56
Re: Time Spent In Game - by Serifukas - 06.07.2011, 15:33
Re: Time Spent In Game - by Serifukas - 07.07.2011, 10:09
Re: Time Spent In Game - by Madsen - 07.07.2011, 10:15
Re: Time Spent In Game - by Serifukas - 07.07.2011, 11:56

Forum Jump:


Users browsing this thread: 1 Guest(s)