G.ConVarExists

From GMod Wiki

Jump to: navigation, search
Function
Syntax ConVarExists( String convar )
Where is this used?
Description:
Used to check if a convar exists, so as to not create it over again and overwrite existing values.
Returns: Boolean
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.ConVarExists]G.ConVarExists [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionThis example was pulled from server_settings.lua
Used onNewerServer.png
Code
//Define the config file
local CONFIG_FILE = "../cfg/server_cfg.txt"
// Load the config file
local f = file.Read( CONFIG_FILE )
 
// Put it in a table
Settings = util.KeyValuesToTable( f )
 
// Create the convars if they don't already exist
for k, v in pairs( Settings ) do
	if ( !ConVarExists( k ) ) then
		CreateConVar( k, v, FCVAR_NOTIFY )
	end
end
 
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox