plugins/include/console.inc
author Scott Ehlert <ds@alliedmods.net>
Wed Feb 25 23:00:59 2009 -0600 (2009-02-25)
changeset 2615 651b94271b43
parent 2396 0a0bb1f7e9b3
child 2400 76b7b4575e21
permissions -rw-r--r--
Fixed 1.1.1 tag for great justice!
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32  
    33 #if defined _console_included
    34  #endinput
    35 #endif
    36 #define _console_included
    37 
    38 #define INVALID_FCVAR_FLAGS		(-1)
    39 
    40 /**
    41  * Console variable bound values used with Get/SetConVarBounds()
    42  */
    43 enum ConVarBounds
    44 {
    45 	ConVarBound_Upper = 0,
    46 	ConVarBound_Lower
    47 };
    48 
    49 /**
    50  * Console variable query helper values.
    51  */
    52 enum QueryCookie
    53 {
    54 	QUERYCOOKIE_FAILED = 0,
    55 };
    56 
    57 /**
    58  * Reply sources for commands.
    59  */
    60 enum ReplySource
    61 {
    62 	SM_REPLY_TO_CONSOLE = 0,
    63 	SM_REPLY_TO_CHAT = 1,
    64 };
    65 
    66 /**
    67  * Console variable query result values.
    68  */
    69 enum ConVarQueryResult
    70 {
    71 	ConVarQuery_Okay = 0,				/**< Retrieval of client convar value was successful. */
    72 	ConVarQuery_NotFound,				/**< Client convar was not found. */
    73 	ConVarQuery_NotValid,				/**< A console command with the same name was found, but there is no convar. */
    74 	ConVarQuery_Protected				/**< Client convar was found, but it is protected. The server cannot retrieve its value. */
    75 };
    76 
    77 /**
    78  * @section Flags for console commands and console variables.  The descriptions 
    79  * for each constant come directly from the Source SDK.
    80  */
    81 #define FCVAR_NONE				0		/**< The default, no flags at all */
    82 #define FCVAR_UNREGISTERED		(1<<0)	/**< If this is set, don't add to linked list, etc. */
    83 #define FCVAR_LAUNCHER			(1<<1)	/**< Defined by launcher. */
    84 #define FCVAR_GAMEDLL			(1<<2)	/**< Defined by the game DLL. */
    85 #define FCVAR_CLIENTDLL			(1<<3)	/**< Defined by the client DLL. */
    86 #define FCVAR_MATERIAL_SYSTEM	(1<<4)	/**< Defined by the material system. */
    87 #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. */
    88 #define FCVAR_SPONLY			(1<<6)	/**< This cvar cannot be changed by clients connected to a multiplayer server. */
    89 #define	FCVAR_ARCHIVE			(1<<7)	/**< Set to cause it to be saved to vars.rc */
    90 #define	FCVAR_NOTIFY			(1<<8)	/**< Notifies players when changed. */
    91 #define	FCVAR_USERINFO			(1<<9)	/**< Changes the client's info string. */
    92 #define FCVAR_PRINTABLEONLY		(1<<10)	/**< This cvar's string cannot contain unprintable characters (e.g., used for player name, etc.) */
    93 #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 */
    94 #define FCVAR_NEVER_AS_STRING	(1<<12)	/**< Never try to print that cvar. */
    95 #define FCVAR_REPLICATED		(1<<13)	/**< Server setting enforced on clients. */
    96 #define FCVAR_CHEAT				(1<<14)	/**< Only useable in singleplayer / debug / multiplayer & sv_cheats */
    97 #define FCVAR_STUDIORENDER		(1<<15)	/**< Defined by the studiorender system. */
    98 #define FCVAR_DEMO				(1<<16)	/**< Record this cvar when starting a demo file. */
    99 #define FCVAR_DONTRECORD		(1<<17)	/**< Don't record these command in demo files. */
   100 #define FCVAR_PLUGIN			(1<<18)	/**< Defined by a 3rd party plugin. */
   101 #define FCVAR_DATACACHE			(1<<19)	/**< Defined by the datacache system. */
   102 #define FCVAR_TOOLSYSTEM		(1<<20)	/**< Defined by an IToolSystem library */
   103 #define FCVAR_FILESYSTEM		(1<<21)	/**< Defined by the file system. */
   104 #define FCVAR_NOT_CONNECTED		(1<<22)	/**< Cvar cannot be changed by a client that is connected to a server. */
   105 #define FCVAR_SOUNDSYSTEM		(1<<23)	/**< Defined by the soundsystem library. */
   106 #define FCVAR_ARCHIVE_XBOX		(1<<24)	/**< Cvar written to config.cfg on the Xbox. */
   107 #define FCVAR_INPUTSYSTEM		(1<<25)	/**< Defined by the inputsystem DLL. */
   108 #define FCVAR_NETWORKSYSTEM		(1<<26)	/**< Defined by the network system. */
   109 #define FCVAR_VPHYSICS			(1<<27)	/**< Defined by vphysics. */
   110 
   111 /**
   112  * @endsection
   113  */
   114 
   115 /**
   116  * Executes a server command as if it were on the server console (or RCON)
   117  *
   118  * @param format		Formatting rules.
   119  * @param ...			Variable number of format parameters.
   120  * @noreturn
   121  */
   122 native ServerCommand(const String:format[], any:...);
   123 
   124 /**
   125  * Inserts a server command at the beginning of the server command buffer.
   126  *
   127  * @param format		Formatting rules.
   128  * @param ...			Variable number of format parameters.
   129  * @noreturn
   130  */
   131 native InsertServerCommand(const String:format[], any:...);
   132 
   133 /**
   134  * Executes every command in the server's command buffer, rather than once per frame.
   135  *
   136  * @noreturn
   137  */
   138 native ServerExecute();
   139 
   140 /**
   141  * Executes a client command.  Note that this will not work on clients unless
   142  * they have cl_restrict_server_commands set to 0.
   143  *
   144  * @param client		Index of the client.
   145  * @param fmt			Format of the client command.
   146  * @param ...			Format parameters/
   147  * @noreturn
   148  * @error				Invalid client index, or client not connected.
   149  */
   150 native ClientCommand(client, const String:fmt[], any:...);
   151 
   152 /**
   153  * Executes a client command on the server without being networked.
   154  *
   155  * FakeClientCommand() overwrites the command tokenization buffer.  This can 
   156  * cause undesired effects because future calls to GetCmdArg* will return 
   157  * data from the FakeClientCommand(), not the parent command.  If you are in 
   158  * a hook where this matters (for example, a "say" hook), you should use 
   159  * FakeClientCommandEx() instead.
   160  *
   161  * @param client		Index of the client.
   162  * @param fmt			Format of the client command.
   163  * @param ...			Format parameters
   164  * @noreturn
   165  * @error				Invalid client index, or client not connected.
   166  */
   167 native FakeClientCommand(client, const String:fmt[], any:...);
   168 
   169 /**
   170  * Executes a client command on the server without being networked.  The 
   171  * execution of the client command is delayed by one frame to prevent any 
   172  * re-entrancy issues that might surface with FakeClientCommand().
   173  *
   174  * @param client		Index of the client.
   175  * @param fmt			Format of the client command.
   176  * @param ...			Format parameters
   177  * @noreturn
   178  * @error				Invalid client index, or client not connected.
   179  */
   180 native FakeClientCommandEx(client, const String:fmt[], any:...);
   181 
   182 /**
   183  * Sends a message to the server console.
   184  *
   185  * @param format		Formatting rules.
   186  * @param ...			Variable number of format parameters.
   187  * @noreturn
   188  */
   189 native PrintToServer(const String:format[], any:...);
   190 
   191 /**
   192  * Sends a message to a client's console.
   193  *
   194  * @param client		Client index.
   195  * @param format		Formatting rules.
   196  * @param ...			Variable number of format parameters.
   197  * @noreturn
   198  * @error				If the client is not connected an error will be thrown.
   199  */
   200 native PrintToConsole(client, const String:format[], any:...);
   201 
   202 /**
   203  * Reples to a message in a command.
   204  *
   205  * A client index of 0 will use PrintToServer().
   206  * If the command was from the console, PrintToConsole() is used.
   207  * If the command was from chat, PrintToChat() is used.
   208  *
   209  * @param client		Client index, or 0 for server.
   210  * @param format		Formatting rules.
   211  * @param ...			Variable number of format parameters.
   212  * @noreturn
   213  * @error				If the client is not connected or invalid.
   214  */
   215 native ReplyToCommand(client, const String:format[], any:...);
   216 
   217 /**
   218  * Returns the current reply source of a command.
   219  *
   220  * @return				ReplySource value.
   221  */
   222 native ReplySource:GetCmdReplySource();
   223 
   224 /**
   225  * Sets the current reply source of a command.
   226  *
   227  * Only use this if you know what you are doing.  You should save the old value
   228  * and restore it once you are done.
   229  *
   230  * @param source		New ReplySource value.
   231  * @return				Old ReplySource value.
   232  */
   233 native ReplySource:SetCmdReplySource(ReplySource:source);
   234 
   235 /**
   236  * Returns whether the current say hook is a chat trigger.
   237  *
   238  * This function is only meaningful inside say or say_team hooks.
   239  *
   240  * @return				True if a chat trigger, false otherwise.
   241  */
   242 native bool:IsChatTrigger();
   243 
   244 /**
   245  * Displays usage of an admin command to users depending on the 
   246  * setting of the sm_show_activity cvar.  All users receive a message 
   247  * in their chat text, except for the originating client, who receives 
   248  * the message based on the current ReplySource.
   249  *
   250  * @param client		Client index doing the action, or 0 for server.
   251  * @param tag			Tag to prepend to the message.
   252  * @param format		Formatting rules.
   253  * @param ...			Variable number of format parameters.
   254  * @noreturn
   255  * @error
   256  */
   257 native ShowActivity2(client, const String:tag[], const String:format[], any:...);
   258 
   259 /**
   260  * Displays usage of an admin command to users depending on the 
   261  * setting of the sm_show_activity cvar.  
   262  *
   263  * This version does not display a message to the originating client 
   264  * if used from chat triggers or menus.  If manual replies are used 
   265  * for these cases, then this function will suffice.  Otherwise, 
   266  * ShowActivity2() is slightly more useful.
   267  *
   268  * @param client		Client index doing the action, or 0 for server.
   269  * @param format		Formatting rules.
   270  * @param ...			Variable number of format parameters.
   271  * @noreturn
   272  * @error
   273  */
   274 native ShowActivity(client, const String:format[], any:...);
   275 
   276 /**
   277  * Same as ShowActivity(), except the tag parameter is used instead of
   278  * "[SM] " (note that you must supply any spacing).
   279  *
   280  * @param client		Client index doing the action, or 0 for server.
   281  * @param tag			Tag to display with.
   282  * @param format		Formatting rules.
   283  * @param ...			Variable number of format parameters.
   284  * @noreturn
   285  * @error
   286  */
   287 native ShowActivityEx(client, const String:tag[], const String:format[], any:...);
   288 
   289 /**
   290  * Given an originating client and a target client, returns the string 
   291  * that describes the originating client according to the sm_show_activity cvar.
   292  *
   293  * For example, "ADMIN", "PLAYER", or a player's name could be placed in this buffer.
   294  *
   295  * @param client        Originating client; may be 0 for server console.
   296  * @param target        Targeted client.
   297  * @param namebuf       Name buffer.
   298  * @param maxlength     Maximum size of the name buffer.
   299  * @return              True if activity should be shown.  False otherwise.  In either 
   300  *                      case, the name buffer is filled.  The return value can be used 
   301  *                      to broadcast a "safe" name to all players regardless of the 
   302  *                      sm_show_activity filters.
   303  * @error               Invalid client index or client not connected.
   304  */
   305 native FormatActivitySource(client, target, const String:namebuf[], maxlength);
   306 
   307 /**
   308  * Called when a server-only command is invoked.  
   309  *
   310  * @params args			Number of arguments that were in the argument string.
   311  * @return				An Action value.  Not handling the command
   312  *						means that Source will report it as "not found."
   313  */
   314 functag public Action:SrvCmd(args);
   315 
   316 /**
   317  * Creates a server-only console command, or hooks an already existing one.  
   318  *
   319  * Server commands are case sensitive.
   320  *
   321  * @param cmd			Name of the command to hook or create.
   322  * @param callback		A function to use as a callback for when the command is invoked.
   323  * @param description	Optional description to use for command creation.
   324  * @param flags			Optional flags to use for command creation.
   325  * @noreturn
   326  * @error				Command name is the same as an existing convar.
   327  */
   328 native RegServerCmd(const String:cmd[], SrvCmd:callback, const String:description[]="", flags=0);
   329 
   330 /**
   331  * Called when a generic console command is invoked.
   332  *
   333  * @param client		Index of the client, or 0 from the server.
   334  * @param args			Number of arguments that were in the argument string.
   335  * @return				An Action value.  Not handling the command
   336  *						means that Source will report it as "not found."
   337  */
   338 functag public Action:ConCmd(client, args);
   339 
   340 /**
   341  * Creates a console command, or hooks an already existing one.
   342  *
   343  * Console commands are case sensitive.  However, if the command already exists in the game, 
   344  * the a client may enter the command in any case.  SourceMod corrects for this automatically, 
   345  * and you should only hook the "real" version of the command.
   346  *
   347  * @param cmd			Name of the command to hook or create.
   348  * @param callback		A function to use as a callback for when the command is invoked.
   349  * @param description	Optional description to use for command creation.
   350  * @param flags			Optional flags to use for command creation.
   351  * @noreturn
   352  * @error				Command name is the same as an existing convar.
   353  */
   354 native RegConsoleCmd(const String:cmd[], ConCmd:callback, const String:description[]="", flags=0);
   355 
   356 /**
   357  * Creates a console command as an administrative command.  If the command does not exist,
   358  * it is created.  When this command is invoked, the access rights of the player are 
   359  * automatically checked before allowing it to continue.
   360  *
   361  * Admin commands are case sensitive from both the client and server.
   362  *
   363  * @param cmd			String containing command to register.
   364  * @param callback		A function to use as a callback for when the command is invoked.
   365  * @param adminflags	Administrative flags (bitstring) to use for permissions.
   366  * @param description	Optional description to use for help.
   367  * @param group			String containing the command group to use.  If empty,
   368  * 						the plugin's filename will be used instead.
   369  * @param flags			Optional console flags.
   370  * @noreturn
   371  * @error				Command name is the same as an existing convar.
   372  */
   373 native RegAdminCmd(const String:cmd[],
   374 					ConCmd:callback,
   375 					adminflags,
   376 					const String:description[]="",
   377 					const String:group[]="",
   378 					flags=0);
   379 					
   380 /**
   381  * Returns the number of arguments from the current console or server command.
   382  * @note Unlike the HL2 engine call, this does not include the command itself.
   383  *
   384  * @return				Number of arguments to the current command.
   385  */
   386 native GetCmdArgs();
   387 
   388 /**
   389  * Retrieves a command argument given its index, from the current console or 
   390  * server command.
   391  * @note Argument indexes start at 1; 0 retrieves the command name.
   392  *
   393  * @param argnum		Argument number to retrieve.
   394  * @param buffer		Buffer to use for storing the string.
   395  * @param maxlength		Maximum length of the buffer.
   396  * @return				Length of string written to buffer.
   397  */
   398 native GetCmdArg(argnum, String:buffer[], maxlength);
   399 
   400 /**
   401  * Retrieves the entire command argument string in one lump from the current 
   402  * console or server command.
   403  *
   404  * @param buffer		Buffer to use for storing the string.
   405  * @param maxlength		Maximum length of the buffer.
   406  * @return				Length of string written to buffer.
   407  */
   408 native GetCmdArgString(String:buffer[], maxlength);
   409 
   410 /**
   411  * Creates a new console variable.
   412  *
   413  * @param name			Name of new convar.
   414  * @param defaultValue	String containing the default value of new convar.
   415  * @param description	Optional description of the convar.
   416  * @param flags			Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
   417  * @param hasMin		Optional boolean that determines if the convar has a minimum value.
   418  * @param min			Minimum floating point value that the convar can have if hasMin is true.
   419  * @param hasMax		Optional boolean that determines if the convar has a maximum value.
   420  * @param max			Maximum floating point value that the convar can have if hasMax is true.
   421  * @return				A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
   422  * @error				Convar name is blank or is the same as an existing console command.
   423  */
   424 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);
   425 
   426 /**
   427  * Searches for a console variable.
   428  *
   429  * @param name			Name of convar to find.
   430  * @return				A handle to the convar if it is found. INVALID_HANDLE otherwise.
   431  */
   432 native Handle:FindConVar(const String:name[]);
   433 
   434 /**
   435  * Called when a console variable's value is changed.
   436  *
   437  * @param convar		Handle to the convar that was changed.
   438  * @param oldValue		String containing the value of the convar before it was changed.
   439  * @param newValue		String containing the new value of the convar.
   440  * @noreturn
   441  */
   442 functag public ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]);
   443 
   444 /**
   445  * Creates a hook for when a console variable's value is changed.
   446  *
   447  * @param convar		Handle to the convar.
   448  * @param callback		An OnConVarChanged function pointer.
   449  * @noreturn
   450  * @error				Invalid or corrupt Handle or invalid callback function.
   451  */
   452 native HookConVarChange(Handle:convar, ConVarChanged:callback);
   453 
   454 /**
   455  * Removes a hook for when a console variable's value is changed.
   456  *
   457  * @param convar		Handle to the convar.
   458  * @param callback		An OnConVarChanged function pointer.
   459  * @noreturn
   460  * @error				Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
   461  */
   462 native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
   463 
   464 /**
   465  * Returns the boolean value of a console variable.
   466  *
   467  * @param convar		Handle to the convar.
   468  * @return				The boolean value of the convar.
   469  * @error				Invalid or corrupt Handle.
   470  */
   471 native bool:GetConVarBool(Handle:convar);
   472 
   473 /**
   474  * Sets the boolean value of a console variable.
   475  *
   476  * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine.
   477  * This engine automatically replicates and notifies as soon as the convar is changed.
   478  *
   479  * @param convar		Handle to the convar.
   480  * @param value			New boolean value.
   481  * @param replicate		If set to true, the new convar value will be set on all clients.
   482  *						This will only work if the convar has the FCVAR_REPLICATED flag
   483  *						and actually exists on clients.
   484  * @param notify		If set to true, clients will be notified that the convar has changed.
   485  *						This will only work if the convar has the FCVAR_NOTIFY flag.
   486  * @noreturn
   487  * @error				Invalid or corrupt Handle.
   488  */
   489 native SetConVarBool(Handle:convar, bool:value, bool:replicate=false, bool:notify=false);
   490 
   491 /**
   492  * Returns the integer value of a console variable.
   493  *
   494  * @param convar		Handle to the convar.
   495  * @return				The integer value of the convar.
   496  * @error				Invalid or corrupt Handle.
   497  */
   498 native GetConVarInt(Handle:convar);
   499 
   500 /**
   501  * Sets the integer value of a console variable.
   502  *
   503  * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine.
   504  * This engine automatically replicates and notifies as soon as the convar is changed.
   505  *
   506  * @param convar		Handle to the convar.
   507  * @param value			New integer value.
   508  * @param replicate		If set to true, the new convar value will be set on all clients.
   509  *						This will only work if the convar has the FCVAR_REPLICATED flag
   510  *						and actually exists on clients.
   511  * @param notify		If set to true, clients will be notified that the convar has changed.
   512  *						This will only work if the convar has the FCVAR_NOTIFY flag.
   513  * @noreturn
   514  * @error				Invalid or corrupt Handle.
   515  */
   516 native SetConVarInt(Handle:convar, value, bool:replicate=false, bool:notify=false);
   517 
   518 /**
   519  * Returns the floating point value of a console variable.
   520  *
   521  * @param convar		Handle to the convar.
   522  * @return				The floating point value of the convar.
   523  * @error				Invalid or corrupt Handle.
   524  */
   525 native Float:GetConVarFloat(Handle:convar);
   526 
   527 /**
   528  * Sets the floating point value of a console variable.
   529  *
   530  * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine.
   531  * This engine automatically replicates and notifies as soon as the convar is changed.
   532  *
   533  * @param convar		Handle to the convar.
   534  * @param value			New floating point value.
   535  * @param replicate		If set to true, the new convar value will be set on all clients.
   536  *						This will only work if the convar has the FCVAR_REPLICATED flag
   537  *						and actually exists on clients.
   538  * @param notify		If set to true, clients will be notified that the convar has changed.
   539  *						This will only work if the convar has the FCVAR_NOTIFY flag.
   540  * @noreturn
   541  * @error				Invalid or corrupt Handle.
   542  */
   543 native SetConVarFloat(Handle:convar, Float:value, bool:replicate=false, bool:notify=false);
   544 
   545 /**
   546  * Retrieves the string value of a console variable.
   547  *
   548  * @param convar		Handle to the convar.
   549  * @param value			Buffer to store the value of the convar.
   550  * @param maxlength		Maximum length of string buffer.
   551  * @noreturn
   552  * @error				Invalid or corrupt Handle.     
   553  */
   554 native GetConVarString(Handle:convar, String:value[], maxlength);
   555 
   556 /**
   557  * Sets the string value of a console variable.
   558  *
   559  * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine.
   560  * This engine automatically replicates and notifies as soon as the convar is changed.
   561  *
   562  * @param convar		Handle to the convar.
   563  * @param value			New string value.
   564  * @param replicate		If set to true, the new convar value will be set on all clients.
   565  *						This will only work if the convar has the FCVAR_REPLICATED flag
   566  *						and actually exists on clients.
   567  * @param notify		If set to true, clients will be notified that the convar has changed.
   568  *						This will only work if the convar has the FCVAR_NOTIFY flag.
   569  * @noreturn
   570  * @error				Invalid or corrupt Handle.
   571  */
   572 native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
   573 
   574 /**
   575  * Resets the console variable to its default value.
   576  *
   577  * Note: The replicate and notify params are ignored on the Episode 2/Orange Box engine.
   578  * This engine automatically replicates and notifies as soon as the convar is changed.
   579  *
   580  * @param convar		Handle to the convar.
   581  * @param replicate		If set to true, the new convar value will be set on all clients.
   582  *						This will only work if the convar has the FCVAR_REPLICATED flag
   583  *						and actually exists on clients.
   584  * @param notify		If set to true, clients will be notified that the convar has changed.
   585  *						This will only work if the convar has the FCVAR_NOTIFY flag.
   586  * @noreturn
   587  * @error				Invalid or corrupt Handle.
   588  */
   589 native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
   590 
   591 /**
   592  * Returns the bitstring of flags on a console variable.
   593  *
   594  * @param convar		Handle to the convar.
   595  * @return				A bitstring containing the FCVAR_* flags that are enabled.
   596  * @error				Invalid or corrupt Handle.
   597  */
   598 native GetConVarFlags(Handle:convar);
   599 
   600 /**
   601  * Sets the bitstring of flags on a console variable.
   602  *
   603  * @param convar		Handle to the convar.
   604  * @param flags			A bitstring containing the FCVAR_* flags to enable.
   605  * @noreturn
   606  * @error				Invalid or corrupt Handle.
   607  */
   608 native SetConVarFlags(Handle:convar, flags);
   609 
   610 /**
   611  * Retrieves the specified bound of a console variable.
   612  *
   613  * @param convar		Handle to the convar.
   614  * @param type			Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
   615  * @param value			By-reference cell to store the specified floating point bound value.
   616  * @return				True if the convar has the specified bound set, false otherwise.
   617  * @error				Invalid or corrupt Handle.
   618  */
   619 native bool:GetConVarBounds(Handle:convar, ConVarBounds:type, &Float:value);
   620 
   621 /**
   622  * Sets the specified bound of a console variable.
   623  *
   624  * @param convar		Handle to the convar.
   625  * @param type			Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
   626  * @param set			If set to true, convar will use specified bound. If false, bound will be removed.
   627  * @param value			Floating point value to use as the specified bound.
   628  * @noreturn
   629  * @error				Invalid or corrupt Handle.
   630  */
   631 native SetConVarBounds(Handle:convar, ConVarBounds:type, bool:set, Float:value=0.0);
   632 
   633 /**
   634  * Retrieves the name of a console variable.
   635  *
   636  * @param convar		Handle to the convar.
   637  * @param value			Buffer to store the name of the convar.
   638  * @param maxlength		Maximum length of string buffer.
   639  * @noreturn
   640  * @error				Invalid or corrupt Handle.     
   641  */
   642 native GetConVarName(Handle:convar, const String:name[], maxlength);
   643 
   644 funcenum ConVarQueryFinished
   645 {	
   646 	/**
   647 	 * Called when a query to retrieve a client's console variable has finished.
   648 	 *
   649 	 * @param cookie		Unique identifier of query.
   650 	 * @param client		Player index.
   651 	 * @param result		Result of query that tells one whether or not query was successful.
   652 	 *						See ConVarQueryResult enum for more details.
   653 	 * @param convarName	Name of client convar that was queried.
   654 	 * @param convarValue	Value of client convar that was queried if successful. This will be "" if it was not.
   655 	 * @param value			Value that was passed when query was started.
   656 	 * @noreturn
   657 	 */
   658 	public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[], any:value),
   659 	
   660 	/**
   661 	 * Called when a query to retrieve a client's console variable has finished.
   662 	 *
   663 	 * @param cookie		Unique identifier of query.
   664 	 * @param client		Player index.
   665 	 * @param result		Result of query that tells one whether or not query was successful.
   666 	 *						See ConVarQueryResult enum for more details.
   667 	 * @param convarName	Name of client convar that was queried.
   668 	 * @param convarValue	Value of client convar that was queried if successful. This will be "" if it was not.
   669 	 * @noreturn
   670 	 */
   671 	public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
   672 };
   673 
   674 /**
   675  * Starts a query to retrieve the value of a client's console variable.
   676  *
   677  * @param client		Player index.
   678  * @param name			Name of client convar to query.
   679  * @param callback		A function to use as a callback when the query has finished.
   680  * @param value			Optional value to pass to the callback function.
   681  * @return				A cookie that uniquely identifies the query. 
   682  *						Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
   683  */
   684 native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);
   685 
   686 /**
   687  * Gets a command iterator.  Must be freed with CloseHandle().
   688  *
   689  * @return				A new command iterator.
   690  */
   691 native Handle:GetCommandIterator();
   692 
   693 /**
   694  * Reads a command iterator, then advances to the next command if any.
   695  * Only SourceMod specific commands are returned.
   696  *
   697  * @param iter			Command iterator Handle.
   698  * @param name			Name buffer.
   699  * @param nameLen		Name buffer size.
   700  * @param eflags		Effective default flags of a command.
   701  * @param desc			Command description buffer.
   702  * @param descLen		Command description buffer size.
   703  * @return				True on success, false if there are no more commands.
   704  */
   705 native bool:ReadCommandIterator(Handle:iter, 
   706 								String:name[], 
   707 								nameLen, 
   708 								&eflags=0, 
   709 								String:desc[]="", 
   710 								descLen=0);
   711 
   712 /**
   713  * Returns whether a client has access to a given command string.  The string 
   714  * can also be any override string, as overrides can be independent of 
   715  * commands.  This important feature essentially allows you to create custom 
   716  * flags using the override system.
   717  *
   718  * @param client		Client index.
   719  * @param command		Command name.  If the command is not found, the default 
   720  *						flags are used.
   721  * @param flags			Flag string to use as a default, if the command or override 
   722  *						is not found.
   723  * @param override_only	If true, SourceMod will not attempt to find a matching 
   724  *						command, and it will only use the default flags specified.
   725  *						Otherwise, SourceMod will ignore the default flags if 
   726  *						there is a matching admin command.
   727  * @return				True if the client has access, false otherwise.
   728  */
   729 native bool:CheckCommandAccess(client, 
   730 							   const String:command[],
   731 							   flags,
   732 							   bool:override_only=false);
   733 
   734 /**
   735  * Returns true if the supplied character is valid in a ConVar name.
   736  *
   737  * @param c			Character to validate.
   738  * @return			True is valid for ConVars, false otherwise
   739  */
   740 stock bool:IsValidConVarChar(c)
   741 {
   742 	return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
   743 }
   744 
   745 /**
   746  * Returns the bitstring of flags of a command.
   747  *
   748  * @param name		Name of the command.
   749  * @return			A bitstring containing the FCVAR_* flags that are enabled 
   750  *					or INVALID_FCVAR_FLAGS if command not found.
   751  */
   752 native GetCommandFlags(const String:name[]);
   753 
   754 /**
   755  * Sets the bitstring of flags of a command.
   756  *
   757  * @param name		Name of the command.
   758  * @param flags		A bitstring containing the FCVAR_* flags to enable.
   759  * @return			True on success, otherwise false.
   760  */
   761 native bool:SetCommandFlags(const String:name[], flags);
   762 
   763 /**
   764  * Starts a ConCommandBase search, traversing the list of ConVars and 
   765  * ConCommands.  If a Handle is returned, the next entry must be read 
   766  * via FindNextConCommand().  The order of the list is undefined.
   767  *
   768  * @param buffer		Buffer to store entry name.
   769  * @param max_size		Maximum size of the buffer.
   770  * @param isCommand		Variable to store whether the entry is a command. 
   771  *						If it is not a command, it is a ConVar.
   772  * @param flags			Variable to store entry flags.
   773  * @param description		Buffer to store the description, empty if no description present.
   774  * @param descrmax_size		Maximum size of the description buffer.
   775  * @return				On success, a ConCmdIter Handle is returned, which 
   776  *						can be read via FindNextConCommand(), and must be 
   777  *						closed via CloseHandle().  Additionally, the output 
   778  *						parameters will be filled with information of the 
   779  *						first ConCommandBase entry.
   780  *						On failure, INVALID_HANDLE is returned, and the 
   781  *						contents of outputs is undefined.
   782  */
   783 native Handle:FindFirstConCommand(String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
   784 
   785 /**
   786  * Reads the next entry in a ConCommandBase iterator.
   787  *
   788  * @param search		ConCmdIter Handle to search.
   789  * @param buffer		Buffer to store entry name.
   790  * @param max_size		Maximum size of the buffer.
   791  * @param isCommand		Variable to store whether the entry is a command.
   792  *						If it is not a command, it is a ConVar.
   793  * @param flags			Variable to store entry flags.
   794  * @param description		Buffer to store the description, empty if no description present.
   795  * @param descrmax_size		Maximum size of the description buffer.
   796  * @return				On success, the outputs are filled, the iterator is 
   797  *						advanced to the next entry, and true is returned.  
   798  *						If no more entries exist, false is returned, and the 
   799  *						contents of outputs is undefined.
   800  */
   801 native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
   802 
   803 /**
   804  * Replicates a convar value to a specific client. This does not change the actual convar value.
   805  *
   806  * @param client		Client index
   807  * @param convar		ConVar handle
   808  * @param value			String value to send
   809  * @return				True on success, false on failure
   810  * @error 				Invalid client index, client not in game, or client is fake
   811  */
   812 native bool:SendConVarValue(client, Handle:convar, const String:value[]);