Cvar use


(jobe314) #1

hi,
can someone explain me how to use Cvar?
i want to create a Cvar and give it a value with the console and then give it to my mapscript.
like a boolean var in c++.
but i dont know how and where create cvar, and what is the command to give it a value with the console may be setstate?
thx


(Ragnar_40k) #2

http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=6730


(kamikazee) #3

I believe this should be in the level design forum, since it involves a map script.

To create a CVAR, just use /set. To make sure it gets saved, use /seta.


(jobe314) #4

i want a variable to do the same as a boolean.
so if i understand i just need to do:
/set CVAR variable_name 1
this command will create my cvar variable_name and put it to value 1
is that correct?


(kamikazee) #5

No, you use a wrong syntax. It’s:

/set variable_name 1

Allso not that you’d need to do

/seta variable_name 1 

if you want the CVAR to be saved in your config, otherwise it might be gone at the map’s end.

BTW: Cvar’s are not boolean’s. They’re variant-typed. It can be integers, otherwise they are strings. As long as you say “the value needs to be 1 or 0” to server admins who will set this cvar, you’re fine.


(jobe314) #6

ok ty very much
just one more question: if i do /set before running the map (host game menu for example), at map begining my Cvar has the good value or i must do /seta before launching my map?


(kamikazee) #7

Do /seta and it will be allways at the same value as you set it, don’t use /set.