> ## Documentation Index
> Fetch the complete documentation index at: https://docs.segra.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# Game Integration

> Automatic event detection and bookmarking for supported games in Segra

Segra includes built-in integrations for popular competitive games. When enabled, these integrations automatically detect and bookmark in-game events like kills, deaths, goals, and assists.

## Supported Games

Segra currently supports automatic event tracking for:

<CardGroup cols={2}>
  <Card title="Counter-Strike 2" icon="crosshairs">
    **Tracked Events**: Kills, Deaths

    Uses CS2's Game State Integration (GSI). Segra ships the required config and serves a local HTTP listener at `http://127.0.0.1:1340/`
  </Card>

  <Card title="League of Legends" icon="shield">
    **Tracked Events**: Kills, Assists, Deaths

    Uses LoL's local Live Client Data API on port 2999
  </Card>

  <Card title="PUBG: Battlegrounds" icon="gun">
    **Tracked Events**: Kills, Deaths

    Reads PUBG's local replay files (`%LocalAppData%/TslGame/Saved/Demos`) after each match
  </Card>

  <Card title="Rocket League" icon="car">
    **Tracked Events**: Goals, Assists

    Uses on-screen OCR to detect goal and assist notifications
  </Card>

  <Card title="Dota 2" icon="hat-wizard">
    **Tracked Events**: Kills, Deaths, Assists

    Uses Dota 2's Game State Integration (GSI) on a local HTTP listener at `http://127.0.0.1:1341/`
  </Card>

  <Card title="Minecraft" icon="cube">
    **Tracked Events**: Deaths

    Tails the Minecraft **Java** `latest.log` (vanilla at `%AppData%/.minecraft/logs/latest.log` and Lunar Client at `%UserProfile%/.lunarclient/logs/client/latest.log`) for death events. Bedrock Edition is not supported.
  </Card>

  <Card title="Rust" icon="hammer">
    **Tracked Events**: Deaths

    Tails `output_log.txt` next to the Rust executable for the `You died` marker
  </Card>

  <Card title="RuneScape: Dragonwilds" icon="dragon">
    **Tracked Events**: Deaths

    Tails `%LocalAppData%/RSDragonwilds/Saved/Logs/RSDragonwilds.log` for the death-state transition
  </Card>

  <Card title="War Thunder" icon="plane">
    **Tracked Events**: Kills, Deaths

    Polls War Thunder's local HUD message endpoint at `http://127.0.0.1:8111/hudmsg` to detect events in real time. The local `.clog` combat log is read only to extract the player's nickname.
  </Card>

  <Card title="Grand Theft Auto" icon="car-burst">
    **Tracked Events**: Deaths

    Uses on-screen OCR to detect the `WASTED` notification and bookmark the death.
  </Card>
</CardGroup>

## Enabling Game Integrations

### From Settings UI

1. Navigate to **Settings** > **Games**
2. Find the **Game Integrations** section
3. Toggle the switch for each game you want to enable
4. Integration activates automatically when you launch the game

<Note>
  Game integrations cannot be enabled or disabled while recording is in progress.
</Note>

### Configuration

<ParamField path="gameIntegrations.counterStrike2.enabled" type="boolean" default="true">
  Enable automatic event detection for Counter-Strike 2
</ParamField>

<ParamField path="gameIntegrations.leagueOfLegends.enabled" type="boolean" default="true">
  Enable automatic event detection for League of Legends
</ParamField>

<ParamField path="gameIntegrations.pubg.enabled" type="boolean" default="true">
  Enable automatic event detection for PUBG: Battlegrounds
</ParamField>

<ParamField path="gameIntegrations.rocketLeague.enabled" type="boolean" default="true">
  Enable automatic event detection for Rocket League
</ParamField>

<ParamField path="gameIntegrations.dota2.enabled" type="boolean" default="true">
  Enable automatic event detection for Dota 2
</ParamField>

<ParamField path="gameIntegrations.minecraft.enabled" type="boolean" default="true">
  Enable automatic event detection for Minecraft
</ParamField>

<ParamField path="gameIntegrations.rust.enabled" type="boolean" default="true">
  Enable automatic event detection for Rust
</ParamField>

<ParamField path="gameIntegrations.runescapeDragonwilds.enabled" type="boolean" default="true">
  Enable automatic event detection for RuneScape: Dragonwilds
</ParamField>

<ParamField path="gameIntegrations.warThunder.enabled" type="boolean" default="true">
  Enable automatic event detection for War Thunder
</ParamField>

<ParamField path="gameIntegrations.gta.enabled" type="boolean" default="true">
  Enable automatic event detection for Grand Theft Auto
</ParamField>

## How It Works

When a game integration is enabled:

<Steps>
  <Step title="Game Detection">
    Segra detects when you launch a supported game
  </Step>

  <Step title="Integration Start">
    The integration service starts and connects to the game's data API
  </Step>

  <Step title="Event Monitoring">
    The integration continuously monitors for in-game events
  </Step>

  <Step title="Automatic Bookmarking">
    When an event occurs (kill, death, goal, etc.), Segra creates a bookmark automatically
  </Step>

  <Step title="Timeline Updates">
    Bookmarks appear in the recording timeline with event labels
  </Step>
</Steps>

## Game-Specific Setup

### Counter-Strike 2

CS2 integration requires a Game State Integration configuration file.

<Accordion title="Setup Instructions">
  Segra automatically creates the required GSI configuration file when:

  1. CS2 is detected for the first time
  2. The integration is enabled in settings

  **Manual setup** (if needed):

  1. Navigate to your CS2 config folder:
     ```
     C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo\cfg\gamestate_integration
     ```

  2. Create a file named `gamestate_integration_segra.cfg` with:
     ```
     "Segra" {
         "uri" "http://localhost:1340/"
         "timeout" "5.0"
         "buffer" "0.1"
         "throttle" "0.2"
         "heartbeat" "2.0"
         "data" {
             "player_id" "1"
             "provider" "1"
             "map" "1"
             "player_match_stats" "1"
         }
     }
     ```

  3. Restart CS2

  4. Segra will now receive kill/death events

  <Note>
    Segra writes this file automatically the first time CS2 is detected. Only follow the manual steps if the auto-created file is missing.
  </Note>
</Accordion>

**Tracked Events**:

* **Kills**: Bookmark created each time you eliminate an opponent
* **Deaths**: Bookmark created when you die

### League of Legends

League integration uses the LoL Live Client Data API (no additional setup required).

<Accordion title="How It Works">
  * LoL exposes game data on `https://127.0.0.1:2999/liveclientdata`
  * Segra polls this endpoint every 250ms during games
  * Events are detected by comparing player stats between polls
  * Works for all game modes (Summoner's Rift, ARAM, etc.)
</Accordion>

**Tracked Events**:

* **Kills**: Bookmark when your kill count increases
* **Assists**: Bookmark when you get an assist
* **Deaths**: Bookmark when you die

### PUBG: Battlegrounds

PUBG integration reads the game's local replay files. No API key or external setup is required.

<Accordion title="How It Works">
  * PUBG writes replay data to `%LocalAppData%/TslGame/Saved/Demos` after each match
  * Segra polls this directory for new replays every 2.5 seconds
  * When a new replay appears, Segra parses its event stream to extract kill and death timestamps
  * Bookmarks are then added to the matching recording
</Accordion>

**Tracked Events**:

* **Kills**: Bookmark when you eliminate a player
* **Deaths**: Bookmark when you're eliminated

<Note>
  Bookmarks are added after a match finishes, once PUBG writes the replay file. They will not appear in real time during the match.
</Note>

### Rocket League

Rocket League integration uses on-screen OCR to detect goal and assist notifications.

<Accordion title="How It Works">
  * Segra periodically captures a small region of the gameplay frame
  * OCR scans the captured frame for text such as "+100", "Goal", or "Assist"
  * Matching keywords create the corresponding bookmarks
  * No external plugins or BakkesMod are required
</Accordion>

**Tracked Events**:

* **Goals**: Bookmark when you score
* **Assists**: Bookmark when you assist a goal

## Bookmark Display

Game integration bookmarks appear with color-coded badges:

<Tabs>
  <Tab title="Success Events">
    **Green badges** for positive events:

    * Kills
    * Assists
    * Goals
  </Tab>

  <Tab title="Death Events">
    **Red badges** for deaths:

    * Deaths (all games)
  </Tab>
</Tabs>

In the timeline and clip editor, you'll see these bookmarks labeled with the event type (e.g., "Kill", "Death", "Goal").

## Game Detection Settings

Segra can automatically detect games or use manual whitelist/blacklist configuration.

### Whitelist

Games in the whitelist will **always** be recorded when launched.

<ParamField path="whitelist" type="array" default="[]">
  Array of game objects to always record:

  ```json theme={null}
  [
    {
      "name": "Counter-Strike 2",
      "paths": ["C:/Program Files/Steam/steamapps/common/Counter-Strike Global Offensive/game/bin/win64/cs2.exe"]
    }
  ]
  ```
</ParamField>

### Blacklist

Games in the blacklist will **never** be recorded.

<ParamField path="blacklist" type="array" default="[]">
  Array of game objects to exclude from recording:

  ```json theme={null}
  [
    {
      "name": "Example Game",
      "paths": ["C:/Games/example.exe"]
    }
  ]
  ```
</ParamField>

### Adding Games to Lists

1. Navigate to **Settings** > **Games** > **Game Detection**
2. Click **Add to Whitelist** or **Add to Blacklist**
3. Browse to the game's executable
4. The game will be added to the appropriate list

## Settings JSON Structure

```json theme={null}
{
  "gameIntegrations": {
    "counterStrike2": {
      "enabled": true
    },
    "leagueOfLegends": {
      "enabled": true
    },
    "pubg": {
      "enabled": true
    },
    "rocketLeague": {
      "enabled": true
    },
    "dota2": {
      "enabled": true
    },
    "rust": {
      "enabled": true
    },
    "minecraft": {
      "enabled": true
    },
    "runescapeDragonwilds": {
      "enabled": true
    },
    "warThunder": {
      "enabled": true
    },
    "gta": {
      "enabled": true
    }
  },
  "whitelist": [],
  "blacklist": []
}
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Events not being detected">
    **Counter-Strike 2**:

    * Verify the GSI config file exists and is correctly formatted
    * Check that Segra is listening on port 1340 (not blocked by firewall)
    * Restart CS2 after adding the config file

    **League of Legends**:

    * Ensure you're in an active game (not lobby/champion select)
    * Check that port 2999 is not blocked
    * Verify LoL client is running (integration needs the client)

    **PUBG**:

    * Verify the replay folder exists at `%LocalAppData%/TslGame/Saved/Demos`
    * PUBG must have replay recording enabled (it is on by default)
    * Bookmarks appear after the match ends, not during live play

    **Rocket League**:

    * Run the game in a supported aspect ratio so the OCR region aligns with the score banner
    * Avoid heavy on-screen overlays that obscure the goal/assist text
    * Make sure you are running the integration on the active Rocket League window
  </Accordion>

  <Accordion title="Too many bookmarks">
    If you're getting too many automatic bookmarks:

    * Disable integrations for games you don't want tracked
    * Use the whitelist/blacklist to control which games are recorded
    * Manually delete unwanted bookmarks after recording
  </Accordion>

  <Accordion title="Integration not starting">
    * Ensure the integration is enabled in Settings > Games
    * Check that Segra service is running (system tray icon present)
    * Verify the game is properly detected (check Segra's game detection)
    * Restart Segra and try launching the game again
  </Accordion>
</AccordionGroup>

## Performance Impact

Game integrations are designed to have minimal performance impact:

* **Counter-Strike 2**: Uses event-driven GSI on a local HTTP listener (no polling)
* **League of Legends**: Polls the local Live Client API every 250ms (negligible CPU usage)
* **PUBG**: Polls the local replay folder every 2.5 seconds and parses replays after a match (no in-game overhead)
* **Rocket League**: Periodic OCR over a small screen region (low overhead, only active while the game is running)

<Tip>
  If you experience any performance issues, you can disable integrations for specific games while keeping others enabled.
</Tip>

## Future Games

Segra is actively adding support for more games. Request integration support by:

* Opening a GitHub issue
* Joining the Segra Discord community
* Contacting support at [segra.tv](https://segra.tv)

Games with public APIs or telemetry systems are easiest to integrate.
