Console Variables
How to read & write console variables (ConVars).
Finding a ConVar
Use the FindConVar
static method to find a reference to an existing ConVar handle (or null
).
Manipulating Primitive Values
Reading the value of a ConVar will depend on the type; for basic value Cvars (like float, int, bool) you can use the GetConVar
method to get a copy
as the value.
Because this is passed by copy, you can't simply set this value to change the underlying value, e.g. You need to use the SetConVar
method to change the value of a ConVar.
Manipulating Objects
By default, the GetConVar
method will return a string value for string Cvars. You can use the GetConVarString
method to get a String
object, which you can then manipulate as normal. To set the value back, you will need to use the SetConVarString
method.
Creating ConVars
You can create your own ConVars using the CreateConVar
method. This is useful for creating custom settings for your plugin.