Garry's Mod Wiki

DMenu:AddCVar

  Panel DMenu:AddCVar( string strText, string convar, string on, string off, function funcFunction = nil )

Description

Creates a DMenuOptionCVar and adds it as an option into the menu. Checking and unchecking the option will alter the given console variable's value.

Arguments

1 string strText
The text of the button
2 string convar
The console variable to change
3 string on
The value of the console variable to set when the option is checked
4 string off
The value of the console variable to set when the option is unchecked
5 function funcFunction = nil
If set, the function will be called every time the option is pressed/clicked/selected.
Function argument(s):
1 Panel pnl - The DMenuOptionCVar that was clicked.

Returns

1 Panel
The created DMenuOptionCVar