Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. include_once("rcon.class.php");
  4.  
  5. // Extend the rcon class to tweak it for minecraft.
  6. class minecraftRcon extends rcon {
  7. function Auth () {
  8. $PackID = $this->_Write(SERVERDATA_AUTH,$this->Password);$ret = $this->_PacketRead();
  9. return true;
  10. }
  11. function mcSendCommand($Command) {
  12. $this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
  13. }
  14.  
  15. function mcRconCommand($Command) {
  16. $this->mcSendcommand($Command);
  17.  
  18. $ret = $this->Read();
  19.  
  20. return $ret[$this->_Id]['S1'];
  21. }
  22. }
  23.  
  24. // Server connection varialbes
  25. $server = "127.0.0.1";
  26. $rconPort = 888;
  27. $rconPass = "hrudd2s4";
  28.  
  29. // Connect to the server
  30. $r = new minecraftRcon($server, $rconPort, $rconPass);
  31.  
  32. // Authenticate, and if so, execute command(s)
  33. if ( $r->Auth() ) {
  34.  
  35. echo "Authenticatedn";
  36.  
  37. // Send a command
  38. var_dump($r->mcRconCommand('say $server, $rconPort, $rconPass'));
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement