PHP RCON

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Hey guys,
so basically what I want is I want to create a function for RCON that can send commands and text to emulator. I've looked to much github repos but they are for minecraft and I didn't really understand those, so I came here. Example:
Code:
<?php 
RCON('ha', 'Follow user x for events.\nSent from HK.');
and it would perform the ha command. Any clues how can I do that? Any resources or docs? Thanks.
 

Jerry

not rly active lol
Jul 8, 2013
1,956
522
Code:
function RCON($header, $data = '') {
    $musData = $header . chr(1) . $data;

    $sock = @socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
    @socket_connect($sock, env('MUS_HOST', ''), env('MUS_PORT', ''));
    @socket_send($sock, $musData, strlen($musData), MSG_DONTROUTE);
    @socket_close($sock);
}

Modify this line with your RCON IP and port:
Code:
@socket_connect($sock, ip, port);

Usage:
PHP:
RCON('ha', 'Follow user x for events.\nSent from HK.');
 

Users who are viewing this thread

Top