PHP code example of dsg / postscriptum-rcon-php

1. Go to this page and download the library: Download dsg/postscriptum-rcon-php 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/ */

    

dsg / postscriptum-rcon-php example snippets


use DSG\PostScriptumRCON\PostScriptumServer;

...

/** @var PostScriptumServer */
$server = new PostScriptumServer(new ServerConnectionInfo('127.0.0.1', 21114, 'YourRconPassword'));

/** @var Player[] */
$players = $server->listPlayers();

/** @var Player[] */
$players = $server->listDisconnectedPlayers();

/** @var bool */
$success = $server->adminKick('76561197960287930', 'Reason');

// or

/** @var bool */
$success = $server->adminKickById($player->getId(), 'Reason');

/** @var bool */
$success = $server->adminBan('76561197960287930', '1h', 'Reason');

// or

/** @var bool */
$success = $server->adminBanById($player->getId(), '1h', 'Reason');

/** @var string */
$map = $server->currentMap();

/** @var string */
$map = $server->nextMap();

/** @var bool */
$success = $server->adminRestartMatch();

/** @var bool */
$success = $server->adminEndMatch();

/** @var bool */
$success = $server->adminBroadcast('Hello from the other side');

/** @var bool */
$success = $server->adminChangeMap('Sumari AAS v1');

/** @var bool */
$success = $server->adminSetNextMap('Sumari AAS v1');

/** @var bool */
$success = $server->adminSetMaxNumPlayers(80);

/** @var bool */
$success = $server->adminSetServerPassword('secret');

/** @var bool */
$success = $server->adminForceTeamChange('Name or SteamId');

/** @var bool */
$success = $server->adminForceTeamChangeById($player->getId());

/** @var bool */
$success = $server->adminDisbandSquad($team->getId(), $squad->getId());

/** @var bool */
$success = $server->adminRemovePlayerFromSquad('Name');

/** @var bool */
$success = $server->adminRemovePlayerFromSquadById($player->getId());

/** @var bool */
$success = $server->adminWarn('Name or SteamId', 'Warn Reason');

/** @var bool */
$success = $server->adminWarnById($player->getId(), 'Warn Reason');

$server->disconnect();
// Or
unset($server);

composer