Austinb / GameQ

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

Cfx/Gta5m does not work if players are on #701

Open justinnobledev opened 1 year ago

justinnobledev commented 1 year ago

While a player is online and using the Gta5m Protocol GameQ will produce the following error. I tried investigating it myself to fix it but was not able to figure out how to solve this error.

Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, string given in C:\xampp\htdocs\test\GameQ-3\src\GameQ\Filters\Normalize.php:115
Stack trace:
#0 C:\xampp\htdocs\test\GameQ-3\src\GameQ\Filters\Normalize.php(115): array_key_exists('nick', '127.0.0.1')
#1 C:\xampp\htdocs\test\GameQ-3\src\GameQ\Filters\Normalize.php(67): GameQ\Filters\Normalize->check('player', '127.0.0.1')
#2 C:\xampp\htdocs\test\GameQ-3\src\GameQ\GameQ.php(650): GameQ\Filters\Normalize->apply(Array, Object(GameQ\Server))
#3 C:\xampp\htdocs\test\GameQ-3\src\GameQ\GameQ.php(370): GameQ\GameQ->doApplyFilters(Array, Object(GameQ\Server))
#4 C:\xampp\htdocs\test\GameQ-3\src\GameQ\Protocols\Cfx.php(119): GameQ\GameQ->process()
#5 C:\xampp\htdocs\test\GameQ-3\src\GameQ\GameQ.php(483): GameQ\Protocols\Cfx->beforeSend(Object(GameQ\Server))
#6 C:\xampp\htdocs\test\GameQ-3\src\GameQ\GameQ.php(360): GameQ\GameQ->doQueries()
#7 C:\xampp\htdocs\test\index.php(14): GameQ\GameQ->process()
#8 {main}
  thrown in C:\xampp\htdocs\test\GameQ-3\src\GameQ\Filters\Normalize.php on line 115

Here is a small test script that demonstrates the issue

$GameQ = new \GameQ\GameQ();
$GameQ->addServer([
    'type' => 'Gta5m',
    'host' => '<ip>:<port>',
]);

$results = $GameQ->process();

print_r($results);

Most of the FiveM query information can be found at these two links that are self-hosted by the server

http://<serverip>:<port>/info.json
http://<serverip>:<port>/players.json

An example of the players.json is

[
  {
    "endpoint": "127.0.0.1",
    "id": 6,
    "identifiers": [
      "steam:110000105127b84",
      "license:13fb7c4176770dab3352282f4b1348d82cf36606",
      "xbl:2533274878728153",
      "live:985156547261461",
      "discord:216392362161733633",
      "fivem:113664",
      "license2:bbf289a0fdc06077cdede027161c8077df302b96"
    ],
    "name": "retro",
    "ping": 53
  }
]
Austinb commented 1 year ago

Need a couple of servers to test against. It is possible something has changed on the server output side causing the queries to fail.