Games

Counter-Strike 2 (CounterStrikeSharp)

How to connect Counter-Strike 2 (CounterStrikeSharp) to valkyr: install the bridge, configure it and see which events and actions it supports.

Method
CounterStrikeSharp plugin (C#)
Status
untested example
Events
frame shot sound spawn

Status: untested example. The plugin (ValkyrPlugin.cs) was not compiled: no .NET SDK and no CounterStrikeSharp package were available where it was written. The unit conversion (Units.cs) was compiled and checked on its own with tests/UnitsCheck.cs (all checks pass).

Scope, read first

  • This plugin runs only on the operator's own community or private CS2 dedicated server, as a CounterStrikeSharp plugin. It never runs on players' machines and installs nothing on them.
  • It reads only state the server already has (player pawn positions, eye angles, game events) and sends it to a valkyr-server the operator runs.
  • It does not interact with VAC or any other anti-cheat, and does not try to bypass, replace or inspect them.
  • Server operators must follow the game's rules for server operators. Kicks and admin notices are the operator's decisions; valkyr only provides evidence and a suggested action.

What it sends

Game sourcevalkyr event
every N ticks, each alive human player: pawn origin, eye angles, on ground flag, jump eventframe
weapon_fireshot (weapon id from the config table) and a sound unless silenced
player_hurt in the same tickfills target and bone of that shot (hit group 1 head; 2, 3, 8 body; 4 to 7 limb)
player_spawn, round_startspawn with the team number
player_footstepsound with the configured radius

Events are batched (BatchIntervalSeconds) to POST /v1/matches/{match_id}/events. The match id is <MatchIdPrefix>-<map>-<unix time> and the match is ended with POST /v1/matches/{match_id}/end on map end. Actions are polled from GET /v1/actions and applied on the game thread: actions listed in KickOnActions kick the player (kickid), actions in NotifyAdminsOnActions print a chat notice to players with AdminPermission. Player ids are SteamID64 values. Bots are ignored.

CS2 does not give plugins the client's own clock, so client_time_ms equals the server time and valkyr's client clock checks have nothing to work with; movement, view, combat, aim and information checks still apply.

Units and axes

Source 2 positions are inches (Hammer units), Z up, yaw 0 along +X and 90 along +Y, pitch positive looking down. valkyr is meters, Y up, yaw 0 along +Z and 90 along +X, pitch positive looking up:

TextText
valkyr (x, y, z) = (X, Z, Y) * 0.0254valkyr yaw       = 90 - source yaw   (wrapped to -180..180)valkyr pitch     = -source pitch

Set the valkyr-server movement limits in meters per second accordingly (CS2 run speed is about 250 units/s, about 6.4 m/s).

Build and install

Requirements: .NET 8 SDK, a CS2 dedicated server with Metamod:Source and CounterStrikeSharp installed.

ShellShell
cd integrations/cs2-counterstrikesharpdotnet build -c Release

Copy bin/Release/net8.0/ValkyrCS2.dll to game/csgo/addons/counterstrikesharp/plugins/ValkyrCS2/ValkyrCS2.dll on the server. On first load CounterStrikeSharp writes the config to game/csgo/addons/counterstrikesharp/configs/plugins/ValkyrCS2/ValkyrCS2.json; see ValkyrCS2.example.json for the fields. Set ApiKey to a valkyr-server key with the ingest role and declare matching weapons (by id) in the valkyr-server combat config.

Check the conversion without the game:

ShellShell
csc -nullable:enable -out:UnitsCheck.exe Units.cs tests/UnitsCheck.cs && UnitsCheck.exe

API names to verify

Written from the CounterStrikeSharp documentation without a compiler. Check these when you build it: pawn.EyeAngles (QAngle X pitch, Y yaw), pawn.Flags bit 0 as on ground, CCSPlayerController.Ping, EventPlayerHurt.Hitgroup, EventWeaponFire.Silenced, EventPlayerFootstep, EventPlayerJump, and whether Server.MapName is available during Load.

Game and platform names belong to their owners and are used only to describe compatibility. valkyr is not affiliated with them.

Edit this page on GitHub