Posts: 2,270
Threads: 45
Joined: May 2007
Reputation:
11
*cough* bablefish XD
realchamp Wrote:Hazz Wrote:Has someone helped you on these forums? If so, help someone else
Mooga Wrote:OrangeBox is a WHORE.
Posts: 5
Threads: 1
Joined: Apr 2008
Reputation:
0
04-20-2008, 04:47 PM
(This post was last modified: 06-09-2008, 02:35 PM by Jezternz.)
I have modified Toast's origonal awesome script (thanks alo toast), for people who want to get all details, including players, max.
Im not sure if there is a more efficient way, if so, feel free to modify it:
PHP Code:
/* SOURCE ENGINE QUERY FUNCTION, requires the server ip:port */ function source_query($ip){ $cut = explode(":", $ip); $HL2_address = $cut[0]; $HL2_port = $cut[1];
$HL2_command = "\377\377\377\377TSource Engine Query\0"; $HL2_socket = fsockopen("udp://".$HL2_address, $HL2_port, $errno, $errstr,3); fwrite($HL2_socket, $HL2_command); $JunkHead = fread($HL2_socket,4); $CheckStatus = socket_get_status($HL2_socket);
if($CheckStatus["unread_bytes"] == 0)return 0;
$do = 1; while($do){ $str = fread($HL2_socket,1); $HL2_stats.= $str; $status = socket_get_status($HL2_socket); if($status["unread_bytes"] == 0){ $do = 0; } } fclose($HL2_socket);
$x = 0; while ($x <= strlen($HL2_stats)){ $x++; $result.= substr($HL2_stats, $x, 1); } // ord ( string $string ); $result = str_split($result); $info['network'] = ord($result[0]);$char = 1; while(ord($result[$char]) != "%00"){$info['name'] .= $result[$char];$char++;}$char++; while(ord($result[$char]) != "%00"){$info['map'] .= $result[$char];$char++;}$char++; while(ord($result[$char]) != "%00"){$info['dir'] .= $result[$char];$char++;}$char++; while(ord($result[$char]) != "%00"){$info['description'] .= $result[$char];$char++;}$char++; $info['appid'] = ord($result[$char].$result[($char+1)]);$char += 2; $info['players'] = ord($result[$char]);$char++; $info['max'] = ord($result[$char]);$char++; $info['bots'] = ord($result[$char]);$char++; $info['dedicated'] = ord($result[$char]);$char++; $info['os'] = chr(ord($result[$char]));$char++; $info['password'] = ord($result[$char]);$char++; $info['secure'] = ord($result[$char]);$char++; while(ord($result[$char]) != "%00"){$info['version'] .= $result[$char];$char++;} return $info; }
Note you will need this if you run php4 (not php5)
PHP Code:
if( !function_exists('str_split') ){ function str_split($string, $split_length=1){ $array = array(); $len = strlen($string); do{ $part = ''; for ($j = 0; $j < $split_length; $j++){ $part .= $string{$i}; $i++; } $array[] = $part; } while ($i < $len); return $array; } }
And use it like so.
PHP Code:
$q = source_query('202.89.33.158:27016');
echo "network: ".$q['network']."<br/>"; echo "name: ".$q['name']."<br/>"; echo "map: ".$q['map']."<br/>"; echo "dir: ".$q['dir']."<br/>"; echo "desc: ".$q['description']."<br/>"; echo "id: ".$q['appid']."<br/>"; echo "players: ".$q['players']."<br/>"; echo "max: ".$q['max']."<br/>"; echo "bots: ".$q['bots']."<br/>"; echo "dedicated: ".$q['dedicated']."<br/>"; echo "os: ".$q['os']."<br/>"; echo "password: ".$q['password']."<br/>"; echo "secure: ".$q['secure']."<br/>"; echo "version: ".$q['version']."<br/>";
Posts: 3
Threads: 1
Joined: Apr 2008
Reputation:
0
Jezternz Wrote:I have modified Toast's origonal awesome script (thanks alo toast), for people who want to get all details, including players, max.
Im not sure if there is a more efficient way, if so, feel free to modify it:
Code:
/* SOURCE ENGINE QUERY FUNCTION, requires the server ip:port */
function source_query($ip){
$cut = explode(":", $ip);
$HL2_address = $cut[0];
$HL2_port = $cut[1];
$HL2_command = "\377\377\377\377TSource Engine Query\0";
$HL2_socket = fsockopen("udp://".$HL2_address, $HL2_port, $errno, $errstr,3);
fwrite($HL2_socket, $HL2_command);
$JunkHead = fread($HL2_socket,4);
$CheckStatus = socket_get_status($HL2_socket);
if($CheckStatus["unread_bytes"] == 0)return 0;
$do = 1;
while($do){
$str = fread($HL2_socket,1);
$HL2_stats.= $str;
$status = socket_get_status($HL2_socket);
if($status["unread_bytes"] == 0){
$do = 0;
}
}
fclose($HL2_socket);
$x = 0;
while ($x <= strlen($HL2_stats)){
$x++;
$result.= substr($HL2_stats, $x, 1);
}
// ord ( string $string );
$result = str_split($result);
$info['network'] = ord($result[0]);$char = 1;
while(ord($result[$char]) != "%00"){$info['name'] .= $result[$char];$char++;}$char++;
while(ord($result[$char]) != "%00"){$info['map'] .= $result[$char];$char++;}$char++;
while(ord($result[$char]) != "%00"){$info['dir'] .= $result[$char];$char++;}$char++;
while(ord($result[$char]) != "%00"){$info['description'] .= $result[$char];$char++;}$char++;
$info['appid'] = ord($result[$char].$result[($char+1)]);$char += 2;
$info['players'] = ord($result[$char]);$char++;
$info['max'] = ord($result[$char]);$char++;
$info['bots'] = ord($result[$char]);$char++;
$info['dedicated'] = ord($result[$char]);$char++;
$info['os'] = chr(ord($result[$char]));$char++;
$info['password'] = ord($result[$char]);$char++;
$info['secure'] = ord($result[$char]);$char++;
while(ord($result[$char]) != "%00"){$info['version'] .= $result[$char];$char++;}
return $info;
}
Note you will need this if you run php4 (not php5)
Code:
if( !function_exists('str_split') ){
function str_split($string, $split_length=1){
$array = array();
$len = strlen($string);
do{
$part = '';
for ($j = 0; $j < $split_length; $j++){
$part .= $string{$i};
$i++;
}
$array[] = $part;
}
while ($i < $len);
return $array;
}
}
And use it like so.
Code:
$q = source_query('202.89.33.158:27016');
echo "network: ".$q['network']."<br/>";
echo "name: ".$q['name']."<br/>";
echo "map: ".$q['map']."<br/>";
echo "dir: ".$q['dir']."<br/>";
echo "desc: ".$q['description']."<br/>";
echo "id: ".$q['appid']."<br/>";
echo "players: ".$q['players']."<br/>";
echo "max: ".$q['max']."<br/>";
echo "bots: ".$q['bots']."<br/>";
echo "dedicated: ".$q['dedicated']."<br/>";
echo "os: ".$q['os']."<br/>";
echo "password: ".$q['password']."<br/>";
echo "secure: ".$q['secure']."<br/>";
echo "version: ".$q['version']."<br/>";
Is there a way to have this return a list of people playing on the server?
Posts: 1
Threads: 0
Joined: May 2008
Reputation:
0
if you find out how please post it would love it as part of my script I will look into it myself, but its 6am and i need sleep. if someone figures out how to Print out current Client Connected I would be happy .
Posts: 5
Threads: 1
Joined: Apr 2008
Reputation:
0
noximana Wrote:if you find out how please post it would love it as part of my script I will look into it myself, but its 6am and i need sleep. if someone figures out how to Print out current Client Connected I would be happy .
I will defnitly be doing this. Just a matter of when. sometime over next few weeks (I have finals soon), when its done I will post here.
Its a bit more complex then the first script
Posts: 13
Threads: 2
Joined: Oct 2008
Reputation:
0
I need help on how to use and implement this? is it more then one scrip on the website. and where do I put the CSS ip. I know nothing about PHP so all help would be great, i need a step be step process on this.
Thanks
Posts: 2
Threads: 0
Joined: Nov 2008
Reputation:
0
I am currently working an a PHP Class, which will be used to query a Source server.
It may be used like this:
PHP Code:
<?php $server = new SourceServer("xxx.xxx.xxx.xxx", xxxx); // IP and port print $server->getInfo('name'); print $server->getInfo('players'); while ( $player = $server->getNextPlayer() ) { print $player['name']; } ?>
This is just a short example. The class will query all data according to the official Valve protocol specification. It will support general server info, player info and ping times.
I focus on a high functionality and easy usability.
I will release this class this weekend, so stay tuned.
Posts: 1,321
Threads: 85
Joined: Feb 2008
Reputation:
11
Sounds cool this will really help me as I can't be bothered making one myself
~ trewq
Posts: 12
Threads: 3
Joined: Nov 2008
Reputation:
0
How do I get playercount in the form "xx/maxplayers" ?
Posts: 2
Threads: 0
Joined: Nov 2008
Reputation:
0
I just finished my class.
A few features:
You can retrieve information like the game, map, players, ping, detailed information on every player (name, points, time of connection) and much more.
For more information and download, visit http://forum.l4dcoop.com/l4dcoop/l4dc-servers/8-source-dedicated-server-query-class/
Posts: 26
Threads: 5
Joined: Sep 2009
Reputation:
1
The site is down... any chance to get this script?
i tried the rcon class, but i have no chance to get anything out of it.
if i use the class as it was posted on the last site, i get Connection Refused error by the fsockopen function and if i place "udp://" before the ip, i get nothing at all.
i don't see any other way to get the playerlist...
any ideas?
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
(11-30-2009, 03:36 AM)_dp Wrote: The site is down... any chance to get this script?
i tried the rcon class, but i have no chance to get anything out of it.
if i use the class as it was posted on the last site, i get Connection Refused error by the fsockopen function and if i place "udp://" before the ip, i get nothing at all.
i don't see any other way to get the playerlist...
any ideas?
Do you only need the players?
Posts: 26
Threads: 5
Joined: Sep 2009
Reputation:
1
i need playerlist with score (if possible), the team on which each player is and the current map.
i know how to get the current map and the amount of players, but i need it like this:
map: cp_dustbowl
player1: 30
player2: 42
player3: 0
player4: 1
player5: 1
...
Posts: 7,778
Threads: 176
Joined: May 2008
Reputation:
83
ahh .. hmm well haven't had a look on that yet.
Posts: 26
Threads: 5
Joined: Sep 2009
Reputation:
1
anyone knows how to manage that?
|