hodokami/palrcon

简单的PHP Rcon类。

v1.0.0 2024-03-19 07:55 UTC

This package is auto-updated.

Last update: 2024-09-19 09:06:00 UTC


README

简单的PHP Rcon类。

安装

使用Composer

可以通过以下命令安装此Rcon库

$ composer require hodokami/palrcon

未使用Composer

如果未使用Composer,只需将Rcon.php文件放置在您的项目中,并在PHP脚本中包含它

require_once('Rcon.php');

示例

为了使此脚本正常工作,服务器上必须启用rcon,通过在服务器的server.properties文件中设置enable-rcon=true。还必须设置密码,并在脚本中提供。

$host = 'server.palworld.com'; // Server host name or IP
$port = 25575;                      // Port rcon is listening on
$password = 'server-admin-password'; // rcon.password setting set in server.properties
$timeout = 3;                       // How long to timeout.

use Hodokami\Rcon;

$rcon = new Rcon($host, $port, $password, $timeout);

if ($rcon->connect())
{
  $rcon->sendCommand("say Hello World!");
}