# roflmuffin/counterstrikesharp architecture

> Architecture diagram of the GitHub repository roflmuffin/counterstrikesharp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/roflmuffin/counterstrikesharp
- Repository: https://github.com/roflmuffin/counterstrikesharp

## Overview

CounterStrikeSharp is a Counter-Strike 2 server-side modding framework: plugin developers write C# plugins against a .NET API, which exposes game-server commands, events, listeners, timers, player/entity state, and related features. At runtime, the Metamod plugin and native scripting bridge connect those plugins to the game. The README documents the main capabilities; source excerpts are partial, so links between unsampled runtime components are limited to documented architecture and visible native dispatch.

Main entry points: [`managed/CounterStrikeSharp.API/Api.cs`](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Api.cs) (Plugin API), [`src/scripting/script_engine.cpp`](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/script_engine.cpp) (Native dispatch), [`managed/CounterStrikeSharp.API/Core/BasePlugin.cs`](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Core/BasePlugin.cs) (C# plugin), [`src/scripting/dotnet_host.cpp`](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/dotnet_host.cpp) (.NET host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin_api["Plugin API"]
  node_api["Plugin API<br/>[Api.cs]"]
  node_commands["Command handling<br/>[CommandManager.cs]"]
  node_admin["Admin permissions<br/>[AdminManager.cs]"]
  node_events["Events and listeners<br/>[GameEvent.cs]"]
  node_timers["Tick timers<br/>[Timer.cs]"]
  node_entities["Players and entities<br/>[Player.cs]"]
  node_menus["Player menus<br/>[MenuManager.cs]"]
end

subgraph group_managed_runtime["Managed Runtime"]
  node_host[".NET host<br/>[dotnet_host.cpp]"]
  node_script_engine["Native dispatch<br/>[script_engine.cpp]"]
end

subgraph group_native_runtime["Native Runtime"]
  node_native_commands["Command natives"]
  node_native_events["Event natives<br/>[natives_events.cpp]"]
  node_native_engine["Engine natives<br/>[natives_engine.cpp]"]
  node_command_manager["Native commands"]
  node_event_manager["Native events<br/>[event_manager.cpp]"]
  node_player_manager["Player lifecycle<br/>[player_manager.cpp]"]
  node_timer_system["Timer scheduler<br/>[timer_system.cpp]"]
end

subgraph group_game_integration["Game Integration"]
  node_schema["Schema access<br/>[Schema.cs]"]
  node_metamod["Metamod plugin<br/>[mm_plugin.cpp]"]
end

node_developer(("Plugin developer"))
node_plugin["C&#35; plugin<br/>[BasePlugin.cs]"]
node_game_server(("Counter-Strike 2 server"))

node_developer -->|"authors"| node_plugin
node_plugin -->|"uses"| node_api
node_plugin -->|"loaded by"| node_host
node_api -->|"registers commands"| node_commands
node_api -->|"subscribes to"| node_events
node_api -->|"schedules timers"| node_timers
node_api -->|"accesses game state"| node_entities
node_api -->|"displays menus"| node_menus
node_commands -->|"checks permissions"| node_admin
node_metamod -->|"hosts runtime"| node_host
node_host -->|"invokes natives"| node_script_engine
node_script_engine -->|"dispatches"| node_native_commands
node_script_engine -->|"dispatches"| node_native_events
node_script_engine -->|"dispatches"| node_native_engine
node_native_commands -->|"registers commands"| node_command_manager
node_native_events -->|"registers callbacks"| node_event_manager
node_player_manager -->|"executes callbacks"| node_script_engine
node_native_engine -->|"reads tick time"| node_timer_system
node_schema -->|"reads schema state"| node_game_server
node_command_manager -->|"registers server commands"| node_game_server
node_event_manager -->|"handles game events"| node_game_server
node_player_manager -->|"tracks players"| node_game_server
node_metamod -->|"integrates with"| node_game_server

click node_plugin "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Core/BasePlugin.cs"
click node_api "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Api.cs"
click node_commands "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Core/Commands/CommandManager.cs"
click node_admin "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Admin/AdminManager.cs"
click node_events "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Events/GameEvent.cs"
click node_timers "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Timers/Timer.cs"
click node_entities "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Entities/Player.cs"
click node_menus "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Menu/MenuManager.cs"
click node_schema "https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Memory/Schema.cs"
click node_host "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/dotnet_host.cpp"
click node_script_engine "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/script_engine.cpp"
click node_native_commands "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_commands.cpp"
click node_native_events "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_events.cpp"
click node_native_engine "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_engine.cpp"
click node_command_manager "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/con_command_manager.cpp"
click node_event_manager "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/event_manager.cpp"
click node_player_manager "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/player_manager.cpp"
click node_timer_system "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/timer_system.cpp"
click node_metamod "https://github.com/roflmuffin/counterstrikesharp/blob/main/src/mm_plugin.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_commands,node_admin,node_events,node_timers,node_entities,node_menus toneBlue
class node_host,node_script_engine toneAmber
class node_native_commands,node_native_events,node_native_engine,node_command_manager,node_event_manager,node_player_manager,node_timer_system,node_game_server toneMint
class node_schema,node_metamod toneRose
class node_developer toneIndigo
class node_plugin toneTeal
```

## Components

### Plugin API

- [Plugin API](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Api.cs): `managed/CounterStrikeSharp.API/Api.cs`
- [Command handling](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Core/Commands/CommandManager.cs): `managed/CounterStrikeSharp.API/Core/Commands/CommandManager.cs`
- [Admin permissions](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Admin/AdminManager.cs): `managed/CounterStrikeSharp.API/Modules/Admin/AdminManager.cs`
- [Events and listeners](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Events/GameEvent.cs): `managed/CounterStrikeSharp.API/Modules/Events/GameEvent.cs`
- [Tick timers](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Timers/Timer.cs): `managed/CounterStrikeSharp.API/Modules/Timers/Timer.cs`
- [Players and entities](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Entities/Player.cs): `managed/CounterStrikeSharp.API/Modules/Entities/Player.cs`
- [Player menus](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Menu/MenuManager.cs): `managed/CounterStrikeSharp.API/Modules/Menu/MenuManager.cs`

### Managed Runtime

- [.NET host](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/dotnet_host.cpp): `src/scripting/dotnet_host.cpp`
- [Native dispatch](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/script_engine.cpp): `src/scripting/script_engine.cpp`

### Native Runtime

- [Command natives](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_commands.cpp): `src/scripting/natives/natives_commands.cpp`
- [Event natives](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_events.cpp): `src/scripting/natives/natives_events.cpp`
- [Engine natives](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/scripting/natives/natives_engine.cpp): `src/scripting/natives/natives_engine.cpp`
- [Native commands](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/con_command_manager.cpp): `src/core/managers/con_command_manager.cpp`
- [Native events](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/event_manager.cpp): `src/core/managers/event_manager.cpp`
- [Player lifecycle](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/managers/player_manager.cpp): `src/core/managers/player_manager.cpp`
- [Timer scheduler](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/core/timer_system.cpp): `src/core/timer_system.cpp`

### Game Integration

- [Schema access](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Modules/Memory/Schema.cs): `managed/CounterStrikeSharp.API/Modules/Memory/Schema.cs`
- [Metamod plugin](https://github.com/roflmuffin/counterstrikesharp/blob/main/src/mm_plugin.cpp): `src/mm_plugin.cpp`

### Other components

- **Plugin developer**
- [C# plugin](https://github.com/roflmuffin/counterstrikesharp/blob/main/managed/CounterStrikeSharp.API/Core/BasePlugin.cs): `managed/CounterStrikeSharp.API/Core/BasePlugin.cs`
- **Counter-Strike 2 server**

## Connections

- Plugin developer → C# plugin: authors
- C# plugin → Plugin API: uses
- C# plugin → .NET host: loaded by
- Plugin API → Command handling: registers commands
- Plugin API → Events and listeners: subscribes to
- Plugin API → Tick timers: schedules timers
- Plugin API → Players and entities: accesses game state
- Plugin API → Player menus: displays menus
- Command handling → Admin permissions: checks permissions
- Metamod plugin → .NET host: hosts runtime
- .NET host → Native dispatch: invokes natives
- Native dispatch → Command natives: dispatches
- Native dispatch → Event natives: dispatches
- Native dispatch → Engine natives: dispatches
- Command natives → Native commands: registers commands
- Event natives → Native events: registers callbacks
- Player lifecycle → Native dispatch: executes callbacks
- Engine natives → Timer scheduler: reads tick time
- Schema access → Counter-Strike 2 server: reads schema state
- Native commands → Counter-Strike 2 server: registers server commands
- Native events → Counter-Strike 2 server: handles game events
- Player lifecycle → Counter-Strike 2 server: tracks players
- Metamod plugin → Counter-Strike 2 server: integrates with
