Page 1 of 1

How to use Cvars

Posted: Sun May 22, 2016 9:43 pm
by decompile
Hey,

Im still having issues how to use cvars in source python, wiki couldnt help me much, thats why im asking here to be sure.

1. How can I get a cvar?

Lets say mp_timelimit;float

2. How can I set/change a cvar value?

3. How can I create a cvar?

lets say xx_version == 1.0.1

Re: How to use Cvars

Posted: Sun May 22, 2016 10:15 pm
by Ayuto
It's quite easy! :)

Syntax: Select all

from cvars import ConVar

# Get an existing ConVar
mp_timelimit = ConVar('mp_timelimit')
print(mp_timelimit.get_float())

# Create a new ConVar
my_convar = ConVar('my_convar')

# Set a ConVar
my_convar.set_int(10)

Re: How to use Cvars

Posted: Sun May 22, 2016 10:30 pm
by decompile
Thank you!

Re: How to use Cvars

Posted: Mon May 23, 2016 12:28 am
by satoon101
Also, to create a ConVar with the config package:
http://builds.sourcepython.com/job/Sour ... onfig.html

That needs some updating, but should suffice.

And, for a public versioning ConVar:
http://builds.sourcepython.com/job/Sour ... blicConVar