Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CS2 Game State Integration Spec

Note

This spec is a draft. It will change as more CS2 payloads are captured and the open items get settled.

Valve has never published a spec for CS2. The only official document is Valve’s CS:GO page, and CS2 kept the same mechanism and config format. This spec takes that page and checks it against payloads CS2 actually sent.

Each fact is tagged with its evidence:

  • [V] Valve’s page. It’s written for CS:GO, and the live page blocks automated clients, so it was read through the Internet Archive.
  • [C] Payloads captured from CS2, in pygsi’s tests/fixtures.json. They come from a practice match against bots on de_dust2 (provider.version 14141), plus one payload from a community server. The previously and added blocks were stripped before they were saved. [C] also covers what pygsi’s git history records about earlier runs against CS2, cited by commit.
  • [B] u/Bkid’s Game State Integration: A Very Large and In-Depth Explanation (2019), a detailed write-up built from payloads captured in CS:GO. Much of CS:GO’s GSI carried over unchanged, so it’s the guide where CS2 data is missing, but each [B] fact still needs a CS2 payload to confirm it.

When sources disagree, the captured payloads and pygsi’s tested behavior win, then Valve, then [B]. Anything not confirmed in CS2 is marked open and listed under Open Items. Where [B] covers an open item, it’s the expected answer. Anything that only other GSI implementations suggest is listed as a lead to check, not as a fact.

Structure

These are the keys a payload can have. Fields marked [C] have been seen in a CS2 payload. The others come from Valve’s descriptions of the components.

payload
+-- auth                           [V] only with an "auth" block in the config
+-- provider                       [C]
|   +-- name, appid, version, steamid, timestamp
+-- map                            [C]
|   +-- mode, name, phase, round, num_matches_to_win_series
|   +-- team_ct, team_t
|   |   +-- score, name, flag, consecutive_round_losses,
|   |       timeouts_remaining, matches_won_this_series
|   +-- round_wins                 [C] with map_round_wins
|       +-- "1", "2", ...
+-- round                          [C]
|   +-- phase, bomb, win_team
+-- player                         [C]
|   +-- steamid, name, observer_slot, team, activity
|   +-- clan                       [V] open
|   +-- state                      [C] with player_state
|   |   +-- health, armor, helmet, flashed, smoked, burning, money,
|   |       round_kills, round_killhs, equip_value
|   +-- weapons                    [C] with player_weapons
|   |   +-- weapon_0, weapon_1, ...
|   |       +-- name, paintkit, type, state,
|   |           ammo_clip, ammo_clip_max, ammo_reserve
|   +-- match_stats                [C] with player_match_stats
|       +-- kills, assists, deaths, mvps, score
+-- allplayers, bomb, phase_countdowns, grenades
|                                  [V] observer-only, open
+-- previously                     [V] old values of what changed
+-- added                          [V] keys that weren't there before

1. The Config File

CS2 reads every file named gamestate_integration_<name>.cfg in game/csgo/cfg/ when it starts, and sends updates to each one [V][C]. A file saved with a UTF-8 BOM doesn’t load, and the console lists the files that did [V].

Valve’s sample for a player’s own client [V]:

"Console Sample v.1"
{
 "uri" "http://127.0.0.1:3000"
 "timeout" "5.0"
 "buffer"  "0.1"
 "throttle" "0.5"
 "heartbeat" "60.0"
 "auth"
 {
   "token" "CCWJu64ZV3JHDT8hZc"
 }
 "output"
 {
   "precision_time" "3"
   "precision_position" "1"
   "precision_vector" "3"
 }
 "data"
 {
   "provider"            "1"
   "map"                 "1"
   "round"               "1"
   "player_id"           "1"
   "player_state"        "1"
   "player_weapons"      "1"
   "player_match_stats"  "1"
 }
}

Endpoint Settings [V]

KeyDefaultMeaning
urinoneWhere the game sends its POST requests. For an https URI, the Steam client uses TLS and validates the server’s certificate.
timeout1.1 sHow long the game waits for a response. After a timeout, the request counts as failed, and the next one sends the full state with no deltas.
buffer0.1 sAfter a change, the game collects more changes for this long and reports them together. 0.0 turns buffering off.
throttle1.0 sThe game sends nothing for at least this long after a 2xx response.
heartbeatnot givenThe game sends a request this long after the last 2xx response, even if nothing changed.

The game expects a 2xx response, and it doesn’t send a new request while one is still in flight [V]. Valve doesn’t say what a non-2xx response does, beyond counting the request as failed. If an endpoint never sees a previously or added block, the game is probably treating every request as failed [V].

auth [V]

Optional. Each field in the config’s auth block is sent to the endpoint as a JSON string field, so the endpoint can check where the payload came from. Valve recommends https when you use it. Open.

output [V]

Optional. Sets how many digits after the decimal point the game sends: precision_time for durations such as countdowns and lifetimes, precision_position for positions, and precision_vector for vectors such as velocity and forward direction.

data Components

Each component turns on one part of the payload. Valve’s list [V]:

ComponentWhat it addsWho gets it
providerThe client sending the payloadEveryone
mapMode, map, phase, and scoreEveryone
map_round_winsHow each round so far was wonEveryone
roundRound phase, bomb state, round winnerEveryone
player_idName, SteamID, clan tag, observer slot, teamEveryone
player_stateHealth, armor, flashes, kills this round, and so onEveryone
player_weaponsEquipped weapons, ammo, and weapon stateEveryone
player_match_statsKills, assists, deaths, MVPs, scoreEveryone
player_positionPosition and forward direction of the spectated playerObservers only
allplayers_id, allplayers_state, allplayers_match_stats, allplayers_weapons, allplayers_positionThe player_* data for every playerObservers only
bombWhere the bomb is, who’s carrying it, whether it’s droppedObservers only
phase_countdownsTime left in the current phase, and which phaseObservers only
allgrenadesEvery grenade’s owner, position, velocity, type, lifetime, and effect timeObservers only

An observer is a client that’s spectating a match, watching GOTV, or watching a demo. A player in a match gets nothing from the observer-only components, which means no bomb timer and no data on other players [V].

2. The Payload

Each request is an HTTP POST with a JSON body. It holds the full current state of every component in the config, plus two blocks computed against the last payload that got a 2xx response [V]:

  • previously holds the old values of the data that changed.
  • added holds the root fields that are in the new state but weren’t in the old one.

A component with no data at the moment is left out [C]. In the main menu, for example, a payload has provider and a player with only steamid, name, and activity. During warmup, there’s a map but no round [C].

provider [C]

FieldTypeSeen in CS2
namestring"Counter-Strike: Global Offensive", unchanged in CS2
appidint730
versionint14141
steamidstringThe SteamID64 of the client that sent the payload. It stays the same while the player spectates someone else.
timestampintUnix time in seconds

map [C]

FieldTypeSeen in CS2
modestringcompetitive. Other modes are open.
namestringde_dust2
phasestringwarmup, live, gameover. Valve also lists intermission, for halftime [V], which is open.
roundintThe number of rounds already finished. It’s 0 in the first round and goes up as soon as a round’s phase becomes over. At gameover it equals the total rounds played.
num_matches_to_win_seriesint0
team_ct, team_tobjectSee below
round_winsobjectOnly with map_round_wins. The keys are round numbers starting at "1".

Each team object has these fields:

FieldTypeSeen in CS2
scoreintRounds won
namestring"CounterTerrorists", "Terrorists"
flagstringA country code, such as "us" or "de"
consecutive_round_lossesint
timeouts_remainingint1
matches_won_this_seriesint0

name and flag are strings, and the other team fields are ints. The community-server payload has the same shape and types as the practice-match ones [C].

The round_wins values seen so far are ct_win_elimination, t_win_elimination, and t_win_bomb. Other win conditions, such as a defuse or the timer running out, are open.

round [C]

FieldTypeSeen in CS2
phasestringfreezetime, live, over
bombstringplanted, exploded. Left out until the bomb is planted. Valve also lists defused [V], which is open.
win_teamstringCT or T. Present once the phase is over.

player [C]

After the player dies, CS2 fills player with the data of the teammate they’re spectating, while provider.steamid stays theirs. The only way to tell is to compare player.steamid with provider.steamid [C]. Bots have short IDs such as "503", not SteamID64s [C].

FieldTypeSeen in CS2
steamidstring
namestring
observer_slotintPresent for the local player as well as a spectated teammate, such as 5 and 9.
teamstringT. CT hasn’t been captured in this field yet, though it appears in round.win_team.
activitystringplaying, menu. [B] adds textinput, for the console, which is open.
clanstringThe clan tag [V]. Open.

player.state, with player_state:

FieldTypeSeen in CS2
healthint0 to 100
armorint0 seen
helmetboolfalse seen
flashedint0 seen. How flashed the player is.
smokedint0 seen. How far inside a smoke the player is.
burningint0 seen. How much the player is burning.
moneyint
round_killsintKills this round
round_killhsintHeadshot kills this round
equip_valueintThe value of everything the player has

Ranges for flashed, smoked, and burning aren’t in Valve’s page and haven’t been measured yet.

player.weapons, with player_weapons, is an object with the keys weapon_0, weapon_1, and so on. Each weapon has:

FieldTypeSeen in CS2
namestringweapon_ak47, weapon_deagle, weapon_glock, weapon_knife_t, weapon_c4, weapon_smokegrenade
paintkitstringThe skin’s internal name, such as cu_desert_eagle_corroden, or default
typestringRifle, Pistol, Knife, Grenade, C4
statestringactive, holstered, reloading
ammo_clipintRounds in the magazine. Left out for knives, grenades, and the C4.
ammo_clip_maxintMagazine size, left out in the same cases.
ammo_reserveintReserve ammo. A grenade has this field and nothing else about ammo.

player.match_stats, with player_match_stats: kills, assists, deaths, mvps, score, all ints.

Observer-Only Blocks

Valve names these blocks and what they contain, but none of them has been captured from CS2, so their exact fields aren’t known yet [V]:

  • allplayers: the player_* data for every player.
  • bomb: the bomb’s position, its carrier, and whether it’s dropped.
  • phase_countdowns: the time left in the current phase and which phase it is.
  • grenades, from allgrenades: each grenade’s owner, position, velocity, type, lifetime, and effect time.

3. Behavior

  • Snapshots, not events. Every payload is the full state, so events have to be worked out by comparing payloads, or from previously and added [V].
  • One request at a time. The game waits for each response before it sends the next request, so a slow endpoint delays every update after it [V].
  • Spectating after death. Once the player dies, player switches to the teammate they’re watching, and provider doesn’t change [C].
  • Round counter. map.round goes up as soon as a round is over, not when the next round starts [C].
  • No kill feed. No component says who killed whom, or with what [V].

4. Open Items

These need a captured payload, or a test against a real client, before the spec can state them. Where other GSI implementations expect something, it’s listed as a lead.

Protocol

  1. Non-2xx responses. Valve says a failed request makes the next one send the full state, but not whether the game slows down or stops after repeated failures. pygsi always answers 200 to be safe.
  2. heartbeat default. Valve gives none. [B]: 30 s.
  3. The shape of previously and added. Valve describes them in words only, and the captured payloads had them stripped. [B]: previously mirrors the payload’s nesting with only the changed fields, such as {"player": {"state": {"flashed": 24}}}, and added marks each new key with true, such as {"player": {"clan": true}}.
  4. auth in the payload. [B]: the config’s auth fields arrive as strings, and the key doesn’t have to be token.
  5. A provider-only config. [B]: a change to provider.timestamp alone doesn’t trigger a request, so such a config only gets heartbeats.

Values Not Yet Seen

  1. map.mode. Only competitive is captured. [B]: casual, deathmatch, gungameprogressive, scrimcomp2v2. Leads for CS2: wingman in place of scrimcomp2v2, custom, workshop, new_user_training, retakes, survival.
  2. map.phase. [V][B]: intermission during halftime.
  3. round.bomb. [V][B]: defused.
  4. round.phase. Only freezetime, live, and over are captured. [B]: freezetime also covers team timeouts.
  5. round_wins. Only ct_win_elimination, t_win_elimination, and t_win_bomb are captured. [B]: ct_win_defuse, ct_win_time. Leads: ct_win_rescue, t_win_time.
  6. player.team. Only T is captured in this field. [B]: T or CT.
  7. player.activity. [B]: textinput while the console is open. It describes the client itself, even while spectating.
  8. Weapon type. [B]: SniperRifle, Submachine Gun. Leads: Shotgun, a machine gun type, and types for the Zeus, fists, melee weapons, and tablets.
  9. Ranges. [B]: flashed, smoked, and burning run from 0 to 255, and burning is 255 while on fire and then counts down after leaving it. money runs up to 16000 in competitive.
  10. player.observer_slot. [B] numbers the slots 1 to 9, then 0, and says the field only appears while spectating. The captured payloads have it for the local player too, so the second part doesn’t hold for CS2.

Fields Not Yet Seen

  1. player.clan [V]. [B]: left out when the player has no clan tag.
  2. player.state. pygsi’s first version modeled round_totaldmg and defusekit, and removed both because CS2 never sent them in real runs (commit d72d174) [C]. Those runs may not have included a CT with a kit, so defusekit could still appear then. Lead: health_c4_preview.
  3. player.xpoverload. A lead only.
  4. map. [B]: current_spectators and souvenirs_total.
  5. tournamentdraft. A lead only: a block with pick and ban details for tournaments.
  6. Observer-only blocks. [B] has examples of these:
    • bomb has state (carried, dropped, planting, planted, defusing, defused, and, per Valve’s round values, exploded), position, player (the SteamID64 of whoever carries, plants, or defuses it), and countdown. countdown is the time to finish planting while planting, the time to explode while planted, and the time to finish defusing while defusing.
    • phase_countdowns has phase (the round phases plus bomb, defuse, and warmup) and phase_ends_in.
    • player.spectarget, player.position, and player.forward come with player_position.
    • Positions and vectors are "x, y, z" strings, and countdowns are strings such as "39.8".
    • Leads: allplayers keyed by SteamID64, each value shaped like player, and grenades keyed by ID, with owner, position, velocity, lifetime, type, effecttime, and flames.

Behavior

  1. Death and spectating. Is the first payload after a death always the player’s own data with health 0, or can it already show the teammate? pygsi’s death event depends on the first case.
  2. The gameover payload while spectating. The captured gameover payload has no player block, so it’s unclear whether one can show a teammate.

To close most of these, run a capture session with every component on and save each raw payload, previously and added included. It should cover a competitive match through halftime, a defuse, and a round lost on time. It should include a round as CT with a kit, armor, and a helmet, and a game in casual, deathmatch, and wingman. Finally, it should include spectating a demo, for the observer-only blocks.