SRCDS Steam group


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] About query.php
#1
I read 'PHP stuff for game servers ' !

That’s marvelous !

But I want use by Counter-Strike 1.6 ,How to change code ?
Reply
#2
Should work exactly the same Smile
~ trewq
Reply
#3
(05-21-2011, 04:19 PM)Goilio Wrote:  Should work exactly the same Smile

No , Can't query 'players'、'playersmax'、'vac'、'password' ... more .

Look :

CS:S [normal]
[Image: css2.gif]
cs:s code:
[Image: css_1.gif]

CS1.6 [not good]
[Image: cs2_1.gif]
cs1.6 code:
[Image: cs_1.gif]

Can u fixed it ?
Reply
#4
Code:
function source_query_old($ip,$port)
{
    $timeout = "1000000";
    $HL2_address = $ip;

    $HL2_port = $port;

    $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);
    socket_set_timeout($HL2_socket,0,$timeout);
    $JunkHead = fread($HL2_socket, 4);
    $CheckStatus = socket_get_status($HL2_socket);
        

    if ($CheckStatus["unread_bytes"] == 0)
        return "socket not made";
    if ($CheckStatus['timed_out'] == 1) {
        return "timeout";
    }

    
    $do = 1;
    while ($do) {
        $str = fread($HL2_socket, 1);
        $HL2_stats .= $str;
        $status = socket_get_status($HL2_socket);
        if ($status["unread_bytes"] == 4) {
            $do = 0;
        }
    }
      fclose($HL2_socket);

    $x = 0;
    while ($x <= strlen($HL2_stats)) {
        $x++;
        $result .= substr($HL2_stats, $x, 1);
    }
  
    $result = str_split($result);
    $char = 15;
    while (ord($result[$char]) != "%00") {
        $info['name'] .= $result[$char];
        $char++;
    }
    $char++;
    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['description'] .= $result[$char];
        $char++;
    }
    $char++;
    while (ord($result[$char]) != "%00") {
        $info['host'] .= $result[$char];
        $char++;
    }
    $char ++;
    $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++;
    return $info;
}
Try this i changed it to the values i saw going thought Wireshark to a 1.6 server, bot count dose not work atm
Need help? Join my Teamspeak 203.98.81.94:9987
Reply
#5
(05-22-2011, 05:38 PM)MIG Wrote:  
Code:
function source_query_old($ip,$port)
{
    $timeout = "1000000";
    $HL2_address = $ip;

    $HL2_port = $port;

    $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);
    socket_set_timeout($HL2_socket,0,$timeout);
    $JunkHead = fread($HL2_socket, 4);
    $CheckStatus = socket_get_status($HL2_socket);
        

    if ($CheckStatus["unread_bytes"] == 0)
        return "socket not made";
    if ($CheckStatus['timed_out'] == 1) {
        return "timeout";
    }

    
    $do = 1;
    while ($do) {
        $str = fread($HL2_socket, 1);
        $HL2_stats .= $str;
        $status = socket_get_status($HL2_socket);
        if ($status["unread_bytes"] == 4) {
            $do = 0;
        }
    }
      fclose($HL2_socket);

    $x = 0;
    while ($x <= strlen($HL2_stats)) {
        $x++;
        $result .= substr($HL2_stats, $x, 1);
    }
  
    $result = str_split($result);
    $char = 15;
    while (ord($result[$char]) != "%00") {
        $info['name'] .= $result[$char];
        $char++;
    }
    $char++;
    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['description'] .= $result[$char];
        $char++;
    }
    $char++;
    while (ord($result[$char]) != "%00") {
        $info['host'] .= $result[$char];
        $char++;
    }
    $char ++;
    $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++;
    return $info;
}
Try this i changed it to the values i saw going thought Wireshark to a 1.6 server, bot count dose not work atm

Nice , but can you make Compatible with both to One file ? (New and Old)

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)