Revision Difference
Global.GetConVar#552363
<function name="GetConVar" parent="Global" type="libraryfunc">
<description>
Gets the <page>ConVar</page> with the specified name.
<note>This function uses <page>Global.GetConVar_Internal</page> internally, but caches the result in Lua for quicker lookups.</note>
<warning>Due to this function using <page>Global.GetConVar_Internal</page> internally it tends to be relatively slow. Please attempt to 'cache' the return of what you used to make it instead of using this function.
Example:
```
local exampleConvar = CreateClientConVar("exampleConvar", "hi")
print(exampleConvar:GetString())
```
</warning>
</description>
<realm>Shared and Menu</realm>
<file line="471-L483">lua/includes/util.lua</file>
<file line="472-L484">lua/includes/util.lua</file>
<args>
<arg name="name" type="string">Name of the ConVar to get</arg>
</args>
<rets>
<ret name="" type="ConVar">The <page>ConVar</page> object, or nil if no such <page>ConVar</page> was found.</ret>
</rets>
</function>
<example>
<description>Makes a ConVar and utilizes GetConVar to print the value of the ConVar.</description>
<code>
CreateClientConVar("exampleConvar", "hi")
concommand.Add("exampleConvar2", function()
MsgN("ConVar Value: " .. GetConVar("exampleConvar"):GetString())
end)
</code>
<output>
```
ConVar Value: hi
```
</output>
</example>