Austinb / GameQ

A PHP Gameserver Status Query Library
https://austinb.github.io/GameQ/
GNU Lesser General Public License v3.0
403 stars 136 forks source link

GameQ2 - MOHAA and BF1942 Support #242

Closed own3mall closed 9 years ago

own3mall commented 9 years ago

Hi,

I cannot get GameQ2 to work for any of the game servers I need to scan. I'd like to scan MOHAA and BF1942 servers, but all I get back is the following:

Received the following data! Array ( [bf1942] => Array ( [gq_online] => [gq_address] => 109.169.20.199 [gq_port] => 14567

        [gq_protocol] => gamespy
        [gq_type] => bf1942
        [gq_name] => Battlefield 1942
        [gq_transport] => udp
        [gq_joinlink] => 
    )

)

Thus, it seems to have not queried the server at all, as this server is online. I was hoping to at least get back the following information:

    $data = $data[$gameKey];
    if(is_array($data)){
        // Write server information
        $gameIcon = $gameKey;
        $currentPlayers = $data["numplayers"];
        $maxPlayers = $data["maxplayers"];
        $hostname = $data["hostname"];
        $gameType = $data["gametype"];
        $map = $data["mapname"];
        $version = $data["version"];
        $fullIP = $ip . ":" . $port;

For MOHAA servers, you need to query each server by sending this command:

// 5 second timeout $socket = stream_socket_client("udp://$fullIP", $errno, $errstr, 5); stream_set_blocking($socket, true); stream_set_timeout($socket, 5);

            if (!$socket) {
                // Server is offline
                $errors[] = "$errstr ($errno)";
                $errorCount++;

            }else{
                // Server is online             
                // Get server information

                $cmd = "\xFF\xFF\xFF\xFF\x02getstatus";
                fwrite($socket, $cmd);
                $statusResults = stream_get_contents($socket); 

I'm not sure what you need to send for BF1942 servers, but I was sure hoping to use this library rather than writing my own for BF1942 even though I already wrote one for MOHAA. However, I was hoping to use a class library that worked for both games.

Could you please look into it or add support for those games in version 3 that actually works?

Austinb commented 9 years ago

You are using the client connect ports and not the server query ports. Check the wiki as it has some info on query ports for different game types.

https://github.com/Austinb/GameQ/wiki/Supported-servers-list-v2