Players online time in server H/M/S
#6

Merge this into your script:

pawn Код:
#include <a_samp>
//#include <foreach>

new
    CheckEachTimer,
    PlayerSeconds[MAX_PLAYERS]
;

public OnFilterScriptInit()
{
    CheckEachTimer = SetTimer("CheckEachPlayer", 1000, true);
    return true;
}

public OnFilterScriptExit()
{
    KillTimer(CheckEachTimer);
    return true;
}

public OnPlayerConnect(playerid)
{
    PlayerSeconds[playerid] = 0;
    return true;
}

public OnPlayerDisconnect(playerid, reason)
{
    new hh, mm, ss;
    GetPlayerOnlineTime(playerid, hh, mm, ss);
   
    printf("ID%i was online for %i hours %i minutes %i seconds.",playerid,hh,mm,ss);
    return true;
}

forward CheckEachPlayer();
public CheckEachPlayer()
{
    #if defined foreach
        foreach(Player, i) { if(IsPlayerConnected(i)) PlayerSeconds[i]++; }
    #else
        for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) PlayerSeconds[i]++; }
    #endif
    return true;
}

stock GetPlayerOnlineTime(playerid, &hours, &minutes, &seconds)
{
    hours = (PlayerSeconds[playerid]/(60*60))%24;
    minutes = (PlayerSeconds[playerid]/60)%60;
    seconds = PlayerSeconds[playerid]%60;
}
Reply


Messages In This Thread
Players online time in server H/M/S - by maisto5 - 20.12.2010, 20:28
Re: Players online time in server H/M/S - by Tigerbeast11 - 31.08.2011, 17:18
Re: Players online time in server H/M/S - by Pinguinn - 31.08.2011, 17:19
Re: Players online time in server H/M/S - by MadeMan - 31.08.2011, 17:20
Re: Players online time in server H/M/S - by =WoR=Varth - 31.08.2011, 17:26
Re: Players online time in server H/M/S - by iPLEOMAX - 31.08.2011, 17:38
Re: Players online time in server H/M/S - by Tigerbeast11 - 31.08.2011, 18:13
Re: Players online time in server H/M/S - by iPLEOMAX - 31.08.2011, 18:39
Re: Players online time in server H/M/S - by Tigerbeast11 - 01.09.2011, 15:18

Forum Jump:


Users browsing this thread: 1 Guest(s)