nizarii/arma-rcon-class
Composer 安装命令:
composer require nizarii/arma-rcon-class
包简介
ARC is a lightweight PHP class, that allows you connecting and sending commands easily to your BattlEye server, including Arma 3, Arma 2 and Arma 2: OA game servers.
README 文档
README
ARC is a lightweight PHP class, that allows you connecting and sending commands easily to your BattlEye server, including Arma 3, Arma 2 and Arma 2: OA game servers.
Requirements
ARC 2.2 only requires PHP 5.4 or higher!
Installation
Via Composer (recommended)
If you haven't already, download Composer.
$ curl -s http://getcomposer.org/installer | php
Now require and install ARC.
$ composer require nizarii/arma-rcon-class $ composer install
Without Composer
Choose a release and include ARC in your project: require_once 'arc.php';.
Examples
Getting started
After installing ARC, you can easily use ARC as shown below. It will automatically establish a new connection and authenticate.
use \Nizarii\ARC; $rcon = new ARC(string $ServerIP, string $RConPassword [, int $Port = 2302 [, array $Options = array()]]);
You are able to send commands with the command() function.
//... $rcon->command('YourCommand');
ARC will throw an Exception if anything goes wrong. You might want to wrap your code in a try catch block.
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()}"; }
Please consider that ARC only checks whether the command has been successfully sent via the socket to the server. It does not check if the command has been executed by the server.
Options
Options can be passed to ARC as an array via the fourth parameter of the constructor. The following options are currently available:
int timeoutSec = 1: Sets a timeout value on the connection.bool autosavebans = false: Automatically saves bans.txt after a player is banned or unbanned.bool debug = false: turns on debug mode, only works on "socketLoop()" and "socketLoopClose()"
Suggestions for new options are always welcome! 👍
Basic usage:
use \Nizarii\ARC; $rcon = new ARC('127.0.0.1', 'RConPassword', 2322, [ 'timeoutSec' => 2 ]); //...
Functions
ARC features many functions to send BattlEye commands easier. After creating a new connections as explained above, you are able to use any of these functions:
string command(string $command): Sends any command to the BattlEye server.string getPlayers(): Returns a list with all players, which are currently on the server.array getPlayersArray(): Same as "getPlayers()", but formats the list to an array.string getMissions(): Gets a list of the available missions on the server.string getBans(): Gets a list of all BE server bans.array getBansArray(): Gets an array of all bans.object kickPlayer(int $player [, string $reason = 'Admin Kick']): Kicks a player who is currently on the server.object sayGlobal(string $message): Sends a global message to all players.object sayPlayer(int $player, string $message): Sends a message to a specific player.object loadScripts(): Loads the "scripts.txt" file without the need to restart the server.object maxPing(int $ping): Changes the MaxPing value. If a player has a higher ping, he will be kicked from the server.object changePassword(string $password): Changes RCon password.object loadBans(): (Re)loads the BE ban list from "bans.txt".object banPlayer(string $player [, string $reason = 'Banned' [, int $time = 0]]): Ban a player's BE GUID from the server (If the time is 0, the ban will be permanent).object addBan(string $player [, string $reason = 'Banned' [, int $time = 0]]): Same as "banPlayer()", but allows to ban a player that is not currently on the server.object removeBan(int $banid): Removes a ban.object writeBans(): Removes expired bans from the bans file.object getBEServerVersion(): Gets the current version of the BE server.disconnect(): Closes the current connection.object reconnect(): Closes the current connection & creates a new one.resource getSocket(): Get the socket, which is used by ARC to send commands to the server.boolean socketLoop(int $loop = -1): Get constant socket stream. $loop is the number of loops to be run until exiting the method. Note that the sequence will be reset. Set to infinite looping by default.boolean socketLoopClose(int $loop = -1): Similar as "socketLoop()", but disconnects after looping. Set to infinite looping by default.array readPackageRaw(string $msg): Make BettlEye format package readable for your program. Use $msg with unreadable header and unmodified string. Array will start as [0] => "FF" when having correct header. Array value [1] has important information what kind of care it needs for your connection. For more information, click here.
See here for more information about BattlEye commands
Contributors
Thanks to all contributors for submitting issues and contributing code, including:
- @nerdalertdk
- @steffalon
New contributors are always welcome ❤️
License
ARC is licensed under the MIT License. View LICENSE file for more information.
nizarii/arma-rcon-class 适用场景与选型建议
nizarii/arma-rcon-class 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.03k 次下载、GitHub Stars 达 43, 最近一次更新时间为 2015 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「client」 「lightweight」 「class」 「rcon」 「arma3」 「arma2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nizarii/arma-rcon-class 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nizarii/arma-rcon-class 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nizarii/arma-rcon-class 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Collection of methods that I or you usually use.
A very simple yet useful helper class to handle PHP file uploads.
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Splot Framework. Lightweight, fully featured framework for rapid web development.
Yii2 js base class
统计信息
- 总下载量: 4.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-28