cvars.AddChangeCallback

From Garry's Mod
Jump to: navigation, search
 cvars.AddChangeCallback( )

Contents

Description

Adds a callback to be called when the named convar changes.

BUG

This does not callback convars in the menu state.

Issue Tracker: #1440

BUG

This does not callback convars on the client with FCVAR_GAMEDLL and convars on the server without FCVAR_GAMEDLL.

Issue Tracker: #3503

BUG

This does not callback convars on the client with FCVAR_REPLICATED.

Issue Tracker: #3740

Arguments

string name

The name of the convar to add the change callback to.

Arguments

function callback

The function to be called when the convar changes. The arguments passed are:

  • string convar - The name of the convar.
  • string oldValue - The old value of the convar.
  • string newValue - The new value of the convar.

Arguments

string identifier=nil

If set, you will be able to remove the callback using cvars.RemoveChangeCallback.

Examples

Example

Called when convar changes.

cvars.AddChangeCallback("convar name", function(convar_name, value_old, value_new)
    print(convar_name, value_old, value_new)
end)

Output:

"convar name" 2 5
Personal tools
Navigation