Web Hosting Talk







View Full Version : PHP: Gamebrowser query


UrlGuy
11-05-2005, 03:15 AM
Hi,

I play this multiplayer fps game, which available games is displayed on a list using a game browser named 'GameSpy'.
I want to have a script that displays the list of games on my webpage.

I already have a script that displays info on a certain game, but this is not for a certain game, but rather to display the name of all games thats on the list.

I know its possible as people has already done this with Visual Basic, and was hoping it could be possible with PHP somehow. I have already played around alittle with fwrite, fread etc. but with no results.

Basicly what I need done is a script that sends some data, (the server recieves the data, and responds), and gets the output.

I'm not really sure its this simple, although I hope so.

I have used a packet logger with GameSpy when I refreshed the list, and every time I refresh my computer sends this data:

\list\cmp\gamename\ccrenegadedemo

The GameSpy server then responds somehow, and sends output back..
The format in which the reply is might look like this:

gamename\ccrenegadedemo\gamever\262\hostname\SOME GAME NAME\hostport\1337\*******\C&C_Under\gametype\C&C\numplayers\28\maxplayers\32\BW\2000000\CSVR\1\DED\1\DG\1\password\0\TC\0\FF\0\SC\550\final\\queryid\17922.1

This is basicly how the scripts that get info on a certain game gets its info, only its removing the slashes, sorting elements correctly etc.

But now I want to get info on all games thats available from the game list, not just one. I also dont know the IP's of the games that are up, only the IP for GameSpy's server that handles the queries. But this should be enough.

I did a test with fsockopen, fwrite, fread, stream_get_contents and alot of other functions on one of GameSpy's IP's: 207.38.11.14 and port: 28910 .

I sendt:
\list\cmp\gamename\ccrenegadedemo, and waited 30ms for reply, (I've tried more, and I also tried double slashes) but I get nothing back, I'm not even sure if I could expect a reply as I'm not 100% sure of the validity of my code. Anyways I didnt get anything back. Except when I tried print the var the fread was in. Then I got 'Resource ID#2', or something similar to this. I did is_array and print_r($myvar); although this didnt output anything at all, so didnt seem like an array.

Well over to the main problem, hm..
Anyone know how this can be done? Or give me some sample code that sends and recieves data using PHP?

Any help on this is greatly apprecciated!
Thanks in advance for all replies I may recieve..!

~UrlGuy

Burhan
11-05-2005, 08:12 AM
You'd have to use a packet sniffer or something to find out exactly what are the commands to be sent.

Parsing the response is very easy, its getting it that's the hard part ;)

UrlGuy
11-05-2005, 02:21 PM
Hi,
thanks for your reply!

I have used a packet sniffer on it, and have found out that it sends this string:

\list\cmp\gamename\ccrenegadedemo

For then to recieve about 10 packets back, each containing server IP and gameinfo.

The packets I recieve appear from the IP the games are on, and looks like this:

\gamename\ccrenegadedemo\gamever\262\hostname\SOME GAME NAME\hostport\1337\C&C_Under\gametype\C&C\numplayers\28\maxplayers\32\BW\2000000\CSVR\1\DED\1\DG\1\password\0\TC\0\FF\0\SC\550

All of this are basicly game rules, port, map and such which I really dont need, all I need is the gamename. Which in the above case would be 'SOME GAME NAME', that should probably not be too much of a problem filtering out, although I'm not all sure yet if I'm doing it right as I'm not recieving any response, and I'm not even sure how to do it to recieve a response. Until now I have played around with a few simple functions in PHP, which one of the things I tried was fread, although without luck :\ Not all sure where to start here.

Anyone else here ever done any similar with retreieving/sending data?
Grateful for all response folks!
thanks again for your reply!

~urlguy

innova
11-07-2005, 11:43 AM
So if I understand correct (might be assuming too much), you are just trying to write a web front-end to gamespy?

I am not sure if they do allow that. For starters, you may want to download Qstat and look at the source code to see what packets they are sending. I *believe* that Qstat can get a list of servers and names. You should be able to analyze the source for the game you are interested in and find the strings they are sending over to get the response.

Burhan
11-07-2005, 12:57 PM
Qstat or Ethereal -- another excellent packet sniffer program.