Dear me, I should have committed this long ago...
1) Added natives to create and manipulate global and private forward
2) Added natives to call forwards and functions
3) Added an IChanageableForward::RemoveFunction overload for convenience or something
4) Added test suite plugins for functions and forwards
5) Some random touch-ups to some include files
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _console_included
19 #define _console_included
22 * @section Flags for console commands and console variables. The descriptions
23 * for each constant come directly from the Source SDK.
25 #define FCVAR_NONE 0 /**< The default, no flags at all */
26 #define FCVAR_UNREGISTERED (1<<0) /**< If this is set, don't add to linked list, etc. */
27 #define FCVAR_LAUNCHER (1<<1) /**< Defined by launcher. */
28 #define FCVAR_GAMEDLL (1<<2) /**< Defined by the game DLL. */
29 #define FCVAR_CLIENTDLL (1<<3) /**< Defined by the client DLL. */
30 #define FCVAR_MATERIAL_SYSTEM (1<<4) /**< Defined by the material system. */
31 #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. */
32 #define FCVAR_SPONLY (1<<6) /**< This cvar cannot be changed by clients connected to a multiplayer server. */
33 #define FCVAR_ARCHIVE (1<<7) /**< Set to cause it to be saved to vars.rc */
34 #define FCVAR_NOTIFY (1<<8) /**< Notifies players when changed. */
35 #define FCVAR_USERINFO (1<<9) /**< Changes the client's info string. */
36 #define FCVAR_PRINTABLEONLY (1<<10) /**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */
37 #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 */
38 #define FCVAR_NEVER_AS_STRING (1<<12) /**< Never try to print that cvar. */
39 #define FCVAR_REPLICATED (1<<13) /**< Server setting enforced on clients. */
40 #define FCVAR_CHEAT (1<<14) /**< Only useable in singleplayer / debug / multiplayer & sv_cheats */
41 #define FCVAR_STUDIORENDER (1<<15) /**< Defined by the studiorender system. */
42 #define FCVAR_DEMO (1<<16) /**< Record this cvar when starting a demo file. */
43 #define FCVAR_DONTRECORD (1<<17) /**< Don't record these command in demo files. */
44 #define FCVAR_PLUGIN (1<<18) /**< Defined by a 3rd party plugin. */
45 #define FCVAR_DATACACHE (1<<19) /**< Defined by the datacache system. */
46 #define FCVAR_TOOLSYSTEM (1<<20) /**< Defined by an IToolSystem library */
47 #define FCVAR_FILESYSTEM (1<<21) /**< Defined by the file system. */
48 #define FCVAR_NOT_CONNECTED (1<<22) /**< Cvar cannot be changed by a client that is connected to a server. */
49 #define FCVAR_SOUNDSYSTEM (1<<23) /**< Defined by the soundsystem library. */
50 #define FCVAR_ARCHIVE_XBOX (1<<24) /**< Cvar written to config.cfg on the Xbox. */
51 #define FCVAR_INPUTSYSTEM (1<<25) /**< Defined by the inputsystem DLL. */
52 #define FCVAR_NETWORKSYSTEM (1<<26) /**< Defined by the network system. */
53 #define FCVAR_VPHYSICS (1<<27) /**< Defined by vphysics. */
60 * Executes a server command as if it were on the server console (or RCON)
62 * @param format Formatting rules.
63 * @param ... Variable number of format parameters.
66 native ServerCommand(const String:format[], {Handle,Float,String,_}:...);
69 * Inserts a server command at the beginning of the server command buffer.
71 * @param format Formatting rules.
72 * @param ... Variable number of format parameters.
75 native InsertServerCommand(const String:format[], {Handle,Float,String,_}:...);
78 * Executes every command in the server's command buffer, rather than once per frame.
82 native ServerExecute();
85 * Executes a client command. Note that this will not work on clients unless
86 * they have cl_restrict_server_commands set to 0.
88 * @param client Index of the client.
89 * @param fmt Format of the client command.
90 * @param ... Format parameters/
92 * @error Invalid client index, or client not connected.
94 native ClientCommand(client, const String:fmt[], {String,Float,Handle,Function,_}:...);
97 * Sends a message to the server console.
99 * @param format Formatting rules.
100 * @param ... Variable number of format parameters.
103 native PrintToServer(const String:format[], {Handle,Float,String,Function,_}:...);
106 * Sends a message to a client's console.
108 * @param client Player index.
109 * @param format Formatting rules.
110 * @param ... Variable number of format parameters.
112 * @error If the client is not connected an error will be thrown.
114 native PrintToConsole(client, const String:format[], {Handle,Float,String,Function,_}:...);
117 * Called when a server-only command is invoked.
119 * @params args Number of arguments that were in the argument string.
120 * @return A Result value. Not handling the command
121 * means that Source will report it as "not found."
123 functag SrvCmd Action:public(args);
126 * Creates a server-only console command, or hooks an already existing one.
128 * @param cmd Name of the command to hook or create.
129 * @param callback A function to use as a callback for when the command is invoked.
130 * @param description Optional description to use for command creation.
131 * @param flags Optional flags to use for command creation.
133 * @error Command name is the same as an existing convar.
135 native RegServerCmd(const String:cmd[], SrvCmd:callback, const String:description[]="", flags=0);
138 * Called when a generic console command is invoked.
140 * @param client Index of the client, or 0 from the server.
141 * @param args Number of arguments that were in the argument string.
142 * @return A Result value. Not handling the command
143 * means that Source will report it as "not found."
145 functag ConCmd Action:public(client, args);
148 * Creates a console command, or hooks an already existing one.
150 * @param cmd Name of the command to hook or create.
151 * @param callback A function to use as a callback for when the command is invoked.
152 * @param description Optional description to use for command creation.
153 * @param flags Optional flags to use for command creation.
155 * @error Command name is the same as an existing convar.
157 native RegConsoleCmd(const String:cmd[], ConCmd:callback, const String:description[]="", flags=0);
160 * Creates a console command as an administrative command. If the command does not exist,
161 * it is created. When this command is invoked, the access rights of the player are
162 * automatically checked before allowing it to continue.
164 * @param cmd String containing command to register.
165 * @param callback A function to use as a callback for when the command is invoked.
166 * @param adminflags Administrative flags (bitstring) to use for permissions.
167 * @param group String containing the command group to use. If empty,
168 * the plugin's filename will be used instead.
169 * @param description Optional description to use for help.
170 * @param flags Optional console flags.
172 * @error Command name is the same as an existing convar.
174 native RegAdminCmd(const String:cmd[],
177 const String:description[]="",
178 const String:group[]="",
182 * Returns the number of arguments from the current console or server command.
183 * @note Unlike the HL2 engine call, this does not include the command itself.
185 * @return Number of arguments to the current command.
190 * Retrieves a command argument given its index, from the current console or
192 * @note Argument indexes start at 1; 0 retrieves the command name.
194 * @param argnum Argument number to retrieve.
195 * @param buffer Buffer to use for storing the string.
196 * @param maxlength Maximum length of the buffer.
199 native GetCmdArg(argnum, String:buffer[], maxlength);
202 * Retrieves the entire command argument string in one lump from the current
203 * console or server command.
205 * @param buffer Buffer to use for storing the string.
206 * @param maxlength Maximum length of the buffer.
209 native GetCmdArgString(String:buffer[], maxlength);
212 * Creates a new console variable.
214 * @param name Name of new convar.
215 * @param defaultValue String containing the default value of new convar.
216 * @param description Optional description of the convar.
217 * @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
218 * @param hasMin Optional boolean that determines if the convar has a minimum value.
219 * @param min Minimum floating point value that the convar can have if hasMin is true.
220 * @param hasMax Optional boolean that determines if the convar has a maximum value.
221 * @param max Maximum floating point value that the convar can have if hasMax is true.
222 * @return A handle to the newly created convar. If the convar already exists, INVALID_HANDLE is returned.
223 * @error Convar name is blank or is the same as an existing console command.
225 native Handle:CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0);
228 * Searches for a console variable.
230 * @param name Name of convar to find.
231 * @return A handle to the convar if it is found. INVALID_HANDLE otherwise.
233 native Handle:FindConVar(const String:name[]);
236 * Called when a console variable's value is changed.
238 * @param convar Handle to the convar that was changed.
239 * @param oldValue String containing the value of the convar before it was changed.
240 * @param newValue String containing the new value of the convar.
243 functag ConVarChanged public(Handle:convar, const String:oldValue[], const String:newValue[]);
246 * Creates a hook for when a console variable's value is changed.
248 * @param convar Handle to the convar.
249 * @param callback An OnConVarChanged function pointer.
251 * @error Invalid or corrupt Handle or invalid callback function.
253 native HookConVarChange(Handle:convar, ConVarChanged:callback);
256 * Removes a hook for when a console variable's value is changed.
258 * @param convar Handle to the convar.
259 * @param callback An OnConVarChanged function pointer.
261 * @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
263 native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
266 * Returns the boolean value of a console variable.
268 * @param convar Handle to the convar.
269 * @return The boolean value of the convar.
270 * @error Invalid or corrupt Handle.
272 native bool:GetConVarBool(Handle:convar);
275 * Sets the boolean value of a console variable.
277 * @param convar Handle to the convar.
278 * @param value New boolean value.
280 * @error Invalid or corrupt Handle.
282 native SetConVarBool(Handle:convar, bool:value);
285 * Returns the integer value of a console variable.
287 * @param convar Handle to the convar.
288 * @return The integer value of the convar.
289 * @error Invalid or corrupt Handle.
291 native GetConVarInt(Handle:convar);
294 * Sets the integer value of a console variable.
296 * @param convar Handle to the convar.
297 * @param value New integer value.
299 * @error Invalid or corrupt Handle.
301 native SetConVarInt(Handle:convar, value);
304 * Returns the floating point value of a console variable.
306 * @param convar Handle to the convar.
307 * @return The floating point value of the convar.
308 * @error Invalid or corrupt Handle.
310 native Float:GetConVarFloat(Handle:convar);
313 * Sets the floating point value of a console variable.
315 * @param convar Handle to the convar.
316 * @param value New floating point value.
318 * @error Invalid or corrupt Handle.
320 native SetConVarFloat(Handle:convar, Float:value);
323 * Retrieves the string value of a console variable.
325 * @param convar Handle to the convar.
326 * @param value Buffer to store the value of the convar.
327 * @param maxlength Maximum length of string buffer.
329 * @error Invalid or corrupt Handle.
331 native GetConVarString(Handle:convar, String:value[], maxlength);
334 * Sets the string value of a console variable.
336 * @param convar Handle to the convar.
337 * @param value New string value.
339 * @error Invalid or corrupt Handle.
341 native SetConVarString(Handle:convar, const String:value[]);
344 * Returns the bitstring of flags on a console variable.
346 * @param convar Handle to the convar.
347 * @return A bitstring containing the FCVAR_* flags that are enabled.
348 * @error Invalid or corrupt Handle.
350 native GetConVarFlags(Handle:convar);
353 * Sets the bitstring of flags on a console variable.
355 * @param convar Handle to the convar.
356 * @param flags A bitstring containing the FCVAR_* flags to enable.
358 * @error Invalid or corrupt Handle.
360 native SetConVarFlags(Handle:convar, flags);
363 * Retrieves the name of a console variable.
365 * @param convar Handle to the convar.
366 * @param value Buffer to store the name of the convar.
367 * @param maxlength Maximum length of string buffer.
369 * @error Invalid or corrupt Handle.
371 native GetConVarName(Handle:convar, const String:name[], maxlength);
374 * Retrieves the minimum floating point value that a console variable can contain.
376 * @param convar Handle to the convar.
377 * @param min By-reference cell to store the minimum floating point value.
378 * @return True if the convar has a minimum value set, false otherwise.
379 * @error Invalid or corrupt Handle.
381 native bool:GetConVarMin(Handle:convar, &Float:min);
384 * Retrieves the maximum floating point value that a console variable can contain.
386 * @param convar Handle to the convar.
387 * @param min By-reference cell to store the maximum floating point value.
388 * @return True if the convar has a maximum value set, false otherwise.
389 * @error Invalid or corrupt Handle.
391 native bool:GetConVarMax(Handle:convar, &Float:max);
394 * Resets the console variable to its default value.
396 * @param convar Handle to the convar.
398 * @error Invalid or corrupt Handle.
400 native ResetConVar(Handle:convar);