CVar

How to create a console variable ?
Just can’t understand the syntax/function of it and that there are few types of them



concommand.Add
G.CreateConVar
G.CreateClientConVar


What I need is a server-side float/real number

[editline]…[/editline]
Shit - wrong section, but I probably wouldn’t get any help in 10 mins in newb questions section

If you want it to store a value, use CreateConVar. If you want it to actually do something, use concommand.Add.

Syntax is here

[lua]
–CreateConVar( “Your Custom Cvar Name”, “Default Value”, { Table of flags } )
local yourcvar = CreateConVar( “sv_numberthingawatever”, 1337, { FCVAR_ARCHIVE, FCVAR_NOTIFY } )

local number = yourcvar:GetInt()
local float = yourcvar:GetFloat()
local string = yourcvar:GetString()
local bool = yourcvar:GetBool()

print( "sv_numberthingawatever: Number = " … number )
print( "sv_numberthingawatever: Float = " … float )
print( "sv_numberthingawatever: String = " … string )
print( "sv_numberthingawatever: Bool = " … bool )
[/lua]

Should return this in console.



sv_numberthingawatever: Number = 1337
sv_numberthingawatever: Float = 1337.00
sv_numberthingawatever: String = 1337
sv_numberthingawatever: Bool = true


Hope this helps.

Thanks, +1 Tool