Advertisement
ipsBruno

(PHP) Enviar Comando RCON SA:MP

Jul 29th, 2012
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. /*
  2.  *  Copyright (c) 2012 [iPs]TeaM
  3.  *  Bruno da Silva (email@brunodasilva.com)
  4.  *  Função básica para enviar um comando RCON (administrador) em servidor samp via sockets
  5.  
  6.   Ex :
  7.    enviarComandoRCON("127.0.0.1", 7777, "TUASENHARCON", "exit");
  8.  
  9.  * www.brunodasilva.com
  10.  * www.ips-team.forumeiros.com
  11. */
  12.  
  13.  
  14.  
  15. function enviarComandoRCON($ip, $porta, $rcon, $cmd, $timeout = 5)  {
  16.  
  17.     $packet = 'SAMP';                                                              
  18.  
  19.     $ipArr = explode('.', $ip);  
  20.  
  21.     $packet .= chr($ipArr[0]) . chr($ipArr[1]) . chr($ipArr[2]) . chr($ipArr[3]) . chr($porta & 255) . chr($porta >> 8 & 255);
  22.     $packet .= 'x'.chr(strlen($rcon) & 255).chr(strlen($rcon) >> 8 & 255).$rcon.chr(strlen($cmd) & 255).chr(strlen($cmd) >> 8 & 255) .$cmd;
  23.  
  24.     $socket = @fsockopen('udp://'.$ip, $porta, $erroval, $errostr, $timeout);            
  25.      
  26.     if($socket) {
  27.         fwrite($socket, $packet);                                                  
  28.  
  29.         fclose($socket);  
  30.  
  31.         return true;
  32.     }    
  33.     return false;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement