|
I wrote this script to run on crontab every 2 minutes However, The problem I am having is it will send the same message twice sometimes....How can I get it to not do that?
<?php // SNXRaven's RCon Connection Script. //Chooses a random number $num = Rand (1,7); //Based on the random number, gives a quote switch ($num) { case 1: $command = "say Welcome to ^1[uBp],^7 You can join us at: UnitedBasePlayers.org Have a GREAT game!"; break; case 2: $command = "say We allow all parts of the game, all perks and guns."; break; case 3: $command = "say There is no bad language allowed in any ^1[uBp]^7 Server"; break; case 4: $command = "say Hacking is not allowed in any ^1[uBp]^7 Server, if you are caught..you will be banned!"; break; case 5: $command = "say Feel free to join us in vent: IP vent.unitedbaseplayers.org:4224 Pass: Sabbath"; break; case 6: $command = "say United Base Players is a family based gaming community, please be respect all players."; case 7: $command = "say If you would like to join our Gaming Community do so at: UnitedBasePlayers.org"; }
// Server IP, Port & to connect to. 10.30.09 $server_ip = '127.0.0.1'; $server_port = '28960'; $rconpass = SomePass;
$ip = $_SERVER['REMOTE_ADDR']; $hostaddress = gethostbyaddr($ip); $browser = $_SERVER['HTTP_USER_AGENT'];
$server_ip = "udp://" . $server_ip;
$connect = fsockopen($server_ip, $server_port, $errno, $errstr, 30);
socket_set_timeout ($connect, 1, 000000);
$server_extra_footer = true; // true | false; if problems with receiving playerlist occur, enable $send = "\xff\xff\xff\xff" . 'rcon "' . $rconpass . '" '.$command.(($server_extra_footer)?"\n":'');
fwrite($connect, $send); fputs($connect, $send);
$output = fread ($connect, 1); if (! empty ($output)) { do { $status_pre = socket_get_status ($connect); $output = $output . fread ($connect, 1); $status_post = socket_get_status ($connect); } while ($status_pre[unread_bytes] != $status_post[unread_bytes]); };
fclose($connect);
?>
|