The Half-Life Unified SDK includes an abstraction layer over the engine’s console command and CVar facilities. The primary goal of this system is to allow code that runs on both the client and server to register commands and CVars without scatteringDocumentation 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.
#ifdef CLIENT_DLL preprocessor guards throughout the codebase. A unified registration API handles the platform-specific details transparently.
The console command system uses the logger named
cvar. Use this logger name when filtering log output related to command and CVar registration.Library Prefix
A key concept in this system is the library prefix. Because the same code can be compiled into both the client library and the server library, each registered command or CVar is automatically prefixed to indicate its origin:| Context | Prefix |
|---|---|
| Client library | cl |
| Server library | sv |
my_command becomes cl_my_command on the client and sv_my_command on the server. This prevents name collisions between client and server registrations of the same logical command.
The prefix can be suppressed on a per-registration basis when needed (see below).
Registering Commands
Commands are registered through the globalg_ConCommands object using CreateCommand. Each command is backed by a std::function with the signature void(const CCommandArgs& args).
The recommended pattern is a capturing lambda that forwards execution to a member function:
std::function object for a function signature void(const CCommandArgs& args). Typical use involves using a capturing lambda to forward command execution to a member function, as shown above.
Disabling the Library Prefix for Commands
To register a command without any library prefix, passCommandLibraryPrefix::No as the third argument:
Registering CVars
CVars are registered throughg_ConCommands.CreateCVar. Provide the base name, default value string, and any engine CVar flags:
Disabling the Library Prefix for CVars
Just like commands, you can opt out of the library prefix for a CVar:Setting CVars From the Command Line
CVars registered with this system can be set from the command line in one of two ways. Both ways require you to prefix the CVar name with:.
The first is to use the complete CVar name:
+ or -.