ConVar.GetFloat

From GMod Wiki

Jump to: navigation, search
Function
Syntax ConVar:GetFloat( )
Description:
Retrieves an integer as a float value from a ConVar object.
Returns: Float
In Object: Convar
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=ConVar.GetFloat]ConVar.GetFloat [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionThis example shows how the GetFloat method translates different data types and values
Used onNewerClient.png
Code
local convar1 = CreateClientConVar("__testconvar_float_1",0)
local convar2 = CreateClientConVar("__testconvar_float_2","0")
local convar3 = CreateClientConVar("__testconvar_float_3",1)
local convar4 = CreateClientConVar("__testconvar_float_4","1")
local convar5 = CreateClientConVar("__testconvar_float_5",1.3)
local convar6 = CreateClientConVar("__testconvar_float_6","1.3")
local convar7 = CreateClientConVar("__testconvar_float_7","lolstring")
local convar8 = CreateClientConVar("__testconvar_float_8","")
Msg("Command 1: "..tostring(convar1:GetFloat()).."\n")
Msg("Command 2: "..tostring(convar2:GetFloat()).."\n")
Msg("Command 3: "..tostring(convar3:GetFloat()).."\n")
Msg("Command 4: "..tostring(convar4:GetFloat()).."\n")
Msg("Command 5: "..tostring(convar5:GetFloat()).."\n")
Msg("Command 6: "..tostring(convar6:GetFloat()).."\n")
Msg("Command 7: "..tostring(convar7:GetFloat()).."\n")
Msg("Command 8: "..tostring(convar8:GetFloat()).."\n")
Output
Command 1: 0
Command 2: 0
Command 3: 1
Command 4: 1
Command 5: 1.2999999523163
Command 6: 1.2999999523163
Command 7: 0
Command 8: 0


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox