SRCDS Steam group

Help querying a server with PHP
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:

[Image: a6319ac377e91c96a355c971af620f1b.png]

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:
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'];

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.
You could use the class GameQ. Its very well tested and easy to use.
Interactive web based config creator for CS, CSS, TF2 and DODS
Creates server and client configs in an explained dialog.

You`ll also find precompiled debian gameserver kernels for download
(12-31-2013, 03:09 AM)Terrorkarotte Wrote:  You could use the class GameQ. Its very well tested and easy to use.

GameQ is extremely hard to adapt to my existing PHP framework, I practically have to rewrite the frontend for GameQ to make it work Sad

Is there anything specifically wrong that I'm doing? Is it a bug in gmod?
Hello there.

I have worked quite a bit with different libraries with the purpose of communicating with servers, and I found Steam Condenser to be quite easy to use. I have also made a tool for myself which is able to control servers using a web-browser. Code/live demo.

PS: The code is a bit old, and I've found possible security holes in it, not that it's that dangerous to use, but I could have made parts of it a bit smarter than I did Smile

Forum Jump:

Users browsing this thread: 1 Guest(s)