Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
[frl]myke

PHP server query available somewhere? Or some related info?

Recommended Posts

I've been searching through google and this very forum but couldn't find anything that works. Some of the older Armed Assault PHP server query scripts seem to work in general but can't get proper server infos, reporting the server being probably offline (i know it is online).

So is there somewhere a working server query PHP script around?

Share this post


Link to post
Share on other sites

Thanks Sickboy, that's what i call a quick response. :D

Anyway, already stumbled upon the gameq package but couldn't get it to work. Also seems to be quite overloaded for what i need. I have to say that i'm a PHP noob, just starting to dig my way through different scripts while adapting/creating a new website for our clan.

Also stumble upon the 6th sense script which worked in general but reported server being offline.

As you say this is an abandoned project, maybe a pointer where to search for the issue might be of help.

Share this post


Link to post
Share on other sites

NP ;-)

I would really recommend GameQ, the trick is to make it use the gamespy3 protocol, and not the gamespy2 etc.

AFAIK it should pretty much work out of the box then.

The 6thSense thingy is outdated and would need to be extended to support the Gamespy Query Challenge and appropriate response to the challenge, and preferably the multi-packet query packet and parsing of the response.

The thread I've linked contains most information about it but is Ruby orientated I believe, still the essence is the same, just need to find the appropriate PHP functions etc.

This is what I am using in Ruby (uses .NET UDPSocket): https://github.com/sickboy/six-updater-gui/blob/develop/SixUpdaterGui/Applications/six/query/gamespy.rb#L216

Otherwise the gamespy3.php file from GameQ might shed some light on the needed PHP functions and syntax.

I suppose there are other query packages available for PHP, but I can't name any of the top of my head,

I also suppose there are custom packages that several communities develop and deploy themselves - hopefully someone jumps in.

There's also binaries available like gslist; http://aluigi.altervista.org/papers.htm#gslist

this can query the full server list (master or direct), or specific servers, but you'd need to be able to execute it on your server and parse the output..

Edited by Sickboy

Share this post


Link to post
Share on other sites

Aye, will try to dig through the gameq stuff although it will take me weeks to get the arma 2 (GS v3) related parts extracted and working.

The other links you gave me are useless for me since i don't even understand what i am looking at. :D

Not your fault though, appreciate your attempt to help, as usual. ;)

Share this post


Link to post
Share on other sites

once again these is no v3 GS query protocol, it's just updated latest version 2

Share this post


Link to post
Share on other sites
Myke;2046496']Aye' date=' will try to dig through the gameq stuff although it will take me weeks to get the arma 2 (GS v3) related parts extracted and working.

The other links you gave me are useless for me since i don't even understand what i am looking at. :D

Not your fault though, appreciate your attempt to help, as usual. ;)[/quote']rgr, NP and goodluck :)

once again these is no v3 GS query protocol, it's just updated latest version 2
It doesn't matter if there's no official v3 GS query protocol, it is an update to v2 and is not the same as v2.

"Gamespy 3" is also used in GameQ: http://gameq.sourceforge.net/ see Supported Game List.

And also in gslist:

Gslist 0.8.10a
by Luigi Auriemma
e-mail: [email="[email protected]"][email protected][/email]
web:    aluigi.org
- list of supported game queries and their number:
 0 Gamespy \status\        1 Quake 3 engine          2 Medal of Honor
 3 Quake 2 engine          4 Half-Life               5 DirectPlay 8
 6 Doom 3 engine           7 All-seeing-eye          8 Gamespy 2
 9 Source                 10 Tribes 2               [b]11 Gamespy 3[/b]
12 Gamespy \info\         13 Quake 3 getinfo
   or a C string containing the custom packet to send like: -Q "hel\x6c\x6f"

More: http://www.alexthissen.nl/wikis/gaming/gamespy-3.aspx

Google also seems to know about Gamespy3 :-) http://lmgtfy.com/?q=Gamespy3

Nitpicking :)

Edited by Sickboy

Share this post


Link to post
Share on other sites

Here's some Ruby code for GSv3 requests:

require 'socket'

DEST_SERVER = "1.2.3.4" # Server to query
DEST_PORT   = 2302      # Port to query

# Sickboy's handle_chr function. Necessary on Ruby (and possibly other
# languages) but not PHP.
def x(number)
 number = ((number % 256) + 256) if number < 0
 number = number % 256 if number > 255

 number
end

sock = UDPSocket.new

# Bind to a random unused port
loop do
 begin
   sock.bind("127.0.0.1", rand(64510) + 1025)
   break
 rescue Errno::EADDRINUSE
 end
end

# Random ID used in the request - you could also generate one randomly
random_id = "\xAB\xAB\xAB\xFF"

# Send the challenge request packet
sock.send("\xFE\xFD\x09#{random_id}", 0, DEST_SERVER, DEST_PORT)

# Receive and parse the challenge
challenge = sock.recv(64).gsub(/[^0-9\-]/, "").to_i
challenge = sprintf("%c%c%c%c".encode("ASCII-8BIT"), x(challenge >> 24), x(challenge >> 16), x(challenge >> 8), x(challenge >> 0))

# Send the final query using this challenge
sock.send("\xFE\xFD\x00#{random_id}#{challenge}\xFF\xFF\xFF\x01", 0, DEST_SERVER, DEST_PORT)

# Receive the final response. This could also be split up into multiple packets
# which you will need to watch for.
response = sock.recv(1400)

I know this isn't PHP, but it should be fairly obvious what everything does and easy to port over to PHP especially if you use GameQ as another reference.

edit: Fixed the final query. Sorry, it's 1am... forgot to include the challenge in the query!

Edited by eddieck

Share this post


Link to post
Share on other sites

Nice one eddieck! Perhaps useful to note that the implementation doesn't support MultiPacket (and is thus limited to a single packet of 1400 bytes). - The comments do mention it somewhat.

Perhaps suffices for most needs though.

Share this post


Link to post
Share on other sites
Nice one eddieck! Perhaps useful to note that the implementation doesn't support MultiPacket (and is thus limited to a single packet of 1400 bytes). - The comments do mention it somewhat.

Perhaps suffices for most needs though.

yeah, shouldn't be difficult to add that in - though in most cases, it will probably be OK.

Also fixed the final query. Just realized that I forgot to add the challenge to that.. LOL.

Share this post


Link to post
Share on other sites
I know this isn't PHP, but it should be fairly obvious what everything does and easy to port over to PHP especially if you use GameQ as another reference.
I have to say that i'm a PHP noob, just starting to dig my way through different scripts while adapting/creating a new website for our clan.

;)

I know it's sometimes difficult for those who are experienced PHP/Ruby programmers to guess what might be "obvious" to a absolute beginner. That ,said, i do appreciate your effort, eddieck, not that you get that wrong. :D

As said, i will definately look at everything i can get my hands on but i also know it will take me a long time to dig through all scripts to understand the flow and meanings of it all.

Again, i appreciate all help. I really do.

Share this post


Link to post
Share on other sites

Iam currently trying this GameQ for our server but if i access the example.php page he says server not responding.

I have the newest Version, or does GamesQ does not support ArmA2OA 1.6?

Thanks for help!

Share this post


Link to post
Share on other sites

I have the newest Version, or does GamesQ does not support ArmA2OA 1.6?

Thanks for help!

It does support ArmA II, but you'll have to tell GameQ to use the challenge-response variant of the query protocol, which GameQ calls "gamespy3".

Here's how you can do it: first, edit the games.ini file and add a new game identifier for ArmA II. Let's call it "arma2":

[arma2]
name = "ArmA II"
port = 2302
prot = "gamespy3"

Then you can use that in the example.php file like this. In my testing, I had to increase the timeout as well:

...
...
// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
   'My ArmA II server ' => array('arma2', 'aaa.bbb.ccc.ddd')
   //'server 1' => array('quake3', '194.109.69.61'),
   //'server 2' => array('cssource', '194.109.69.51', 27015),
   //'server 3' => array('bf2142', '194.109.69.21'),
  //'server 4' => array('ts3', 'voice.planetteamspeak.com')
);
...
...
// You can optionally specify some settings
$gq->setOption('timeout', 2000);

(I've tested and verified that it works with GameQ 1.12) Hope that helps!

Edited by Killswitch

Share this post


Link to post
Share on other sites
Sign in to follow this  

×