aon4o/cs2-gsi-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aon4o/cs2-gsi-parser

最新稳定版本:v0.4.0

Composer 安装命令:

composer require aon4o/cs2-gsi-parser

包简介

A parser for CS2 Game State Integration data.

README 文档

README

Latest Version on Packagist Tests Total Downloads

This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require aon4o/cs2-gsi-parser

Usage

Parser

The GameState::from() function accepts a JSON string, an associative array or an object.

The result you get back is a fully typed object representing the game state.

use Aon4o\Cs2GsiParser\GameState;

/** @var string|array|object $data */
$game_state = GameState::from($data);

echo $game_state->map->name; // de_dust2

Config generator

You can also generate a config file for CS2 GSI.

use Aon4o\Cs2GsiParser\ConfigWriter;

$config = ConfigWriter::new()
    ->setUrl('http://yourdomain.com/cs2-gsi-endpoint')
    ->setAuthToken('your_auth_key')
    ->setSettings(timeout: 5.0, buffer: 0.1, throttle: 0.1, heartbeat: 30.0)
    ->get();

echo $config;
// "cs2-gsi"
// {
//     "uri" "http://yourdomain.com/cs2-gsi-endpoint"
//     "timeout" "5"
//     "buffer"  "0.1"
//     "throttle" "0.1"
//     "heartbeat" "30"
//     "auth"
//     {
//         "token" "your_auth_key"
//     }
//     "data"
//     {
//         "map_round_wins" "1"
//         "map" "1"
//         "player_id" "1"
//         "player_match_stats" "1"
//         "player_state" "1"
//         "player_weapons" "1"
//         "provider" "1"
//         "round" "1"
//         "allgrenades" "1"
//         "allplayers_id" "1"
//         "allplayers_match_stats" "1"
//         "allplayers_position" "1"
//         "allplayers_state" "1"
//         "allplayers_weapons" "1"
//         "bomb" "1"
//         "phase_countdowns" "1"
//         "player_position" "1"
//     }
// }

Event Extractor

The package also provides a custom event extractor. This is not a feature of CS2 GSI, but a custom definition of events based on changes in the game state. The events are defined in the Aon4o\Cs2GsiParser\Enums\Custom\Event enum.

use Aon4o\Cs2GsiParser\GameState;
use Aon4o\Cs2GsiParser\EventExtractor;

/** @var GameState $prev */
/** @var GameState $curr */

new EventExtractor($prev, $curr)->allEvents();
new EventExtractor($prev, $curr)->mapEvents();
new EventExtractor($prev, $curr)->playerEvents();
new EventExtractor($prev, $curr)->roundEvents();

// Example output

 array:1 [                                                                                                                                                                                      
    0 => Aon4o\Cs2GsiParser\Enums\Custom\Event {#741                                                                                                                                             
      +name: "MAP_PHASE_CHANGED"                                                                                                                                                                 
      +value: "map.phase_changed"                                                                                                                                                                
    }                                                                                                                                                                                            
  ]  

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-10