Garry's Mod Wiki

GetConVarNumber

  number GetConVarNumber( string name )

Description

Returns the numeric value ConVar (converted from the ConVar's string value) with the specified name.

This function will return 0 if the ConVar does not exist. Use cvars.Number to specify your own default.

Will return the value of game.MaxPlayers if maxplayers is specified as the ConVar name, even though maxplayers is not a ConVar. (it is a console command) You should be using aforementioned Lua function instead for that case.

In performance intensive places such as think and rendering callbacks/hooks, it is advised to use ConVar:GetFloat on a ConVar object directly, which be retrieved via GetConVar, or from existing CreateConVar call.

Arguments

1 string name
Name of the ConVar to get the value of.

Returns

1 number
The ConVar's value.