Work in Progress — CS2-Kit is under active development. Expect breaking changes.
Prerequisites
- C++23 compiler (MSVC 19.38+, GCC 13+, Clang 17+)
- HL2SDK (hl2sdk-cs2 branch)
- Metamod:Source 2.0
- AMBuild (or your preferred build system)
Adding CS2-Kit to Your Project
CS2-Kit is designed to be included as source files in your Metamod plugin project. There is no separate compiled library — you compile the .cpp files alongside your own code.
As a Git Submodule
git submodule add https://github.com/suxrobgm/cs2-kit.git vendor/cs2-kit
AMBuild Integration
In your AMBuildScript, add CS2-Kit source files to your build:
import os
CS2KIT_DIR = os.path.join(builder.sourcePath, "vendor", "cs2-kit")
CS2KIT_INCLUDE_DIR = os.path.join(CS2KIT_DIR, "include")
CS2KIT_SRC_DIR = os.path.join(CS2KIT_DIR, "src")
binary.compiler.cxxincludes += [CS2KIT_INCLUDE_DIR]
for root, dirs, files in os.walk(CS2KIT_SRC_DIR):
for f in files:
if f.endswith(".cpp"):
binary.sources += [os.path.join(root, f)]
Initialization
CS2Kit handles SDK interface resolution, gamedata loading, and subsystem initialization internally. Just pass the Metamod ISmmAPI pointer:
#include <CS2Kit/CS2Kit.hpp>
bool MyPlugin::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool late)
{
PLUGIN_SAVEVARS();
CS2Kit::InitParams params;
params.LogPrefix = "MyPlugin";
return false;
return true;
}
bool Initialize(ISmmAPI *ismm, char *error, size_t maxlen, const InitParams ¶ms)
CS2Kit::Initialize() performs the following internally:
- Sets up logging (built-in
ConsoleLogger by default, or your custom ILogger)
- Resolves all required SDK interfaces via
ISmmAPI::VInterfaceMatch()
- Sets the HL2SDK
g_pCVar global
- Loads engine signatures and offsets from built-in gamedata
- Initializes all subsystems (schema, entities, events, menus, ConVars)
Game Frame Hook
The scheduler and menu system require a per-tick callback. Hook IServerGameDLL::GameFrame:
void MyPlugin::GameFrame(bool simulating, bool firstTick, bool lastTick)
{
}
Player Disconnect Hook
Clean up menu state when players disconnect:
void MyPlugin::ClientDisconnect(CPlayerSlot slot, ...)
{
}
void OnPlayerDisconnect(int slot)
Shutdown
bool MyPlugin::Unload(char* error, size_t maxlen)
{
return true;
}
Next Steps