mariusdrg / laravel-fivem-api
此包用于获取 GTA FiveM 服务器信息。
dev-main
2023-11-19 16:48 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: >=7.0
- illuminate/support: >=5.4
This package is auto-updated.
Last update: 2024-09-19 18:34:53 UTC
README
此包允许您以 JSON 数组的形式获取与 GTA FiveM 服务器相关的在线玩家和通用属性信息。
依赖项
PHP >= 8.0
illuminate/support >=5.4
guzzlehttp/guzzle >=7.0
安装
使用 Composer 安装,请执行以下命令
composer require mariusdrg/laravel-fivem-api
Laravel 中的 ServiceProvider
use Mariusdrg\LaravelFivemApi\Services\LFAService;
函数
getServer() - 将返回包含服务器信息的完整 JSON(资源、玩家、服务器属性)
getServerInfo() - 将返回仅包含服务器属性,例如:服务器名称、横幅、网站、描述等。
getLocale() - 将返回服务器区域语言的 ISO 639-1 代码
getResources() - 将返回资源列表
getLicenseKeyToken() - 将返回服务器的许可证密钥令牌
getAllPlayers() - 将返回所有在线玩家及其信息(端点、ID、标识符、名称和延迟)
getOnlinePlayers() - 将仅返回总玩家数
getMaxPlayers() - 将返回服务器属性允许的最大玩家数。所有这些均基于从 http://0.0.0.0:30120/x.json 收到的 API GET 响应。
用法
$client = new LFAService("127.0.0.1"); //replace 127.0.0.1 with your server's IP | Port is set by default as 30120
//or
$client = new LFAService("127.0.0.1", 30121); //second parameter allows you to set a custom Port if necessary
$client->getServer();
示例
namespace App\Http\Controllers;
use Mariusdrg\LaravelFivemApi\Services\LFAService;
class IndexController extends Controller
{
public function index() {
$lfa = new LFAService("127.0.0.1");
return view('index', ['server' => $lfa->getServer()]);
}
}
响应将如下所示
{
"enhancedHostSupport": true,
"icon": "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt",
"requestSteamTicket": "off",
"resources": ["hardcap","rcore_bowling","easy_allowlist","safecracker","boatdealer"],
"server": "FXServer-master SERVER v1.0.0.6683 win32",
"vars": {
"JD_logs": "V3.0.4",
"banner_connecting": "https://i.imgur.com/YYY.png",
"banner_detail": "https://i.imgur.com/XXX.png",
"gamename": "gta5",
"locale": "en-US",
"onesync_enabled": "true",
"sv_enforceGameBuild": "2502",
"sv_enhancedHostSupport": "true",
"sv_lan": "false",
"sv_licenseKeyToken": "3443444x0000000000000000_4627049:0e82a33e8f0c1ab0b5b95d04f48e235099054ecebad8ah8aed4a8951a8a218b8",
"sv_maxClients": "128",
"sv_projectDesc": "^5wcodero",
"sv_projectName": "^5In-House Development | ^5Drugs and Heists | ^4Wars | ^5Active Gangs | ^4Active Staff | ^5Exclusive Scripts | 16+",
"sv_pureLevel": "1",
"sv_scriptHookAllowed": "false",
"tags": "roleplay, rp, qbcore, qb-core, serious",
"txAdmin-version": "6.0.1"
},
"version": 1683688455
}