Console Variables
How to read & write console variables (ConVars).
Overview
Console variables (ConVars) are the primary way to configure game settings and plugin behavior. With the new class support, you can work with ConVars in two ways:
- Class-based approach - Using the
ConVarwrapper class for cleaner, object-oriented code - Function-based approach - Traditional C-style functions with explicit handles
New: The ConVar class provides automatic resource management, cleaner syntax, and better IDE support. Use it for new code when available in your language!
Finding a ConVar
Use the ConVar.Find static method to get a ConVar instance:
Manipulating Primitive Values
Reading and setting values is more intuitive with methods:
Manipulating Objects
String values are handled through typed methods:
Creating ConVars
Create ConVars using the class constructor with automatic type detection: