Page 1 of 1

php sockets

Posted: Wed May 07, 2008 10:03 am
by fricx
Hello,

I am making a script that will connect to udp port of my counter strike 1.6 server and that will be able to change stuff via rcon commands.

The problem is that RCON protocol has some requirements witch you can see in the following code:

Code: Select all

function rcon ($ip, $port, $rcon_pass, $command) {
 
        $fp = fsockopen("udp://$ip",$port, $errno, $errstr, 2);
        socket_set_timeout($fp,2);
 
        if (!$fp)       {
                echo "$errstr ($errno)<br>\n";
        } else {
                $query = "\xFF\xFFrcon\x00". $rcon_pass . "\x00" . $command . "\x00\x00";
                fwrite($fp,$query);
        }
 
        fclose ($fp);
}  


Here is the problem:

Code: Select all

$query = "\xFF\xFFrcon\x00". $rcon_pass . "\x00" . $command . "\x00\x00";
RCON requests this " \xFF\xFFrcon\x00 " codes and for every game is different. I found it for cs:source but not for cs 1.6.

If anyone knows how to connect to gameserver rcon and send commands through it please help =))
Thank you !!!

Re: php sockets

Posted: Wed May 07, 2008 1:02 pm
by fricx
Anyone?