PHP code example of nizarii / arma-rcon-class

1. Go to this page and download the library: Download nizarii/arma-rcon-class library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nizarii / arma-rcon-class example snippets


use \Nizarii\ARC;

$rcon = new ARC(string $ServerIP, string $RConPassword [, int $Port = 2302 [, array $Options = array()]]);

//...
$rcon->command('YourCommand');

use \Nizarii\ARC;

try {
    $rcon = new ARC('127.0.0.1', 'password');
       
    $array = $rcon->getPlayersArray();
    
    $rcon
        ->sayGlobal('example')
        ->kickPlayer(1, 'example')
        ->sayPlayer(0, 'example')
        ->disconnect()
    ;
    
    $rcon->getBans(); // Throws exception, because the connection was closed
} catch (Exception $e) {
    echo "Ups! Something went wrong: {$e->getMessage()}";
}

use \Nizarii\ARC;

$rcon = new ARC('127.0.0.1', 'RConPassword', 2322, [
    'timeoutSec' => 2
]);
    
//...