Player/GetInfoNum

From Garry's Mod
Jump to: navigation, search
 Player:GetInfoNum( )

Contents

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

string cVarName

The name of the ConVar to query the value of

Arguments

number default

Default value if we failed to retrieve the number.

Returns

number

The value of the ConVar or the default value

Examples

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

Examples

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
Personal tools
Navigation