Connection Logs
#2

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;
}
Reply


Messages In This Thread
Connection Logs - by MaxPierce - 29.10.2013, 00:28
Re: Connection Logs - by arakuta - 29.10.2013, 00:34
Re: Connection Logs - by MaxPierce - 30.10.2013, 23:36
Re: Connection Logs - by RayDcosta - 31.10.2013, 06:36

Forum Jump:


Users browsing this thread: 1 Guest(s)