20.08.2008, 19:52
Hi everybody, i just have a php script to send Rcon commands to the server.
The thing is, if i send "say lalala", players see the command, but it's not printed in the console.
The code is this:
So how could i manage to print those messages?
Thanks to all.
Cheers.
---
Web
The thing is, if i send "say lalala", players see the command, but it's not printed in the console.
The code is this:
PHP код:
<?
set_time_limit (30) ;
$ip = $_POST['ip']; if (!$ip) die();
$port = $_POST['port']; if (!$port) die();
$pass = $_POST['pass']; if (!$pass) die();
$passlen = strlen($pass);
$cmd = $_POST['cmd']; if (!$cmd) die();
$cmdlen = strlen($cmd);
$packet = 'SAMP';
$packet .= chr(strtok($ip, '.')).chr(strtok('.')).chr(strtok('.')).chr(strtok('.'));
$packet .= chr($port & 0xFF).chr($port >> 8 & 0xFF);
$packet .= "x";
$packet .= chr($passlen & 0xFF).chr($passlen >> 8 & 0xFF).$pass;
$packet .= chr($cmdlen & 0xFF).chr($cmdlen >> 8 & 0xFF).$cmd;
$fp =fsockopen('udp://' . $ip, $port, $errno, $errstr);
fwrite($fp, $packet);
while(!feof($fp)) {
$str=fread($fp,128);
$str=substr($str,13,strlen($str)-13);
if (!$str) break;
echo $str."<br>";
}
fclose($fp);
?>
Thanks to all.
Cheers.
---
Web