ConVar: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Add FCVAR_ARCHIVE save location)
(Added more tips.)
Line 21: Line 21:
</pre>
</pre>
== Good practices ==
== Good practices ==
Variables that you wish to be saved should be marked with flag [[FCVAR_ARCHIVE]]. These will be saved with the user bindings in <code>config.cfg</code>. Any cheat ConVar should not be archived.
* Variables that you wish to be saved should be marked with flag [[FCVAR_ARCHIVE]]. These will be saved with the user bindings in <code>config.cfg</code>. Any cheat ConVar should not be archived.
 
* After whatever flags you may want to add (or 0 if you don't want any), you can set a help string. This will display when someone enters in the ConVar without any value or if they enter an invalid value. You can use \n to make a new line and use spaces after that to indent lines. Make your help-strings as rich and detailed as you want!
 
* Use the flag FCVAR_CHEAT to signify a ConVar that can only be used when sv_cheats is turned on.
 
* Use the flag FCVAR_REPLICATED to signify a server variable which is then ''replicated'' onto clients. For example, round timers or game rules should have this flag.


== See also ==
== See also ==

Revision as of 15:48, 26 March 2017

Template:Otherlang2

Stub

This article or section is a stub. You can help by expanding it.

For a description of what a Console Variable is, see Commands and variables.

Documentation on specific console variables can be found at Category:Console Variables. For creating a new Console Variable see this. Developer Console Control


ConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax );

The default value given as the second argument of the ConVar constructor is not the value set. To set a value, use:

pName->SetValue([value]);

Good practices

  • Variables that you wish to be saved should be marked with flag FCVAR_ARCHIVE. These will be saved with the user bindings in config.cfg. Any cheat ConVar should not be archived.
  • After whatever flags you may want to add (or 0 if you don't want any), you can set a help string. This will display when someone enters in the ConVar without any value or if they enter an invalid value. You can use \n to make a new line and use spaces after that to indent lines. Make your help-strings as rich and detailed as you want!
  • Use the flag FCVAR_CHEAT to signify a ConVar that can only be used when sv_cheats is turned on.
  • Use the flag FCVAR_REPLICATED to signify a server variable which is then replicated onto clients. For example, round timers or game rules should have this flag.

See also

Developer Console Control