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