|
ds@457
|
1 |
/** |
|
ds@457
|
2 |
* =============================================================== |
|
ds@457
|
3 |
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. |
|
ds@457
|
4 |
* =============================================================== |
|
ds@457
|
5 |
* |
|
ds@457
|
6 |
* This file is part of the SourceMod/SourcePawn SDK. This file may only be used |
|
ds@457
|
7 |
* or modified under the Terms and Conditions of its License Agreement, which is found |
|
ds@457
|
8 |
* in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins |
|
ds@457
|
9 |
* may change at any time. To view the latest information, see: |
|
ds@457
|
10 |
* http://www.sourcemod.net/license.php |
|
ds@457
|
11 |
* |
|
ds@457
|
12 |
* Version: $Id$ |
|
ds@457
|
13 |
*/ |
|
ds@457
|
14 |
|
|
ds@457
|
15 |
#if defined _console_included |
|
ds@457
|
16 |
#endinput |
|
ds@457
|
17 |
#endif |
|
ds@457
|
18 |
#define _console_included |
|
ds@457
|
19 |
|
|
ds@457
|
20 |
/** |
|
ds@457
|
21 |
* Flags for console commands and console variables |
|
ds@457
|
22 |
* @note The descriptions for each constant come directly from the Source SDK. |
|
ds@457
|
23 |
*/ |
|
ds@457
|
24 |
#define FCVAR_NONE 0 /**< The default, no flags at all */ |
|
ds@457
|
25 |
#define FCVAR_UNREGISTERED (1<<0) /**< If this is set, don't add to linked list, etc. */ |
|
ds@457
|
26 |
#define FCVAR_LAUNCHER (1<<1) /**< Defined by launcher. */ |
|
ds@457
|
27 |
#define FCVAR_GAMEDLL (1<<2) /**< Defined by the game DLL. */ |
|
ds@457
|
28 |
#define FCVAR_CLIENTDLL (1<<3) /**< Defined by the client DLL. */ |
|
ds@457
|
29 |
#define FCVAR_MATERIAL_SYSTEM (1<<4) /**< Defined by the material system. */ |
|
ds@457
|
30 |
#define FCVAR_PROTECTED (1<<5) /**< It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value. */ |
|
ds@457
|
31 |
#define FCVAR_SPONLY (1<<6) /**< This cvar cannot be changed by clients connected to a multiplayer server. */ |
|
ds@457
|
32 |
#define FCVAR_ARCHIVE (1<<7) /**< Set to cause it to be saved to vars.rc */ |
|
ds@457
|
33 |
#define FCVAR_NOTIFY (1<<8) /**< Notifies players when changed. */ |
|
ds@457
|
34 |
#define FCVAR_USERINFO (1<<9) /**< Changes the client's info string. */ |
|
ds@457
|
35 |
#define FCVAR_PRINTABLEONLY (1<<10) /**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */ |
|
ds@457
|
36 |
#define FCVAR_UNLOGGED (1<<11) /**< If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log */ |
|
ds@457
|
37 |
#define FCVAR_NEVER_AS_STRING (1<<12) /**< Never try to print that cvar. */ |
|
ds@457
|
38 |
#define FCVAR_REPLICATED (1<<13) /**< Server setting enforced on clients. */ |
|
ds@457
|
39 |
#define FCVAR_CHEAT (1<<14) /**< Only useable in singleplayer / debug / multiplayer & sv_cheats */ |
|
ds@457
|
40 |
#define FCVAR_STUDIORENDER (1<<15) /**< Defined by the studiorender system. */ |
|
ds@457
|
41 |
#define FCVAR_DEMO (1<<16) /**< Record this cvar when starting a demo file. */ |
|
ds@457
|
42 |
#define FCVAR_DONTRECORD (1<<17) /**< Don't record these command in demo files. */ |
|
ds@457
|
43 |
#define FCVAR_PLUGIN (1<<18) /**< Defined by a 3rd party plugin. */ |
|
ds@457
|
44 |
#define FCVAR_DATACACHE (1<<19) /**< Defined by the datacache system. */ |
|
ds@457
|
45 |
#define FCVAR_TOOLSYSTEM (1<<20) /**< Defined by an IToolSystem library */ |
|
ds@457
|
46 |
#define FCVAR_FILESYSTEM (1<<21) /**< Defined by the file system. */ |
|
ds@457
|
47 |
#define FCVAR_NOT_CONNECTED (1<<22) /**< Cvar cannot be changed by a client that is connected to a server. */ |
|
ds@457
|
48 |
#define FCVAR_SOUNDSYSTEM (1<<23) /**< Defined by the soundsystem library. */ |
|
ds@457
|
49 |
#define FCVAR_ARCHIVE_XBOX (1<<24) /**< Cvar written to config.cfg on the Xbox. */ |
|
ds@457
|
50 |
#define FCVAR_INPUTSYSTEM (1<<25) /**< Defined by the inputsystem DLL. */ |
|
ds@457
|
51 |
#define FCVAR_NETWORKSYSTEM (1<<26) /**< Defined by the network system. */ |
|
ds@457
|
52 |
#define FCVAR_VPHYSICS (1<<27) /**< Defined by vphysics. */ |
|
ds@457
|
53 |
|
|
ds@457
|
54 |
/** |
|
ds@457
|
55 |
* Creates a new console variable. |
|
ds@457
|
56 |
* |
|
ds@457
|
57 |
* @param name Name of new convar. |
|
ds@457
|
58 |
* @param defaultValue String containing the default value of new convar. |
|
ds@457
|
59 |
* @param helpText Optional description of the convar. |
|
ds@457
|
60 |
* @param flags Optional bitstream of flags determining how the convar should be handled. (See FCVAR_* constants for more details) |
|
ds@457
|
61 |
* @param hasMin Optional boolean that determines if the convar has a minimum value. |
|
ds@457
|
62 |
* @param min Minimum floating point value that the convar can have if hasMin is true. |
|
ds@457
|
63 |
* @param hasMax Optional boolean that determines if the convar has a maximum value. |
|
ds@457
|
64 |
* @param max Maximum floating point value that the convar can have if hasMax is true. |
|
ds@457
|
65 |
* @return A handle to the newly created convar. If the convar already exists, INVALID_HANDLE is returned. |
|
ds@473
|
66 |
* @error Convar name is blank or is the same as a console command. |
|
ds@457
|
67 |
*/ |
|
ds@457
|
68 |
native Handle:CreateConVar(const String:name[], const String:defaultValue[], const String:helpText[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0); |
|
ds@457
|
69 |
|
|
ds@457
|
70 |
/** |
|
ds@457
|
71 |
* Searches for a console variable. |
|
ds@457
|
72 |
* |
|
ds@457
|
73 |
* @param name Name of convar to find. |
|
ds@457
|
74 |
* @return A handle to the convar if it is found. INVALID_HANDLE otherwise. |
|
ds@457
|
75 |
*/ |
|
ds@457
|
76 |
native Handle:FindConVar(const String:name[]); |
|
ds@457
|
77 |
|
|
ds@457
|
78 |
/** |
|
ds@465
|
79 |
* Called when a console variable's value is changed. |
|
ds@465
|
80 |
* |
|
ds@465
|
81 |
* @param convar Handle to the convar that was changed. |
|
ds@465
|
82 |
* @param oldValue String containing the value of the convar before it was changed. |
|
ds@465
|
83 |
* @param newValue String containing the new value of the convar. |
|
ds@465
|
84 |
* @noreturn |
|
ds@465
|
85 |
*/ |
|
ds@465
|
86 |
functag OnConVarChanged public(Handle:convar, const String:oldValue[], const String:newValue[]); |
|
ds@465
|
87 |
|
|
ds@465
|
88 |
/** |
|
ds@465
|
89 |
* Creates a hook for when a console variable's value is changed. |
|
ds@465
|
90 |
* |
|
ds@465
|
91 |
* @param convar Handle to the convar. |
|
ds@465
|
92 |
* @param callback An OnConVarChanged function pointer. |
|
ds@465
|
93 |
* @noreturn |
|
ds@473
|
94 |
* @error Invalid or corrupt Handle or invalid callback function. |
|
ds@465
|
95 |
*/ |
|
ds@465
|
96 |
native HookConVarChange(Handle:convar, OnConVarChanged:callback); |
|
ds@465
|
97 |
|
|
ds@465
|
98 |
/** |
|
ds@465
|
99 |
* Removes a hook for when a console variable's value is changed. |
|
ds@465
|
100 |
* |
|
ds@465
|
101 |
* @param convar Handle to the convar. |
|
ds@465
|
102 |
* @param callback An OnConVarChanged function pointer. |
|
ds@472
|
103 |
* @noreturn |
|
ds@473
|
104 |
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar. |
|
ds@465
|
105 |
*/ |
|
ds@472
|
106 |
native UnhookConVarChange(Handle:convar, OnConVarChanged:callback); |
|
ds@465
|
107 |
|
|
ds@465
|
108 |
/** |
|
ds@457
|
109 |
* Returns the boolean value of a console variable. |
|
ds@457
|
110 |
* |
|
ds@457
|
111 |
* @param convar Handle to the convar. |
|
ds@457
|
112 |
* @return The boolean value of the convar. |
|
ds@457
|
113 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
114 |
*/ |
|
ds@457
|
115 |
native bool:GetConVarBool(Handle:convar); |
|
ds@457
|
116 |
|
|
ds@457
|
117 |
/** |
|
ds@457
|
118 |
* Sets the boolean value of a console variable. |
|
ds@457
|
119 |
* |
|
ds@457
|
120 |
* @param convar Handle to the convar. |
|
ds@457
|
121 |
* @param value New boolean value. |
|
ds@457
|
122 |
* @noreturn |
|
ds@457
|
123 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
124 |
*/ |
|
ds@457
|
125 |
native SetConVarBool(Handle:convar, bool:value); |
|
ds@457
|
126 |
|
|
ds@457
|
127 |
/** |
|
ds@457
|
128 |
* Returns the integer value of a console variable. |
|
ds@457
|
129 |
* |
|
ds@457
|
130 |
* @param convar Handle to the convar. |
|
ds@457
|
131 |
* @return The integer value of the convar. |
|
ds@457
|
132 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
133 |
*/ |
|
ds@457
|
134 |
native GetConVarInt(Handle:convar); |
|
ds@457
|
135 |
|
|
ds@457
|
136 |
/** |
|
ds@457
|
137 |
* Sets the integer value of a console variable. |
|
ds@457
|
138 |
* |
|
ds@457
|
139 |
* @param convar Handle to the convar. |
|
ds@457
|
140 |
* @param value New integer value. |
|
ds@457
|
141 |
* @noreturn |
|
ds@457
|
142 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
143 |
*/ |
|
ds@457
|
144 |
native SetConVarInt(Handle:convar, value); |
|
ds@457
|
145 |
|
|
ds@457
|
146 |
/** |
|
ds@457
|
147 |
* Returns the floating point value of a console variable. |
|
ds@457
|
148 |
* |
|
ds@457
|
149 |
* @param convar Handle to the convar. |
|
ds@457
|
150 |
* @return The floating point value of the convar. |
|
ds@457
|
151 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
152 |
*/ |
|
ds@457
|
153 |
native Float:GetConVarFloat(Handle:convar); |
|
ds@457
|
154 |
|
|
ds@457
|
155 |
/** |
|
ds@457
|
156 |
* Sets the floating point value of a console variable. |
|
ds@457
|
157 |
* |
|
ds@457
|
158 |
* @param convar Handle to the convar. |
|
ds@457
|
159 |
* @param value New floating point value. |
|
ds@457
|
160 |
* @noreturn |
|
ds@457
|
161 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
162 |
*/ |
|
ds@457
|
163 |
native SetConVarFloat(Handle:convar, Float:value); |
|
ds@457
|
164 |
|
|
ds@457
|
165 |
/** |
|
ds@457
|
166 |
* Retrieves the string value of a console variable. |
|
ds@457
|
167 |
* |
|
ds@457
|
168 |
* @param convar Handle to the convar. |
|
ds@457
|
169 |
* @param value Buffer to store the value of the convar. |
|
ds@465
|
170 |
* @param maxlength Maximum length of string buffer. |
|
ds@457
|
171 |
* @noreturn |
|
ds@457
|
172 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
173 |
*/ |
|
ds@465
|
174 |
native GetConVarString(Handle:convar, String:value[], maxlength); |
|
ds@457
|
175 |
|
|
ds@457
|
176 |
/** |
|
ds@457
|
177 |
* Sets the string value of a console variable. |
|
ds@457
|
178 |
* |
|
ds@457
|
179 |
* @param convar Handle to the convar. |
|
ds@457
|
180 |
* @param value New string value. |
|
ds@457
|
181 |
* @noreturn |
|
ds@457
|
182 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
183 |
*/ |
|
ds@457
|
184 |
native SetConVarString(Handle:convar, const String:value[]); |
|
ds@457
|
185 |
|
|
ds@457
|
186 |
/** |
|
ds@457
|
187 |
* Returns the bitstring of flags on a console variable. |
|
ds@457
|
188 |
* |
|
ds@457
|
189 |
* @param convar Handle to the convar. |
|
ds@457
|
190 |
* @return A bitstring containing the FCVAR_* flags that are enabled. |
|
ds@457
|
191 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
192 |
*/ |
|
ds@457
|
193 |
native GetConVarFlags(Handle:convar); |
|
ds@457
|
194 |
|
|
ds@457
|
195 |
/** |
|
ds@457
|
196 |
* Sets the bitstring of flags on a console variable. |
|
ds@457
|
197 |
* |
|
ds@457
|
198 |
* @param convar Handle to the convar. |
|
ds@457
|
199 |
* @param flags A bitstring containing the FCVAR_* flags to enable. |
|
ds@457
|
200 |
* @noreturn |
|
ds@457
|
201 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
202 |
*/ |
|
ds@457
|
203 |
native SetConVarFlags(Handle:convar, flags); |
|
ds@457
|
204 |
|
|
ds@457
|
205 |
/** |
|
ds@465
|
206 |
* Retrieves the name of a console variable. |
|
ds@465
|
207 |
* |
|
ds@465
|
208 |
* @param convar Handle to the convar. |
|
ds@465
|
209 |
* @param value Buffer to store the name of the convar. |
|
ds@465
|
210 |
* @param maxlength Maximum length of string buffer. |
|
ds@465
|
211 |
* @noreturn |
|
ds@465
|
212 |
* @error Invalid or corrupt Handle. |
|
ds@465
|
213 |
*/ |
|
ds@465
|
214 |
native GetConVarName(Handle:convar, const String:name[], maxlength); |
|
ds@465
|
215 |
|
|
ds@465
|
216 |
/** |
|
ds@457
|
217 |
* Retrieves the minimum floating point value that a console variable can contain. |
|
ds@457
|
218 |
* |
|
ds@457
|
219 |
* @param convar Handle to the convar. |
|
ds@457
|
220 |
* @param min By-reference cell to store the minimum floating point value. |
|
ds@457
|
221 |
* @return True if the convar has a minimum value set, false otherwise. |
|
ds@457
|
222 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
223 |
*/ |
|
ds@457
|
224 |
native bool:GetConVarMin(Handle:convar, &Float:min); |
|
ds@457
|
225 |
|
|
ds@457
|
226 |
/** |
|
ds@457
|
227 |
* Retrieves the maximum floating point value that a console variable can contain. |
|
ds@457
|
228 |
* |
|
ds@457
|
229 |
* @param convar Handle to the convar. |
|
ds@457
|
230 |
* @param min By-reference cell to store the maximum floating point value. |
|
ds@457
|
231 |
* @return True if the convar has a maximum value set, false otherwise. |
|
ds@457
|
232 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
233 |
*/ |
|
ds@457
|
234 |
native bool:GetConVarMax(Handle:convar, &Float:max); |
|
ds@457
|
235 |
|
|
ds@457
|
236 |
/** |
|
ds@457
|
237 |
* Resets the console variable to its default value. |
|
ds@457
|
238 |
* |
|
ds@457
|
239 |
* @param convar Handle to the convar. |
|
ds@457
|
240 |
* @noreturn |
|
ds@457
|
241 |
* @error Invalid or corrupt Handle. |
|
ds@457
|
242 |
*/ |
|
ds@457
|
243 |
native ResetConVar(Handle:convar); |