Hey there! I've been reading threads upon threads on how to query a gmod server with PHP and I have finally gotten it to work:
However as you can see I'm having issues with the player count. I'm just getting random foreign data that appears not to be related in any way to the actual player counts in the server.
For example in the image above they player count reports to be
The php code that is responsible for getting the player account can be found in this thread: http://forums.srcds.com/viewtopic/4441
I've tried using the php Unpack function with both c* and C* data options and still I get numbers like 22 for the players on the server (1 at the time of testing) and 100 max players (should be 24)
These lines return this:
And as described in the official valve wiki post I'm definately grabbing the correct array pointer for where the data should be:
I really hope you can help me resolve this issue, I thought it would only be simple!
Many thanks, Gergy.
However as you can see I'm having issues with the player count. I'm just getting random foreign data that appears not to be related in any way to the actual player counts in the server.
For example in the image above they player count reports to be
Code:
/dw
The php code that is responsible for getting the player account can be found in this thread: http://forums.srcds.com/viewtopic/4441
I've tried using the php Unpack function with both c* and C* data options and still I get numbers like 22 for the players on the server (1 at the time of testing) and 100 max players (should be 24)
These lines return this:
PHP Code:
$plyr = $info['players'];
$mplyr =$info['maxplayers'];
var_dump($plyr);
var_dump($mplyr);
#############
echo(((count($info))?$plyr.'/':'').((count($info))?$mplyr:''));
Code:
string(1) "" string(2) "dw"
And as described in the official valve wiki post I'm definately grabbing the correct array pointer for where the data should be:
PHP Code:
$info['hostname'] = $sinfo[0];
$info['map'] = $sinfo[1];
$info['game'] = $sinfo[2];
if ($info['game'] == 'garrysmod') { $info['game'] = "Garry's Mod"; }
elseif ($info['game'] == 'cstrike') { $info['game'] = "Counter-Strike: Source"; }
$info['gamemode'] = $sinfo[3];
$info['players'] = $sinfo[5];
$info['maxplayers'] = $sinfo[6];
I really hope you can help me resolve this issue, I thought it would only be simple!
Many thanks, Gergy.