29.10.2013, 00:34
You can use the default log for this, using printf and gettime when player diconnects.
pawn Код:
new LoginTime[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
LoginTime[playerid] == gettime();
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
new n[24];
GetPlayerName(playerid,n,24);
printf("Player %s had been online for %s",ConvertSeconds(gettime() - LoginTime[playerid]));
}
stock ConvertSeconds(seconds)
{
new hours, mins, secs, string[50];
hours = floatround(number / 3600);
mins = floatround((number / 60) - (hours * 60));
secs = floatround(number - ((hours * 3600) + (mins * 60)));
new days = 0;
if(hours >= 24)
{
days = floatround((hours/24), floatround_floor);
hours = hours % 24;
}
if(days > 0)
format(string, 50, "%dd, %dh %dm and %ds", days, hours, mins, secs);
else if(hours > 0)
format(string, 50, "%dh %dm and %ds", hours, mins, secs);
else
format(string, 50, "%dm and %ds", mins, secs);
return string;
}