Get Total Users Online

  • This is a simple (and probably unwanted) tutorial that will give you all the online players for each core, including the auth

    We might argue about whether being in the select character phase is really in-game, but we will include it anyway



    Why?

    The /u and /w commands only provide data from the channel where the player is

    Since I needed absolute values - as soon as someone logs in - I went searching in the source and came across the GetUserCount() function

    Bitte melden Sie sich an, um dieses Bild zu sehen.

    I had 3 players in separated channels (auth, 1 and 99 respectively)

    I used the commands above and lastly the new one we are going to create



    Explanation?

    The function returns (in type DWORD) the size of m_map_kLogonAccount

    It is a map that stores the login values with class CLoginData

    It is also responsible for storing the values of the players online every 1h in usage.txt

    It is given an insert in the map every login a player makes through the boolean function InsertLogonAccount()

    What we're going to do is requesting the data from GetUserCount() and show it.




    Installing


    DB


    ClientManager.cpp:

    Search for:

    Code
    1. //RELOAD_ADMIN
    2. case HEADER_GD_RELOAD_ADMIN:
    3. ReloadAdmin(peer, (TPacketReloadAdmin*)data);
    4. break;
    5. //END_RELOAD_ADMIN

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Add below:

    Code
    1. case HEADER_GD_REQ_USER_COUNT:
    2. RequestUserCount(dwHandle);
    3. break;

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Search for:

    Code
    1. void CClientManager::ReloadAdmin(CPeer*, TPacketReloadAdmin* p)
    2. { ....
    3. }

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Add below:

    Bitte melden Sie sich an, um diesen Anhang zu sehen.


    ClientManager.h:

    Search for:

    Code
    1. //RELOAD_ADMIN
    2. void ReloadAdmin(CPeer * peer, TPacketReloadAdmin * p);
    3. //END_RELOAD_ADMIN

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Add below:

    Code
    1. void RequestUserCount(DWORD dwHandle);

    Bitte melden Sie sich an, um diesen Anhang zu sehen.


    Common

    tables.h:

    Search for:

    Code
    1. HEADER_DG_RESPOND_CHANNELSTATUS = 181,

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Add below:

    Code
    1. HEADER_GD_REQ_USER_COUNT = 141,
    2. HEADER_DG_RET_USER_COUNT = 182,

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Search for:

    Code
    1. typedef struct SPacketDGChangeEmpirePriv
    2. {
    3. BYTE type;
    4. int value;
    5. BYTE empire;
    6. BYTE bLog;
    7. time_t end_time_sec;
    8. } TPacketDGChangeEmpirePriv;

    Bitte melden Sie sich an, um diesen Anhang zu sehen.

    Add below:

    Code
    1. typedef struct SPacketDGUserCount
    2. {
    3. DWORD user;
    4. } TPacketDGUserCount;

    Bitte melden Sie sich an, um diesen Anhang zu sehen.


    Game

    cmd_gm.cpp:

    Search for:

    Code
    1. //RELOAD_ADMIN
    2. case 'a':
    3. ch->ChatPacket(CHAT_TYPE_INFO, "Reloading Admin infomation.");
    4. db_clientdesc->DBPacket(HEADER_GD_RELOAD_ADMIN, 0, NULL, 0);
    5. sys_log(0, "Reloading admin infomation.");
    6. break;
    7. //END_RELOAD_ADMIN

    Add below:

    Code
    1. case 'y':
    2. ch->ChatPacket(CHAT_TYPE_INFO, "Requesting total users.");
    3. db_clientdesc->DBPacket(HEADER_GD_REQ_USER_COUNT, ch->GetDesc()->GetHandle(), NULL, 0);
    4. break;


    input.cpp:

    Search for:

    Code
    1. case 'a':
    2. db_clientdesc->DBPacket(HEADER_GD_RELOAD_ADMIN, 0, NULL, 0);
    3. sys_log(0, "Reloading admin infomation.");
    4. break;

    Add below:

    Code
    1. case 'y':
    2. db_clientdesc->DBPacket(HEADER_GD_REQ_USER_COUNT, d->GetHandle(), NULL, 0);
    3. sys_log(0, "Reloading user count.");
    4. break;


    input.h:

    Search for:

    Code
    1. //RELOAD_ADMIN
    2. void ReloadAdmin( const char * c_pData );
    3. //END_RELOAD_ADMIN

    Add below:

    Code
    1. void UserCount(LPDESC d, const TPacketDGUserCount* p);


    input_db.cpp:

    Search for:

    Add below:

    Search for:

    Code
    1. // RELOAD_ADMIN
    2. case HEADER_DG_RELOAD_ADMIN:
    3. ReloadAdmin(c_pData );
    4. break;
    5. //END_RELOAD_ADMIN

    Add below:

    Code
    1. case HEADER_DG_RET_USER_COUNT:
    2. UserCount(DESC_MANAGER::instance().FindByHandle(m_dwHandle), (TPacketDGUserCount*)c_pData);
    3. break;


    Usage

    The usage is /reload y

  • Dieses Thema enthält einen weiteren Beitrag, der nur für registrierte Benutzer sichtbar ist, bitte registrieren Sie sich oder melden Sie sich an um diesen lesen zu können.