Inactive time
#1

Remove please
Reply
#2

Quote:

if(strcmp(cmd, "/lastlogin", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new string2[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /lastlogin [full name(case sensative)]");
return 1;
}
if(PlayerInfo[playerid][pAdmin] >= 5)
{
format(string, sizeof(string), "%s.ini",tmp);
if(dini_Exists(string))
{
string2 = dini_Get(string, "LastLogin");
format(string, sizeof(string), "%s's last login: %s", tmp,string2);
SendClientMessage(playerid,COLOR_WHITE, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "That player does not exist!");
}
}
}
return 1;
}

Does this help?
P.S I am not a scripter. Just trying to help.
Reply
#3

This can be done using Unix Timestamps. Store the time they last logged off, and when you need to get it, fetch that variable, and then subtract the stored timestamp from the current timestamp.

Then convert the milliseconds to weeks, days, etc, formats.

Example:
pawn Код:
CMD:lastlogged(playerid, params[])
{
    new string[75];
    new tmp = LastLogged[playerid] - gettime();
    tmp = tmp/1000;
    format(string, sizeof(string), "Last online: %d seconds ago", tmp);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Reply
#4

I think you'd just be better off using unix timestamps if you're not experienced with this certain plugin.

pawn Код:
stock ConvertTimeToString(weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0)
{
    while(seconds >= 60) minutes++, seconds -= 60;
    while(minutes >= 60) hours++, minutes -= 60;
    while(hours >= 24) days++, hours -= 24;
    while(days >= 7) weeks++, days -= 7;
    new string[70], fstr[20];
    if(weeks) { format(fstr, sizeof(fstr), (weeks == 1) ? ("%d week") : ("%d weeks"), weeks); if(days || hours || minutes || seconds) strins(fstr, ", ", strlen(fstr)); strins(string, fstr, 0); }
    if(days) { format(fstr, sizeof(fstr), (days == 1) ? ("%d day") : ("%d days"), days); if(hours || minutes || seconds) strins(fstr, ", ", strlen(fstr)); strins(string, fstr, strlen(string)); }
    if(hours) { format(fstr, sizeof(fstr), (hours == 1) ? ("%d hour") : ("%d hours"), hours); if(minutes || seconds) strins(fstr, ", ", strlen(fstr)); strins(string, fstr, strlen(string)); }
    if(minutes) { format(fstr, sizeof(fstr), (minutes == 1) ? ("%d minute") : ("%d minutes"), minutes); if(seconds) strins(fstr, ", ", strlen(fstr)); strins(string, fstr, strlen(string)); }
    if(seconds) { format(fstr, sizeof(fstr), (seconds == 1) ? ("%d second") : ("%d seconds"), seconds), strins(string, fstr, strlen(string)); }
    return string;
}
When player logs in:
pawn Код:
new string[128];
format(string, sizeof(string), "You last logged in: %s ago", ConvertTimeToString(.seconds = (gettime() - LastLoggedIn[playerid])));
SendClientMessage(playerid, -1, string);
LastLoggedIn[playerid] = gettime();
Where 'LastLoggedIn[playerid]' would be the variable you use to store their last login time.
Reply
#5

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)