01-19-2008, 12:30 PM
*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.
|
Query a server with PHP
|
|
01-19-2008, 12:30 PM
*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.
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;
}
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/>";
04-30-2008, 01:30 AM
Jezternz Wrote:I have modified Toast's origonal awesome script (thanks alo toast), for people who want to get all details, including players, max. Is there a way to have this return a list of people playing on the server?
05-12-2008, 09:59 PM
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 .
05-20-2008, 02:03 PM
noximana Wrote:if you find out how please post it would love it as part of my script 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
10-27-2008, 03:22 AM
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
11-28-2008, 10:25 AM
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'];
}
?>I focus on a high functionality and easy usability. I will release this class this weekend, so stay tuned.
11-28-2008, 10:35 AM
Sounds cool this will really help me as I can't be bothered making one myself
~ trewq
11-30-2008, 04:26 PM
How do I get playercount in the form "xx/maxplayers" ?
12-04-2008, 02:16 AM
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 *****forum.l4dcoop.com/l4dcoop/l4dc-servers/8-source-dedicated-server-query-class/
11-30-2009, 03:36 AM
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?
11-30-2009, 06:34 AM
(11-30-2009, 03:36 AM)_dp Wrote: The site is down... any chance to get this script? Do you only need the players?
11-30-2009, 07:24 AM
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 ...
11-30-2009, 07:38 AM
ahh .. hmm well haven't had a look on that yet.
12-05-2009, 06:50 AM
anyone knows how to manage that?
|
|
« Next Oldest | Next Newest »
|