The Half-Life Unified SDK provides a structured registry for client commands — commands that players send from their client to the server. In the original SDK, incoming client commands were matched using a chain ofDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/twhl-community/halflife-unified-sdk/llms.txt
Use this file to discover all available pages before exploring further.
if statements. The Unified SDK replaces this with a proper registry that supports dynamic registration and removal of commands at any time during the game’s lifetime.
Command Structure
Commands take astd::function object for a function signature void(CBasePlayer* player, const CCommandArgs& args). Typical use involves using a capturing lambda to forward command execution to a member function, as shown below.
The player entity is that of the player who issued the command.
Commands also have a name and flags. The name must include only lowercase alphabetical and underscore characters.
Flags
| Flag | Description |
|---|---|
ClientCommandFlag::None | Constant to use when no flags are set |
ClientCommandFlag::Cheat | Indicates that this command is a cheat command, only allowed when sv_cheats is non-zero |
Registering Commands
There are two ways to register commands, depending on how you want to manage the lifetime of the command. If a command exists for the lifetime of another object like a gamerules class then you should use a scoped command:Create function:
Remove: