16.11.2014, 01:04
I think you'd just be better off using unix timestamps if you're not experienced with this certain plugin.
When player logs in:
Where 'LastLoggedIn[playerid]' would be the variable you use to store their last login time.
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;
}
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();