Inactive time
#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


Messages In This Thread
Removed - by MasonSFW - 16.11.2014, 00:19
Re: Inactive time - by ZenBish - 16.11.2014, 00:38
Re: Inactive time - by Abagail - 16.11.2014, 00:47
Re: Inactive time - by Threshold - 16.11.2014, 01:04
Re: Inactive time - by MasonSFW - 16.11.2014, 01:23

Forum Jump:


Users browsing this thread: 1 Guest(s)