Panel/SetConVar

From Garry's Mod
Revision as of 11:49, 12 October 2019 by Argonium (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 Panel:SetConVar( )

Contents

Description

WARNING

This function does not exist on all panels

WARNING

This function cannot interact with serverside convars unless you are host

NOTE

Blocked convars will not work with this, see Blocked ConCommands

Sets this panel's convar. When the convar changes this panel will update automatically.

For developer implementation, see Derma_Install_Convar_Functions.

Arguments

string convar

The console variable to check.

Examples

Example

Makes a checkbox linked to the cl_drawhud convar.

local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 100, 100 )
DermaPanel:SetSize( 300, 200 )
DermaPanel:SetTitle( "My new Derma frame" )
DermaPanel:SetDraggable( true )
DermaPanel:MakePopup()

local Checkbox = vgui.Create( "DCheckBoxLabel", DermaPanel )
Checkbox:SetConVar( "cl_drawhud" )
Checkbox:SetText( "Enable HUD?" )
Checkbox:SetPos( 5, 25 )
Checkbox:SizeToContents()

Output:

panel setcvar.png
Personal tools
Navigation