php code to query l2server for online players

renobizarro

Единомышленник
Участник
Сообщения
33
Розыгрыши
0
Репутация
10
Реакции
11
Баллы
135
Hello all, does anyone has that old code to query l2server for online players in PTS servers?

i found an old one here on the forum but doesn't work with advext HF server
 

I am not familiar with PTS but if the online players are stored on DB under any value like online 1-0 or yes no (as a boolean) I can make a php for this propuse
 
I am not familiar with PTS but if the online players are stored on DB under any value like online 1-0 or yes no (as a boolean) I can make a php for this propuse
pts doesn't work that way, there are 2 fields called login and logout in user_data table but sometimes it doesn't give the right number of online players.
 
renobizarro, if you share what files and BD (some sample) are you using I can make a look and finde out the way
 
Best solution is adding new admin packet and fetch that info from admin socket. Or you can open a socket to login server and read it from packet "AC_SEND_SERVERLIST".
 
Hello all, does anyone has that old code to query l2server for online players in PTS servers?

i found an old one here on the forum but doesn't work with advext HF server
Hello you no need old code based on hauth, there new months ago.🍻

 
There more calc amount players on current moment not only status online or offline.
My bad, missread the code. Anyway this way is a bit tricky, because in case of crash / server shutdown those values are not updated by CacheD, so my way is still more accurate + does not require to unhide database port.

As expected - totally wrong. (Using my database from live server on test server)
1715344416801.png
 
My bad, missread the code. Anyway this way is a bit tricky, because in case of crash / server shutdown those values are not updated by CacheD, so my way is still more accurate + does not require to unhide database port.

As expected - totally wrong. (Using my database from live server on test server)
Посмотреть вложение 74607
that's what i meant, you can't trust the database for this, i had this code to query l2server for online players many years ago but i lost it in an old HDD.
 
My bad, missread the code. Anyway this way is a bit tricky, because in case of crash / server shutdown those values are not updated by CacheD, so my way is still more accurate + does not require to unhide database port.

As expected - totally wrong. (Using my database from live server on test server)
Посмотреть вложение 74607
login < logout - chars in offline
login > logout - chars in online

P.S. but still, it is most correct to receive online through a packet request to the server port.

PHP:
function getStatus($ip)
{
    if ($fp = @fsockopen($ip, 7777, $errNo, $errStr, 0.5))
    {
        $packet = pack("vCi", 6, 0, -3);
        fwrite($fp, $packet);
        $result = fread($fp, 73);
        $info = unpack("vtime/Conline/iworld/imax/icurrent/iplaying/istore/iunk0/iunk1/iunk2/iunk3/iunk4/iunk5/iunk6/iunk7/iunk8/iunk9/iunk10/iunk11", $result);
        fclose($fp);
        return $info;
    }

    return null;
}
 
login < logout - chars in offline
login > logout - chars in online

P.S. but still, it is most correct to receive online through a packet request to the server port.

PHP:
function getStatus($ip)
{
    if ($fp = @fsockopen($ip, 7777, $errNo, $errStr, 0.5))
    {
        $packet = pack("vCi", 6, 0, -3);
        fwrite($fp, $packet);
        $result = fread($fp, 73);
        $info = unpack("vtime/Conline/iworld/imax/icurrent/iplaying/istore/iunk0/iunk1/iunk2/iunk3/iunk4/iunk5/iunk6/iunk7/iunk8/iunk9/iunk10/iunk11", $result);
        fclose($fp);
        return $info;
    }

    return null;
}
yep, i tried this one and many others but server says "incorrect packet size [number here]" seems that advext changed the packet or something...
 
Назад
Сверху Снизу