SA-MP Forums Archive
Time Spent In Game - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Time Spent In Game (/showthread.php?tid=266893)



Time Spent In Game - Serifukas - 06.07.2011

Hello All.
I Figured One Thing,I Think This Is Possible But I Don't Know How To Do It.
I want to do command which show player time spent in server and do code which save player spent time and then he use command:
Code:
COMMAND:spenttime(playerid,params[])
{
///Spent Time Code
///
new time [80] ;
format( time , 80 , " You Spent Time In This Server:  %s " , //TIME CODE//);
return 1;
}
Something Like This This Is Just Command I Know How To Make Command But Don't Know How To Make Script Which Show What Of The Time Player Spent In Server If Possible Would Be And Days. :S
Sorry If In The Text Are Fouls Because I'am tired and I Learning English.
If Someone Can Help Please Help Thanks In Advice..


Re: Time Spent In Game - Calgon - 06.07.2011

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.


Re: Time Spent In Game - Serifukas - 06.07.2011

Thanks For Help


Re: Time Spent In Game - Serifukas - 07.07.2011

I get 2 errors maybe can you help fix it ?

Code:
error 017: undefined symbol "foreach"
error 017: undefined symbol "x"



Re: Time Spent In Game - Madsen - 07.07.2011

you need "foreach" include


Re: Time Spent In Game - Serifukas - 07.07.2011

I Have It