G.CreateClientConVar
From GMod Wiki
Function | |
Syntax |
CreateClientConVar( String convarName, String or Number default, Boolean shouldSave, Boolean userdata ) Where is this used? |
Description: | |
Creates a clientside console variable. Default is the default value. | |
Returns: | Convar |
Part of Library: | Global Functions |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=G.CreateClientConVar]G.CreateClientConVar [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | This example adds a client console variable called "prp_bankamount". |
---|---|
Used on | |
Code | CreateClientConVar("prp_bankamount", "0", false, false) |
Output | N/A |
Additional Notes
- If userdata is true, then the console variable is sent to the server whenever the client changes it.
- The server can access this variable using player.GetInfo for string or player.GetInfoNum for number such as
pl:GetInfoNum("prp_bankamount")
- Client Lua scripts can set this using G.RunConsoleCommand. ex:
RunConsoleCommand("prp_bankamount","500")
- This function will silently fail if the convar has the string "ent_" in the name!
- If shouldSave is true, then whenever the game is saved the console command will be saved too (and when that save is loaded, the convar will be set to the value that was saved).
- These convars are actually saved in cfg/gmod_cvars_cl.txt when the game is exited regardless of if the game is saved.