Difference between revisions of "CCVar"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Outerbeast (talk | contribs) m  | 
				Outerbeast (talk | contribs)  m  | 
				||
| Line 75: | Line 75: | ||
<pre>void CVarCallback(CCVar@ cvar, const string& in szOldValue, float flOldValue)</pre>  | <pre>void CVarCallback(CCVar@ cvar, const string& in szOldValue, float flOldValue)</pre>  | ||
Called when the command is executed.  | Called when the command is executed.  | ||
| + | |||
| + | [[Category:Scripting]]  | ||
Latest revision as of 15:33, 6 March 2025
The CCVar class represents a custom server console variable.
To create a custom cvar, it is done as follows:
CCVar myCvar( <your cvar name>", <default value>, "Description of the CVar goes here." );
Using the cvar is done via:
as_command <your cvar name>
This can be put in the CFG file or in the console.
1 Constructors
| Constructor | Description | 
|---|---|
CCVar(const string& in szName, float flValue = 0, const string& in szHelpInfo = "", const ConCommandFlags_t flags = ConCommandFlag::None, CVarCallback@ pCallback = null)
 | 
Creates a cvar with the given name, float value, help info, flags and callback. | 
CCVar(const string& in szName, const string& in szValue, const string& in szHelpInfo = "", const ConCommandFlags_t flags = ConCommandFlag::None, CVarCallback@ pCallback = null)
 | 
Creates a cvar with the given name, string value, help info, flags and callback. | 
2 Methods
| Function | Description | 
|---|---|
const string& GetName() const
 | 
Gets the name of this command. | 
const string& GetFullyQualifiedName() const
 | 
Gets the fully qualified name of this command. This is the name that the command is referred to when called. | 
const string& GetHelpInfo() const
 | 
Gets the help info describing this command. | 
ConCommandKind::Type GetKind() const
 | 
Gets the type of this console command. | 
const string& GetOwningModuleName() const
 | 
Gets the name of the module that owns (created) this command. | 
bool HasBeenAdded() const
 | 
Whether this command was added to the list of commands. Must be added to be usable from the console. | 
const string& GetDefaultValue() const
 | 
Gets the default value for this cvar. | 
const string& GetString() const
 | 
Converts the value to a string. | 
float GetFloat() const
 | 
Converts the value to a float. | 
int GetInt() const
 | 
Converts the value to an integer. | 
bool GetBool() const
 | 
Converts the value to a boolean. | 
void SetString(const string& in szValue)
 | 
Sets the given string as the value. | 
void SetFloat(const float flValue)
 | 
Sets the given float as the value. | 
void SetInt(const int iValue)
 | 
Sets the given integer as the value. | 
void SetBool(const bool bValue)
 | 
Sets the given boolean as the value. | 
3 Funcdefs
void CVarCallback(CCVar@ cvar, const string& in szOldValue, float flOldValue)
Called when the command is executed.