Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("rcon.class.php");
- // Extend the rcon class to tweak it for minecraft.
- class minecraftRcon extends rcon {
- function Auth () {
- $PackID = $this->_Write(SERVERDATA_AUTH,$this->Password);$ret = $this->_PacketRead();
- return true;
- }
- function mcSendCommand($Command) {
- $this->_Write(SERVERDATA_EXECCOMMAND,$Command,'');
- }
- function mcRconCommand($Command) {
- $this->mcSendcommand($Command);
- $ret = $this->Read();
- return $ret[$this->_Id]['S1'];
- }
- }
- // Server connection varialbes
- $server = "127.0.0.1";
- $rconPort = 888;
- $rconPass = "hrudd2s4";
- // Connect to the server
- $r = new minecraftRcon($server, $rconPort, $rconPass);
- // Authenticate, and if so, execute command(s)
- if ( $r->Auth() ) {
- echo "Authenticatedn";
- // Send a command
- var_dump($r->mcRconCommand('say $server, $rconPort, $rconPass'));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement