Garry's Mod Wiki

Player:GetInfoNum

  number Player:GetInfoNum( string cVarName, number default )

Description

Retrieves the numeric value of a client-side convar, returns nil if value is not convertible to a number. The ConVar must have a FCVAR_USERINFO flag for this to work.

Arguments

1 string cVarName
The name of the ConVar to query the value of
2 number default
Default value if we failed to retrieve the number.

Returns

1 number
The value of the ConVar or the default value

Example

Creates clientside ConVar 'Apple' and retrieves value of it.

if CLIENT then CreateConVar( "Apple", "1", FCVAR_USERINFO ) else MsgN( Entity( 1 ):GetInfoNum( "Apple" ) ) end
Output: 1

Example

Shows difference between Player:GetInfo and Player:GetInfoNum.

if CLIENT then CreateConVar( "Apple", "1", FCVAR_USERINFO ) else MsgN( type( Entity( 1 ):GetInfoNum( "Apple", 1 ) ) ) MsgN( type( Entity( 1 ):GetInfo( "Apple" ) ) ) end
Output:
number string