DEV Community

Louis Cerclé-Cheminel
Louis Cerclé-Cheminel

Posted on

Building a Suite of C# Server Plugins for Counter-Strike 2

I run a small CS2 Retake community server, and over the past few months I ended up writing (and extending) enough CounterStrikeSharp plugins to call it a suite. Sharing the writeup in case it's useful to anyone else doing Source 2 / CS2 server-side modding in C#.

The stack

CounterStrikeSharp is a .NET 8 scripting layer on top of a Metamod:Source plugin — you write plugins in C#, hook game events, and manipulate entities through a managed API. It's the dominant framework for CS2 server plugins right now (SourceMod's SourcePawn predates CS2 and hasn't caught up to it there).

What's in the suite

CS2-RETAKE is the core piece: a full retake gamemode with a persisted weapon-selection menu (per player × team × round-type, backed by SQLite or Postgres), AWP restrictions, team scramble/queue logic, and a built-in InstaDefuse implementation ported from B3none/cs2-instadefuse. It's a fork of LordFetznschaedl/CS2Retake — full credit in the README, GPL-3.0 throughout.

Around that core, a few companion plugins that each solve one problem and stay out of each other's way:

  • CS2-SpawnEditor — an in-game visual editor for retake spawn points (CBeam pillar markers, nearest-spawn highlighting) so you don't hand-edit spawn JSON.
  • CS2-BreakerAndOpenDoor — opens doors and breaks windows/vents/breakables at round start so every round starts from the same map state. Multi-pass with fallback because Source 2 entity timing during round start is not always cooperative.
  • CS2-Antibait — through-wall glow highlighting for admins, with an auto last-CT-alive mode.
  • CS2-STATPLAY — MySQL-backed stats (kills, rounds, objectives, grenades) aggregated at lifetime/session/map granularity, plus chat commands and milestone webhooks.
  • CS2-AntiSlow, CS2-AdminTools — smaller QoL/admin tools.

One thing worth calling out: getting two plugins that both create entities on EventRoundStart to not crash into each other. Antibait creates glow entities on round start; BreakerAndOpenDoor scans/destroys entities in the same window. Creating a CDynamicProp while another plugin's entity scan is still in flight produces a WriteEnterPVS: GetEntServerClass failed server crash. Antibait gates entity creation on EventRoundFreezeEnd instead, which fires after the scan window closes — a small thing, but the kind of cross-plugin timing bug you only find by running plugins together on a live server.

Links

Suite overview with a compatibility diagram: https://github.com/NeuTroNBZh/CS2-Retake-Suite

Everything is MIT or GPL-3.0, tagged releases with install instructions in each README. Happy to answer questions about CounterStrikeSharp internals or the retake-specific stuff.

Top comments (0)