Garry's Mod Wiki

cvars

The cvars library allows you to control what happens when a cvar (console variable) is changed.

Methods

cvars.AddChangeCallback( string name, function callback, string identifier = nil )
Adds a callback to be called when the named convar changes. This does not callback convars in the menu state. Issue Tracker: 1440This does not callback convars on the client with FCVAR_GAMEDLL and convars on the server without FCVAR_GAMEDLL. Issue Tracker: 3503This does not callback convars on the client with FCVAR_REPLICATED. Issue Tracker: 3740
boolean cvars.Bool( string cvar, boolean default = false )
Retrieves console variable as a boolean.
table cvars.GetConVarCallbacks( string name, boolean createIfNotFound = false )
Returns a table of the given ConVars callbacks.
number cvars.Number( string cvar, any default = nil )
Retrieves console variable as a number.
cvars.OnConVarChanged( string name, string oldVal, string newVal )
This is used internally - although you're able to use it you probably shouldn't. You are probably looking for cvars. AddChangeCallback. Called by the engine when a convar value changes.
cvars.RemoveChangeCallback( string name, string indentifier )
Removes a callback for a convar using the the callback's identifier. The identifier should be the third argument specified for cvars. AddChangeCallback.
string cvars.String( string cvar, any default = nil )
Retrieves console variable as a string.