Introduction
Source2Mod is a plugin platform for Counter-Strike 2 servers on Metamod:Source — plugins in C++ or SourcePawn, on one API.
Source2Mod is a server modification for Counter-Strike 2. Plugins are written in C++ or SourcePawn — both are first-class and use the same API: direct access to Source 2 internals (the schema system, entities, hooks, memory, network messages) together with the high-level pieces every server plugin needs: commands, ConVars, game events, menus, timers, translations, HTTP, SQL and more.
Source2Mod grew out of Source2Toolkit: the C++ core and SDK carried over, and SourcePawn was added on top of it.
Who it is for
- C++ developers who want native code with nothing in between, and who are comfortable reading engine code when they need to.
- SourcePawn developers coming from SourceMod: the language they know, with an API that mirrors the C++ one name for name.
- Server owners who run plugins built on Source2Mod: installing it is a
Metamod plugin plus a folder of
.smxfiles — native and script plugins alike.
How it fits with Metamod:Source
Source2Mod is itself a Metamod:Source plugin. Metamod loads the core
(addons/source2mod/bin/...), and the core then loads your plugins — .smx
files from addons/source2mod/plugins/, native libraries and compiled
SourcePawn scripts side by side — and hands each of them the Source2Mod API.
That split is deliberate:
- A plugin talks to one API —
ISource2ModAPIand theg_pSource2Mod*interfaces in C++, theSource2Mod*methodmaps in SourcePawn — instead of fetching engine interfaces, scanning signatures and wiring listeners itself. - Everything a plugin registers — commands, event hooks, timers, net message hooks, menus — is owned by that plugin and removed when it unloads.
- Hooks use KHook, the detour library inside Metamod:Source. Metamod, Source2Mod and every plugin share one KHook instance, so hooks placed by different plugins on the same function chain correctly.
- C++ plugins can give scripts natives of their own, and scripts can share natives and forwards with each other.
The core also resolves engine functions from a shared gamedata folder, so most plugins never ship a signature of their own.
Features
Engine access
- Schema system — generated classes for the game's schema (
CBaseEntity,CCSPlayerController, …) with typed field access and network state updates, in C++ and as SourcePawn methodmaps. - Entities — find, create and spawn entities, entity listeners and entity I/O.
- Hooks — game hooks, KHook virtual, vtable and function detours, and raw hooks from SourcePawn described at runtime.
- Addresses — engine functions the core already resolved (spawn, take damage, set model, switch team, …), ready to call.
- GameConfig — signatures, offsets and patches from JSON gamedata, per platform.
- Memory & modules — pattern scans, symbol lookups and typed casts on any loaded library.
- Game systems — register your own
IGameSystemon the engine's factory list.
Gameplay
- Commands — console and chat commands, plus listeners on commands you do not own.
- Permissions — admins, groups and dotted permissions from a file or granted at runtime, commands gated by them.
- Clients & targeting — players by slot, SteamID or name,
@all/@ctstyle targets with immunity. - ConVars — declare your own, read and write the game's, hear about changes.
- Game events — pre/post hooks with field access,
dontBroadcastand cancel, and firing your own. - Network messages — allocate, send and hook Source 2 net messages by id or by name.
- Menus — center-screen menus with pages and submenus; keys 1–9 work without binds.
- Translations — phrase files per plugin in every player's own language.
- Custom HUD — Panorama layouts with click callbacks.
- Scheduler — timers and next-frame tasks.
- Tracing — ray and hull traces for line-of-sight and collision queries.
- Sounds — sound events for exactly the players you pick, stop and change by guid, per-player volume channels and a hook on every sound the game sends.
- Transmit — per-viewer entity visibility, owner-following and a CheckTransmit hook.
- Scripts — run cs_script (compiled assets, raw source, hot-reloaded files), fire inputs into a script and receive its messages.
Services
- SQL — MySQL and SQLite, queries off the main thread, named connections from
databases.json. - HTTP — asynchronous requests through Steam's HTTP client.
- JSON, files and KeyValues — parse and build JSON, read and write files, a streaming KeyValues parser.
- Client preferences, GeoIP, map lists — per-player settings that persist, a player's country, the map cycle and next map.
- Paths — the game directory, Source2Mod root, configs, gamedata, plugins and a shared data folder.
- Crash handler — minidumps processed on the server itself, plugin frames symbolized to
function @ file:line, a suspected culprit and an optional Discord report.
Where to go next
Installation
Your first C++ plugin
.smx.SourcePawn plugins
SourcePawn section
Coming from CounterStrikeSharp
API reference
Schema
ConVars & Commands
Entities
Protobuf
Events
Panorama
Hooks
License
Source2Mod and its SDK are licensed under the GPLv3, with an MIT exception for derivative works: plugins built against the SDK may use any license you choose, including closed-source and commercial terms. Source2Mod and the SDK themselves, and modified versions of them, stay under the GPLv3. SourcePawn and the parts of the include set that come from SourceMod are AlliedModders LLC's and keep their own license terms. See the FAQ for details.