plugins/include/console.inc
author Nicholas Hastings <skamonkey@gmail.com>
Sun Mar 17 11:39:04 2013 -0400 (2013-03-17)
changeset 3833 7563b32966af
parent 3389 68d3e56f4bb7
child 3967 ceafb87d38a7
permissions -rw-r--r--
Moved PCRE_STATIC def in Regex ext to extension instead of modifying pcre header (bug 5593).
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
/**
asherkin@3361
   125
 * Executes a server command as if it were on the server console (or RCON) 
asherkin@3361
   126
 * and stores the printed text into buffer.
asherkin@3361
   127
 *
asherkin@3361
   128
 * Warning: This calls ServerExecute internally and may have issues if
asherkin@3361
   129
 * certain commands are in the buffer, only use when you really need
asherkin@3361
   130
 * the response.
asherkin@3361
   131
 * Also, on L4D2 this will not print the command output to the server console.
asherkin@3361
   132
 *
asherkin@3361
   133
 * @param buffer		String to store command result into.
asherkin@3361
   134
 * @param maxlen		Length of buffer.
asherkin@3361
   135
 * @param format		Formatting rules.
asherkin@3361
   136
 * @param ...			Variable number of format parameters.
asherkin@3361
   137
 * @noreturn
asherkin@3361
   138
 */
asherkin@3361
   139
native ServerCommandEx(String:buffer[], maxlen, const String:format[], any:...);
asherkin@3361
   140
asherkin@3361
   141
/**
dvander@522
   142
 * Inserts a server command at the beginning of the server command buffer.
dvander@522
   143
 *
dvander@522
   144
 * @param format		Formatting rules.
dvander@522
   145
 * @param ...			Variable number of format parameters.
dvander@522
   146
 * @noreturn
dvander@522
   147
 */
ds@634
   148
native InsertServerCommand(const String:format[], any:...);
dvander@522
   149
dvander@522
   150
/**
dvander@522
   151
 * Executes every command in the server's command buffer, rather than once per frame.
dvander@522
   152
 *
dvander@522
   153
 * @noreturn
dvander@522
   154
 */
dvander@522
   155
native ServerExecute();
dvander@480
   156
dvander@480
   157
/**
dvander@532
   158
 * Executes a client command.  Note that this will not work on clients unless
dvander@532
   159
 * they have cl_restrict_server_commands set to 0.
dvander@532
   160
 *
dvander@532
   161
 * @param client		Index of the client.
dvander@532
   162
 * @param fmt			Format of the client command.
dvander@532
   163
 * @param ...			Format parameters/
dvander@532
   164
 * @noreturn
dvander@532
   165
 * @error				Invalid client index, or client not connected.
dvander@532
   166
 */
ds@634
   167
native ClientCommand(client, const String:fmt[], any:...);
dvander@532
   168
dvander@532
   169
/**
ds@899
   170
 * Executes a client command on the server without being networked.
ds@899
   171
 *
dvander@1338
   172
 * FakeClientCommand() overwrites the command tokenization buffer.  This can 
dvander@1338
   173
 * cause undesired effects because future calls to GetCmdArg* will return 
dvander@1338
   174
 * data from the FakeClientCommand(), not the parent command.  If you are in 
dvander@1338
   175
 * a hook where this matters (for example, a "say" hook), you should use 
dvander@1338
   176
 * FakeClientCommandEx() instead.
dvander@1338
   177
 *
ds@899
   178
 * @param client		Index of the client.
ds@899
   179
 * @param fmt			Format of the client command.
ds@899
   180
 * @param ...			Format parameters
ds@899
   181
 * @noreturn
ds@899
   182
 * @error				Invalid client index, or client not connected.
ds@899
   183
 */
ds@899
   184
native FakeClientCommand(client, const String:fmt[], any:...);
ds@899
   185
ds@899
   186
/**
dvander@1338
   187
 * Executes a client command on the server without being networked.  The 
dvander@1338
   188
 * execution of the client command is delayed by one frame to prevent any 
dvander@1338
   189
 * re-entrancy issues that might surface with FakeClientCommand().
dvander@1338
   190
 *
dvander@1338
   191
 * @param client		Index of the client.
dvander@1338
   192
 * @param fmt			Format of the client command.
dvander@1338
   193
 * @param ...			Format parameters
dvander@1338
   194
 * @noreturn
dvander@1338
   195
 * @error				Invalid client index, or client not connected.
dvander@1338
   196
 */
dvander@1338
   197
native FakeClientCommandEx(client, const String:fmt[], any:...);
dvander@1338
   198
dvander@1338
   199
/**
dvander@480
   200
 * Sends a message to the server console.
dvander@480
   201
 *
dvander@480
   202
 * @param format		Formatting rules.
dvander@480
   203
 * @param ...			Variable number of format parameters.
dvander@480
   204
 * @noreturn
dvander@480
   205
 */
ds@634
   206
native PrintToServer(const String:format[], any:...);
dvander@480
   207
dvander@480
   208
/**
dvander@480
   209
 * Sends a message to a client's console.
dvander@480
   210
 *
dvander@893
   211
 * @param client		Client index.
dvander@480
   212
 * @param format		Formatting rules.
dvander@480
   213
 * @param ...			Variable number of format parameters.
dvander@480
   214
 * @noreturn
ds@873
   215
 * @error				If the client is not connected an error will be thrown.
dvander@480
   216
 */
ds@634
   217
native PrintToConsole(client, const String:format[], any:...);
dvander@480
   218
ds@457
   219
/**
dvander@893
   220
 * Reples to a message in a command.
dvander@893
   221
 *
dvander@893
   222
 * A client index of 0 will use PrintToServer().
dvander@893
   223
 * If the command was from the console, PrintToConsole() is used.
dvander@893
   224
 * If the command was from chat, PrintToChat() is used.
dvander@893
   225
 *
dvander@893
   226
 * @param client		Client index, or 0 for server.
dvander@893
   227
 * @param format		Formatting rules.
dvander@893
   228
 * @param ...			Variable number of format parameters.
dvander@893
   229
 * @noreturn
dvander@893
   230
 * @error				If the client is not connected or invalid.
dvander@893
   231
 */
dvander@910
   232
native ReplyToCommand(client, const String:format[], any:...);
dvander@910
   233
dvander@910
   234
/**
dvander@923
   235
 * Returns the current reply source of a command.
dvander@923
   236
 *
dvander@923
   237
 * @return				ReplySource value.
dvander@923
   238
 */
dvander@923
   239
native ReplySource:GetCmdReplySource();
dvander@923
   240
dvander@923
   241
/**
dvander@1071
   242
 * Sets the current reply source of a command.
dvander@1071
   243
 *
dvander@1071
   244
 * Only use this if you know what you are doing.  You should save the old value
dvander@1071
   245
 * and restore it once you are done.
dvander@1071
   246
 *
dvander@1071
   247
 * @param source		New ReplySource value.
dvander@1071
   248
 * @return				Old ReplySource value.
dvander@1071
   249
 */
dvander@1071
   250
native ReplySource:SetCmdReplySource(ReplySource:source);
dvander@1071
   251
dvander@1071
   252
/**
dvander@1469
   253
 * Returns whether the current say hook is a chat trigger.
dvander@1469
   254
 *
dvander@1469
   255
 * This function is only meaningful inside say or say_team hooks.
dvander@1469
   256
 *
dvander@1469
   257
 * @return				True if a chat trigger, false otherwise.
dvander@1469
   258
 */
dvander@1469
   259
native bool:IsChatTrigger();
dvander@1469
   260
dvander@1469
   261
/**
dvander@910
   262
 * Displays usage of an admin command to users depending on the 
dvander@1623
   263
 * setting of the sm_show_activity cvar.  All users receive a message 
dvander@1623
   264
 * in their chat text, except for the originating client, who receives 
dvander@1623
   265
 * the message based on the current ReplySource.
dvander@1621
   266
 *
dvander@1623
   267
 * @param client		Client index doing the action, or 0 for server.
dvander@1624
   268
 * @param tag			Tag to prepend to the message.
dvander@1623
   269
 * @param format		Formatting rules.
dvander@1623
   270
 * @param ...			Variable number of format parameters.
dvander@1623
   271
 * @noreturn
dvander@1623
   272
 * @error
dvander@1623
   273
 */
dvander@1623
   274
native ShowActivity2(client, const String:tag[], const String:format[], any:...);
dvander@1623
   275
dvander@1623
   276
/**
dvander@1623
   277
 * Displays usage of an admin command to users depending on the 
dvander@1623
   278
 * setting of the sm_show_activity cvar.  
dvander@1623
   279
 *
dvander@1623
   280
 * This version does not display a message to the originating client 
dvander@1623
   281
 * if used from chat triggers or menus.  If manual replies are used 
dvander@1623
   282
 * for these cases, then this function will suffice.  Otherwise, 
dvander@1623
   283
 * ShowActivity2() is slightly more useful.
dvander@910
   284
 *
dvander@910
   285
 * @param client		Client index doing the action, or 0 for server.
dvander@910
   286
 * @param format		Formatting rules.
dvander@910
   287
 * @param ...			Variable number of format parameters.
dvander@910
   288
 * @noreturn
dvander@910
   289
 * @error
dvander@910
   290
 */
dvander@910
   291
native ShowActivity(client, const String:format[], any:...);
dvander@893
   292
dvander@893
   293
/**
dvander@1104
   294
 * Same as ShowActivity(), except the tag parameter is used instead of
dvander@1104
   295
 * "[SM] " (note that you must supply any spacing).
dvander@1104
   296
 *
dvander@1104
   297
 * @param client		Client index doing the action, or 0 for server.
dvander@1104
   298
 * @param tag			Tag to display with.
dvander@1104
   299
 * @param format		Formatting rules.
dvander@1104
   300
 * @param ...			Variable number of format parameters.
dvander@1104
   301
 * @noreturn
dvander@1104
   302
 * @error
dvander@1104
   303
 */
dvander@1104
   304
native ShowActivityEx(client, const String:tag[], const String:format[], any:...);
dvander@1104
   305
dvander@1104
   306
/**
dvander@2318
   307
 * Given an originating client and a target client, returns the string 
dvander@2318
   308
 * that describes the originating client according to the sm_show_activity cvar.
dvander@2318
   309
 *
dvander@2318
   310
 * For example, "ADMIN", "PLAYER", or a player's name could be placed in this buffer.
dvander@2318
   311
 *
dvander@2318
   312
 * @param client        Originating client; may be 0 for server console.
dvander@2318
   313
 * @param target        Targeted client.
dvander@2318
   314
 * @param namebuf       Name buffer.
dvander@2318
   315
 * @param maxlength     Maximum size of the name buffer.
dvander@2318
   316
 * @return              True if activity should be shown.  False otherwise.  In either 
dvander@2318
   317
 *                      case, the name buffer is filled.  The return value can be used 
dvander@2318
   318
 *                      to broadcast a "safe" name to all players regardless of the 
dvander@2318
   319
 *                      sm_show_activity filters.
dvander@2318
   320
 * @error               Invalid client index or client not connected.
dvander@2318
   321
 */
dvander@2318
   322
native FormatActivitySource(client, target, const String:namebuf[], maxlength);
dvander@2318
   323
dvander@2318
   324
/**
dvander@498
   325
 * Called when a server-only command is invoked.  
dvander@498
   326
 *
dvander@520
   327
 * @params args			Number of arguments that were in the argument string.
dvander@708
   328
 * @return				An Action value.  Not handling the command
dvander@498
   329
 *						means that Source will report it as "not found."
dvander@498
   330
 */
dvander@2317
   331
functag public Action:SrvCmd(args);
dvander@498
   332
dvander@498
   333
/**
dvander@498
   334
 * Creates a server-only console command, or hooks an already existing one.  
dvander@498
   335
 *
dvander@2245
   336
 * Server commands are case sensitive.
dvander@2245
   337
 *
dvander@498
   338
 * @param cmd			Name of the command to hook or create.
dvander@498
   339
 * @param callback		A function to use as a callback for when the command is invoked.
dvander@498
   340
 * @param description	Optional description to use for command creation.
dvander@498
   341
 * @param flags			Optional flags to use for command creation.
dvander@498
   342
 * @noreturn
ds@579
   343
 * @error				Command name is the same as an existing convar.
dvander@498
   344
 */
dvander@498
   345
native RegServerCmd(const String:cmd[], SrvCmd:callback, const String:description[]="", flags=0);
dvander@498
   346
dvander@498
   347
/**
dvander@498
   348
 * Called when a generic console command is invoked.
dvander@498
   349
 *
dvander@498
   350
 * @param client		Index of the client, or 0 from the server.
dvander@520
   351
 * @param args			Number of arguments that were in the argument string.
dvander@708
   352
 * @return				An Action value.  Not handling the command
dvander@498
   353
 *						means that Source will report it as "not found."
dvander@498
   354
 */
dvander@2317
   355
functag public Action:ConCmd(client, args);
dvander@498
   356
dvander@498
   357
/**
dvander@498
   358
 * Creates a console command, or hooks an already existing one.
dvander@498
   359
 *
dvander@2245
   360
 * Console commands are case sensitive.  However, if the command already exists in the game, 
dvander@2245
   361
 * the a client may enter the command in any case.  SourceMod corrects for this automatically, 
dvander@2245
   362
 * and you should only hook the "real" version of the command.
dvander@2245
   363
 *
dvander@498
   364
 * @param cmd			Name of the command to hook or create.
dvander@498
   365
 * @param callback		A function to use as a callback for when the command is invoked.
dvander@498
   366
 * @param description	Optional description to use for command creation.
dvander@498
   367
 * @param flags			Optional flags to use for command creation.
dvander@498
   368
 * @noreturn
ds@579
   369
 * @error				Command name is the same as an existing convar.
dvander@498
   370
 */
dvander@498
   371
native RegConsoleCmd(const String:cmd[], ConCmd:callback, const String:description[]="", flags=0);
dvander@498
   372
dvander@498
   373
/**
dvander@498
   374
 * Creates a console command as an administrative command.  If the command does not exist,
dvander@520
   375
 * it is created.  When this command is invoked, the access rights of the player are 
dvander@520
   376
 * automatically checked before allowing it to continue.
dvander@498
   377
 *
dvander@2245
   378
 * Admin commands are case sensitive from both the client and server.
dvander@2245
   379
 *
dvander@498
   380
 * @param cmd			String containing command to register.
dvander@498
   381
 * @param callback		A function to use as a callback for when the command is invoked.
dvander@498
   382
 * @param adminflags	Administrative flags (bitstring) to use for permissions.
pred@2082
   383
 * @param description	Optional description to use for help.
dvander@498
   384
 * @param group			String containing the command group to use.  If empty,
dvander@498
   385
 * 						the plugin's filename will be used instead.
dvander@498
   386
 * @param flags			Optional console flags.
dvander@498
   387
 * @noreturn
ds@579
   388
 * @error				Command name is the same as an existing convar.
dvander@498
   389
 */
dvander@514
   390
native RegAdminCmd(const String:cmd[],
dvander@514
   391
					ConCmd:callback,
dvander@514
   392
					adminflags,
dvander@514
   393
					const String:description[]="",
dvander@514
   394
					const String:group[]="",
dvander@514
   395
					flags=0);
dvander@517
   396
					
dvander@517
   397
/**
dvander@517
   398
 * Returns the number of arguments from the current console or server command.
dvander@517
   399
 * @note Unlike the HL2 engine call, this does not include the command itself.
dvander@517
   400
 *
dvander@517
   401
 * @return				Number of arguments to the current command.
dvander@517
   402
 */
dvander@517
   403
native GetCmdArgs();
dvander@517
   404
dvander@517
   405
/**
dvander@517
   406
 * Retrieves a command argument given its index, from the current console or 
dvander@517
   407
 * server command.
dvander@517
   408
 * @note Argument indexes start at 1; 0 retrieves the command name.
dvander@517
   409
 *
dvander@517
   410
 * @param argnum		Argument number to retrieve.
dvander@517
   411
 * @param buffer		Buffer to use for storing the string.
dvander@517
   412
 * @param maxlength		Maximum length of the buffer.
dvander@1421
   413
 * @return				Length of string written to buffer.
dvander@517
   414
 */
dvander@517
   415
native GetCmdArg(argnum, String:buffer[], maxlength);
dvander@517
   416
dvander@517
   417
/**
dvander@517
   418
 * Retrieves the entire command argument string in one lump from the current 
dvander@517
   419
 * console or server command.
dvander@517
   420
 *
dvander@517
   421
 * @param buffer		Buffer to use for storing the string.
dvander@517
   422
 * @param maxlength		Maximum length of the buffer.
dvander@1421
   423
 * @return				Length of string written to buffer.
dvander@517
   424
 */
dvander@517
   425
native GetCmdArgString(String:buffer[], maxlength);
dvander@498
   426
dvander@498
   427
/**
ds@457
   428
 * Creates a new console variable.
ds@457
   429
 *
ds@475
   430
 * @param name			Name of new convar.
ds@475
   431
 * @param defaultValue	String containing the default value of new convar.
ds@582
   432
 * @param description	Optional description of the convar.
ds@576
   433
 * @param flags			Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
ds@475
   434
 * @param hasMin		Optional boolean that determines if the convar has a minimum value.
ds@475
   435
 * @param min			Minimum floating point value that the convar can have if hasMin is true.
ds@475
   436
 * @param hasMax		Optional boolean that determines if the convar has a maximum value.
ds@475
   437
 * @param max			Maximum floating point value that the convar can have if hasMax is true.
ds@1961
   438
 * @return				A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
ds@579
   439
 * @error				Convar name is blank or is the same as an existing console command.
ds@457
   440
 */
ds@582
   441
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
   442
ds@457
   443
/**
ds@457
   444
 * Searches for a console variable.
ds@457
   445
 *
ds@475
   446
 * @param name			Name of convar to find.
ds@475
   447
 * @return				A handle to the convar if it is found. INVALID_HANDLE otherwise.
ds@457
   448
 */
ds@457
   449
native Handle:FindConVar(const String:name[]);
ds@457
   450
ds@457
   451
/**
ds@465
   452
 * Called when a console variable's value is changed.
ds@465
   453
 *
ds@475
   454
 * @param convar		Handle to the convar that was changed.
ds@475
   455
 * @param oldValue		String containing the value of the convar before it was changed.
ds@475
   456
 * @param newValue		String containing the new value of the convar.
ds@465
   457
 * @noreturn
ds@465
   458
 */
dvander@2317
   459
functag public ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]);
ds@465
   460
ds@465
   461
/**
ds@465
   462
 * Creates a hook for when a console variable's value is changed.
ds@465
   463
 *
ds@475
   464
 * @param convar		Handle to the convar.
ds@475
   465
 * @param callback		An OnConVarChanged function pointer.
ds@465
   466
 * @noreturn
ds@475
   467
 * @error				Invalid or corrupt Handle or invalid callback function.
ds@465
   468
 */
ds@582
   469
native HookConVarChange(Handle:convar, ConVarChanged:callback);
ds@465
   470
ds@465
   471
/**
ds@465
   472
 * Removes a hook for when a console variable's value is changed.
ds@465
   473
 *
ds@475
   474
 * @param convar		Handle to the convar.
ds@475
   475
 * @param callback		An OnConVarChanged function pointer.
ds@472
   476
 * @noreturn
ds@475
   477
 * @error				Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
ds@465
   478
 */
ds@582
   479
native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
ds@465
   480
ds@465
   481
/**
ds@457
   482
 * Returns the boolean value of a console variable.
ds@457
   483
 *
ds@475
   484
 * @param convar		Handle to the convar.
ds@475
   485
 * @return				The boolean value of the convar.
ds@475
   486
 * @error				Invalid or corrupt Handle.
ds@457
   487
 */
ds@457
   488
native bool:GetConVarBool(Handle:convar);
ds@457
   489
ds@457
   490
/**
ds@457
   491
 * Sets the boolean value of a console variable.
ds@457
   492
 *
ds@3082
   493
 * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
ds@3082
   494
 * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
ds@2396
   495
 *
ds@475
   496
 * @param convar		Handle to the convar.
ds@475
   497
 * @param value			New boolean value.
ds@936
   498
 * @param replicate		If set to true, the new convar value will be set on all clients.
ds@936
   499
 *						This will only work if the convar has the FCVAR_REPLICATED flag
ds@936
   500
 *						and actually exists on clients.
ds@936
   501
 * @param notify		If set to true, clients will be notified that the convar has changed.
ds@936
   502
 *						This will only work if the convar has the FCVAR_NOTIFY flag.
ds@457
   503
 * @noreturn
ds@475
   504
 * @error				Invalid or corrupt Handle.
ds@457
   505
 */
ds@936
   506
native SetConVarBool(Handle:convar, bool:value, bool:replicate=false, bool:notify=false);
ds@457
   507
ds@457
   508
/**
ds@457
   509
 * Returns the integer value of a console variable.
ds@457
   510
 *
ds@475
   511
 * @param convar		Handle to the convar.
ds@475
   512
 * @return				The integer value of the convar.
ds@475
   513
 * @error				Invalid or corrupt Handle.
ds@457
   514
 */
ds@457
   515
native GetConVarInt(Handle:convar);
ds@457
   516
ds@457
   517
/**
ds@457
   518
 * Sets the integer value of a console variable.
ds@457
   519
 *
ds@3082
   520
 * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
ds@3082
   521
 * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
ds@2396
   522
 *
ds@475
   523
 * @param convar		Handle to the convar.
ds@475
   524
 * @param value			New integer value.
ds@936
   525
 * @param replicate		If set to true, the new convar value will be set on all clients.
ds@936
   526
 *						This will only work if the convar has the FCVAR_REPLICATED flag
ds@936
   527
 *						and actually exists on clients.
ds@936
   528
 * @param notify		If set to true, clients will be notified that the convar has changed.
ds@936
   529
 *						This will only work if the convar has the FCVAR_NOTIFY flag.
ds@457
   530
 * @noreturn
ds@475
   531
 * @error				Invalid or corrupt Handle.
ds@457
   532
 */
ds@936
   533
native SetConVarInt(Handle:convar, value, bool:replicate=false, bool:notify=false);
ds@457
   534
ds@457
   535
/**
ds@457
   536
 * Returns the floating point value of a console variable.
ds@457
   537
 *
ds@475
   538
 * @param convar		Handle to the convar.
ds@475
   539
 * @return				The floating point value of the convar.
ds@475
   540
 * @error				Invalid or corrupt Handle.
ds@457
   541
 */
ds@457
   542
native Float:GetConVarFloat(Handle:convar);
ds@457
   543
ds@457
   544
/**
ds@457
   545
 * Sets the floating point value of a console variable.
ds@457
   546
 *
ds@3082
   547
 * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
ds@3082
   548
 * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
ds@2396
   549
 *
ds@475
   550
 * @param convar		Handle to the convar.
ds@475
   551
 * @param value			New floating point value.
ds@936
   552
 * @param replicate		If set to true, the new convar value will be set on all clients.
ds@936
   553
 *						This will only work if the convar has the FCVAR_REPLICATED flag
ds@936
   554
 *						and actually exists on clients.
ds@936
   555
 * @param notify		If set to true, clients will be notified that the convar has changed.
ds@936
   556
 *						This will only work if the convar has the FCVAR_NOTIFY flag.
ds@457
   557
 * @noreturn
ds@475
   558
 * @error				Invalid or corrupt Handle.
ds@457
   559
 */
ds@936
   560
native SetConVarFloat(Handle:convar, Float:value, bool:replicate=false, bool:notify=false);
ds@457
   561
ds@457
   562
/**
ds@457
   563
 * Retrieves the string value of a console variable.
ds@457
   564
 *
ds@475
   565
 * @param convar		Handle to the convar.
ds@475
   566
 * @param value			Buffer to store the value of the convar.
ds@475
   567
 * @param maxlength		Maximum length of string buffer.
ds@457
   568
 * @noreturn
ds@475
   569
 * @error				Invalid or corrupt Handle.     
ds@457
   570
 */
ds@465
   571
native GetConVarString(Handle:convar, String:value[], maxlength);
ds@457
   572
ds@457
   573
/**
ds@457
   574
 * Sets the string value of a console variable.
ds@457
   575
 *
ds@3082
   576
 * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
ds@3082
   577
 * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
ds@2396
   578
 *
ds@475
   579
 * @param convar		Handle to the convar.
ds@475
   580
 * @param value			New string value.
ds@936
   581
 * @param replicate		If set to true, the new convar value will be set on all clients.
ds@936
   582
 *						This will only work if the convar has the FCVAR_REPLICATED flag
ds@936
   583
 *						and actually exists on clients.
ds@936
   584
 * @param notify		If set to true, clients will be notified that the convar has changed.
ds@936
   585
 *						This will only work if the convar has the FCVAR_NOTIFY flag.
ds@457
   586
 * @noreturn
ds@475
   587
 * @error				Invalid or corrupt Handle.
ds@457
   588
 */
ds@936
   589
native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
ds@457
   590
ds@457
   591
/**
ds@1301
   592
 * Resets the console variable to its default value.
ds@1301
   593
 *
ds@3082
   594
 * Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
ds@3082
   595
 * Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
ds@2396
   596
 *
ds@1301
   597
 * @param convar		Handle to the convar.
ds@1301
   598
 * @param replicate		If set to true, the new convar value will be set on all clients.
ds@1301
   599
 *						This will only work if the convar has the FCVAR_REPLICATED flag
ds@1301
   600
 *						and actually exists on clients.
ds@1301
   601
 * @param notify		If set to true, clients will be notified that the convar has changed.
ds@1301
   602
 *						This will only work if the convar has the FCVAR_NOTIFY flag.
ds@1301
   603
 * @noreturn
ds@1301
   604
 * @error				Invalid or corrupt Handle.
ds@1301
   605
 */
ds@1301
   606
native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
ds@1301
   607
ds@1301
   608
/**
ds@3071
   609
 * Retrieves the default string value of a console variable.
ds@3071
   610
 *
ds@3071
   611
 * @param convar		Handle to the convar.
ds@3072
   612
 * @param value			Buffer to store the default value of the convar.
ds@3071
   613
 * @param maxlength		Maximum length of string buffer.
ds@3071
   614
 * @return				Number of bytes written to the buffer (UTF-8 safe).
ds@3071
   615
 * @error				Invalid or corrupt Handle.
ds@3071
   616
 */
ds@3072
   617
native GetConVarDefault(Handle:convar, String:value[], maxlength);
ds@3071
   618
ds@3071
   619
/**
ds@457
   620
 * Returns the bitstring of flags on a console variable.
ds@457
   621
 *
ds@475
   622
 * @param convar		Handle to the convar.
ds@475
   623
 * @return				A bitstring containing the FCVAR_* flags that are enabled.
ds@475
   624
 * @error				Invalid or corrupt Handle.
ds@457
   625
 */
ds@457
   626
native GetConVarFlags(Handle:convar);
ds@457
   627
ds@457
   628
/**
ds@457
   629
 * Sets the bitstring of flags on a console variable.
ds@457
   630
 *
ds@475
   631
 * @param convar		Handle to the convar.
ds@475
   632
 * @param flags			A bitstring containing the FCVAR_* flags to enable.
ds@457
   633
 * @noreturn
ds@475
   634
 * @error				Invalid or corrupt Handle.
ds@457
   635
 */
ds@457
   636
native SetConVarFlags(Handle:convar, flags);
ds@457
   637
ds@457
   638
/**
ds@714
   639
 * Retrieves the specified bound of a console variable.
ds@714
   640
 *
ds@714
   641
 * @param convar		Handle to the convar.
ds@714
   642
 * @param type			Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
ds@714
   643
 * @param value			By-reference cell to store the specified floating point bound value.
ds@714
   644
 * @return				True if the convar has the specified bound set, false otherwise.
ds@714
   645
 * @error				Invalid or corrupt Handle.
ds@714
   646
 */
ds@714
   647
native bool:GetConVarBounds(Handle:convar, ConVarBounds:type, &Float:value);
ds@714
   648
ds@714
   649
/**
ds@714
   650
 * Sets the specified bound of a console variable.
ds@714
   651
 *
ds@714
   652
 * @param convar		Handle to the convar.
ds@714
   653
 * @param type			Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
ds@714
   654
 * @param set			If set to true, convar will use specified bound. If false, bound will be removed.
ds@714
   655
 * @param value			Floating point value to use as the specified bound.
ds@714
   656
 * @noreturn
ds@714
   657
 * @error				Invalid or corrupt Handle.
ds@714
   658
 */
ds@714
   659
native SetConVarBounds(Handle:convar, ConVarBounds:type, bool:set, Float:value=0.0);
ds@714
   660
ds@714
   661
/**
ds@465
   662
 * Retrieves the name of a console variable.
ds@465
   663
 *
ds@475
   664
 * @param convar		Handle to the convar.
ds@3080
   665
 * @param name			Buffer to store the name of the convar.
ds@475
   666
 * @param maxlength		Maximum length of string buffer.
ds@465
   667
 * @noreturn
ds@475
   668
 * @error				Invalid or corrupt Handle.     
ds@465
   669
 */
ds@3080
   670
native GetConVarName(Handle:convar, String:name[], maxlength);
ds@465
   671
ds@696
   672
funcenum ConVarQueryFinished
ds@696
   673
{	
ds@696
   674
	/**
ds@696
   675
	 * Called when a query to retrieve a client's console variable has finished.
ds@696
   676
	 *
ds@696
   677
	 * @param cookie		Unique identifier of query.
ds@696
   678
	 * @param client		Player index.
ds@696
   679
	 * @param result		Result of query that tells one whether or not query was successful.
ds@696
   680
	 *						See ConVarQueryResult enum for more details.
ds@696
   681
	 * @param convarName	Name of client convar that was queried.
ds@696
   682
	 * @param convarValue	Value of client convar that was queried if successful. This will be "" if it was not.
ds@696
   683
	 * @param value			Value that was passed when query was started.
ds@696
   684
	 * @noreturn
ds@696
   685
	 */
ds@696
   686
	public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[], any:value),
ds@696
   687
	
ds@696
   688
	/**
ds@696
   689
	 * Called when a query to retrieve a client's console variable has finished.
ds@696
   690
	 *
ds@696
   691
	 * @param cookie		Unique identifier of query.
ds@696
   692
	 * @param client		Player index.
ds@696
   693
	 * @param result		Result of query that tells one whether or not query was successful.
ds@696
   694
	 *						See ConVarQueryResult enum for more details.
ds@696
   695
	 * @param convarName	Name of client convar that was queried.
ds@696
   696
	 * @param convarValue	Value of client convar that was queried if successful. This will be "" if it was not.
ds@696
   697
	 * @noreturn
ds@696
   698
	 */
ds@696
   699
	public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
ds@696
   700
};
ds@696
   701
ds@696
   702
/**
ds@696
   703
 * Starts a query to retrieve the value of a client's console variable.
ds@696
   704
 *
ds@696
   705
 * @param client		Player index.
ds@696
   706
 * @param name			Name of client convar to query.
ds@696
   707
 * @param callback		A function to use as a callback when the query has finished.
ds@696
   708
 * @param value			Optional value to pass to the callback function.
ds@697
   709
 * @return				A cookie that uniquely identifies the query. 
ds@697
   710
 *						Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
ds@696
   711
 */
ds@696
   712
native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);
dvander@1119
   713
dvander@1119
   714
/**
dvander@1119
   715
 * Gets a command iterator.  Must be freed with CloseHandle().
dvander@1119
   716
 *
dvander@1119
   717
 * @return				A new command iterator.
dvander@1119
   718
 */
dvander@1119
   719
native Handle:GetCommandIterator();
dvander@1119
   720
dvander@1119
   721
/**
dvander@1119
   722
 * Reads a command iterator, then advances to the next command if any.
dvander@1119
   723
 * Only SourceMod specific commands are returned.
dvander@1119
   724
 *
dvander@1119
   725
 * @param iter			Command iterator Handle.
dvander@1119
   726
 * @param name			Name buffer.
dvander@1119
   727
 * @param nameLen		Name buffer size.
dvander@1119
   728
 * @param eflags		Effective default flags of a command.
dvander@1119
   729
 * @param desc			Command description buffer.
dvander@1119
   730
 * @param descLen		Command description buffer size.
dvander@1119
   731
 * @return				True on success, false if there are no more commands.
dvander@1119
   732
 */
dvander@1119
   733
native bool:ReadCommandIterator(Handle:iter, 
dvander@1119
   734
								String:name[], 
dvander@1119
   735
								nameLen, 
dvander@1119
   736
								&eflags=0, 
dvander@1119
   737
								String:desc[]="", 
dvander@1119
   738
								descLen=0);
dvander@1119
   739
dvander@1119
   740
/**
dvander@1399
   741
 * Returns whether a client has access to a given command string.  The string 
skamonkey@3389
   742
 * can be any override string, as overrides can be independent of 
skamonkey@3389
   743
 * commands.  This feature essentially allows you to create custom 
dvander@1399
   744
 * flags using the override system.
dvander@1119
   745
 *
dvander@1119
   746
 * @param client		Client index.
dvander@1399
   747
 * @param command		Command name.  If the command is not found, the default 
dvander@1399
   748
 *						flags are used.
dvander@1399
   749
 * @param flags			Flag string to use as a default, if the command or override 
dvander@1399
   750
 *						is not found.
dvander@1399
   751
 * @param override_only	If true, SourceMod will not attempt to find a matching 
dvander@1399
   752
 *						command, and it will only use the default flags specified.
dvander@1399
   753
 *						Otherwise, SourceMod will ignore the default flags if 
dvander@1399
   754
 *						there is a matching admin command.
dvander@1120
   755
 * @return				True if the client has access, false otherwise.
dvander@1119
   756
 */
dvander@1399
   757
native bool:CheckCommandAccess(client, 
dvander@1399
   758
							   const String:command[],
dvander@1399
   759
							   flags,
dvander@1399
   760
							   bool:override_only=false);
ferret99gt@1475
   761
ferret99gt@1475
   762
/**
skamonkey@3389
   763
 * Returns whether an admin has access to a given command string.  The string 
skamonkey@3389
   764
 * can be any override string, as overrides can be independent of 
skamonkey@3389
   765
 * commands.  This feature essentially allows you to create custom flags
skamonkey@3389
   766
 * using the override system.
skamonkey@3389
   767
 *
skamonkey@3389
   768
 * @param id			AdminId of the admin.
skamonkey@3389
   769
 * @param command		Command name.  If the command is not found, the default 
skamonkey@3389
   770
 *						flags are used.
skamonkey@3389
   771
 * @param flags			Flag string to use as a default, if the command or override 
skamonkey@3389
   772
 *						is not found.
skamonkey@3389
   773
 * @param override_only	If true, SourceMod will not attempt to find a matching 
skamonkey@3389
   774
 *						command, and it will only use the default flags specified.
skamonkey@3389
   775
 *						Otherwise, SourceMod will ignore the default flags if 
skamonkey@3389
   776
 *						there is a matching admin command.
skamonkey@3389
   777
 * @return				True if the admin has access, false otherwise.
skamonkey@3389
   778
 */
skamonkey@3389
   779
native bool:CheckAccess(AdminId:id, 
skamonkey@3389
   780
							   const String:command[],
skamonkey@3389
   781
							   flags,
skamonkey@3389
   782
							   bool:override_only=false);
skamonkey@3389
   783
skamonkey@3389
   784
/**
ferret99gt@1475
   785
 * Returns true if the supplied character is valid in a ConVar name.
ferret99gt@1475
   786
 *
ferret99gt@1475
   787
 * @param c			Character to validate.
ferret99gt@1475
   788
 * @return			True is valid for ConVars, false otherwise
ferret99gt@1475
   789
 */
ferret99gt@1475
   790
stock bool:IsValidConVarChar(c)
ferret99gt@1475
   791
{
ferret99gt@1475
   792
	return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
ferret99gt@1475
   793
}
faluco@1643
   794
faluco@1643
   795
/**
faluco@1643
   796
 * Returns the bitstring of flags of a command.
faluco@1643
   797
 *
dvander@1792
   798
 * @param name		Name of the command.
dvander@1792
   799
 * @return			A bitstring containing the FCVAR_* flags that are enabled 
dvander@1792
   800
 *					or INVALID_FCVAR_FLAGS if command not found.
faluco@1643
   801
 */
faluco@1643
   802
native GetCommandFlags(const String:name[]);
faluco@1643
   803
faluco@1643
   804
/**
faluco@1643
   805
 * Sets the bitstring of flags of a command.
faluco@1643
   806
 *
dvander@1792
   807
 * @param name		Name of the command.
dvander@1792
   808
 * @param flags		A bitstring containing the FCVAR_* flags to enable.
faluco@1643
   809
 * @return			True on success, otherwise false.
faluco@1643
   810
 */
faluco@1643
   811
native bool:SetCommandFlags(const String:name[], flags);
dvander@1795
   812
dvander@1795
   813
/**
dvander@1795
   814
 * Starts a ConCommandBase search, traversing the list of ConVars and 
dvander@1795
   815
 * ConCommands.  If a Handle is returned, the next entry must be read 
dvander@1795
   816
 * via FindNextConCommand().  The order of the list is undefined.
dvander@1795
   817
 *
dvander@1795
   818
 * @param buffer		Buffer to store entry name.
dvander@1795
   819
 * @param max_size		Maximum size of the buffer.
dvander@1795
   820
 * @param isCommand		Variable to store whether the entry is a command. 
dvander@1795
   821
 *						If it is not a command, it is a ConVar.
dvander@1795
   822
 * @param flags			Variable to store entry flags.
faluco@1893
   823
 * @param description		Buffer to store the description, empty if no description present.
faluco@1893
   824
 * @param descrmax_size		Maximum size of the description buffer.
dvander@1795
   825
 * @return				On success, a ConCmdIter Handle is returned, which 
dvander@1795
   826
 *						can be read via FindNextConCommand(), and must be 
dvander@1795
   827
 *						closed via CloseHandle().  Additionally, the output 
dvander@1795
   828
 *						parameters will be filled with information of the 
dvander@1795
   829
 *						first ConCommandBase entry.
dvander@1795
   830
 *						On failure, INVALID_HANDLE is returned, and the 
dvander@1795
   831
 *						contents of outputs is undefined.
dvander@1795
   832
 */
faluco@1893
   833
native Handle:FindFirstConCommand(String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
dvander@1795
   834
dvander@1795
   835
/**
dvander@1795
   836
 * Reads the next entry in a ConCommandBase iterator.
dvander@1795
   837
 *
dvander@1795
   838
 * @param search		ConCmdIter Handle to search.
dvander@1795
   839
 * @param buffer		Buffer to store entry name.
dvander@1795
   840
 * @param max_size		Maximum size of the buffer.
dvander@1795
   841
 * @param isCommand		Variable to store whether the entry is a command.
dvander@1795
   842
 *						If it is not a command, it is a ConVar.
dvander@1795
   843
 * @param flags			Variable to store entry flags.
faluco@1893
   844
 * @param description		Buffer to store the description, empty if no description present.
faluco@1893
   845
 * @param descrmax_size		Maximum size of the description buffer.
dvander@1795
   846
 * @return				On success, the outputs are filled, the iterator is 
dvander@1795
   847
 *						advanced to the next entry, and true is returned.  
dvander@1795
   848
 *						If no more entries exist, false is returned, and the 
dvander@1795
   849
 *						contents of outputs is undefined.
dvander@1795
   850
 */
faluco@1893
   851
native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
pred@1852
   852
pred@1852
   853
/**
pred@1852
   854
 * Replicates a convar value to a specific client. This does not change the actual convar value.
pred@1852
   855
 *
pred@1852
   856
 * @param client		Client index
pred@1852
   857
 * @param convar		ConVar handle
pred@1852
   858
 * @param value			String value to send
pred@1852
   859
 * @return				True on success, false on failure
pred@1852
   860
 * @error 				Invalid client index, client not in game, or client is fake
pred@1852
   861
 */
pred@1852
   862
native bool:SendConVarValue(client, Handle:convar, const String:value[]);
pred@2648
   863
pred@2648
   864
/**
dvander@2684
   865
 * Adds an informational string to the server's public "tags".
dvander@2684
   866
 * This string should be a short, unique identifier.
pred@2648
   867
 *
dvander@2684
   868
 * Note: Tags are automatically removed when a plugin unloads.
dvander@2684
   869
 * Note: Currently, this function does nothing because of bugs in the Valve master.
pred@2648
   870
 *
pred@2648
   871
 * @param tag			Tag string to append.
pred@2648
   872
 * @noreturn
pred@2648
   873
 */
pred@2648
   874
native AddServerTag(const String:tag[]);
pred@2648
   875
pred@2648
   876
/**
dvander@2684
   877
 * Removes a tag previously added by the calling plugin.
pred@2648
   878
 *
pred@2648
   879
 * @param tag			Tag string to remove.
pred@2648
   880
 * @noreturn
pred@2648
   881
 */
pred@2648
   882
native RemoveServerTag(const String:tag[]);
dvander@2806
   883
dvander@2806
   884
/**
dvander@2806
   885
 * Callback for command listeners. This is invoked whenever any command
dvander@2806
   886
 * reaches the server, from the server console itself or a player.
dn@3048
   887
 *
dn@3048
   888
 * Clients may be in the process of connecting when they are executing commands
dn@3048
   889
 * IsClientConnected(client) is not guaranteed to return true.  Other functions
dn@3048
   890
 * such as GetClientIP() may not work at this point either.
dn@3048
   891
 *
dvander@2806
   892
 * Returning Plugin_Handled or Plugin_Stop will prevent the original,
dvander@2806
   893
 * baseline code from running.
dvander@2806
   894
 *
dvander@2806
   895
 * -- TEXT BELOW IS IMPLEMENTATION, AND NOT GUARANTEED --
dvander@2806
   896
 * Even if returning Plugin_Handled or Plugin_Stop, some callbacks will still
dvander@2806
   897
 * trigger. These are:
dvander@2806
   898
 *  * C++ command dispatch hooks from Metamod:Source plugins
dvander@2806
   899
 *  * Reg*Cmd() hooks that did not create new commands.
dvander@2806
   900
 *
dn@3048
   901
 * @param client        Client, or 0 for server.
dn@3048
   902
 *                      Client may not be connected or in game.
dvander@2806
   903
 * @param command       Command name, lower case. To get name as typed, use
dvander@2806
   904
 *                      GetCmdArg() and specify argument 0.
dvander@2806
   905
 * @param argc          Argument count.
dvander@2806
   906
 * @return				Action to take (see extended notes above).
dvander@2806
   907
 */
dvander@2806
   908
functag public Action:CommandListener(client, const String:command[], argc);
dvander@2806
   909
dvander@2841
   910
#define FEATURECAP_COMMANDLISTENER  "command listener"
dvander@2841
   911
dvander@2806
   912
/**
dvander@2806
   913
 * Adds a callback that will fire when a command is sent to the server.
dvander@2806
   914
 *
dvander@2806
   915
 * Registering commands is designed to create a new command as part of the UI,
dvander@2806
   916
 * whereas this is a lightweight hook on a command string, existing or not.
dvander@2806
   917
 * Using Reg*Cmd to intercept is in poor practice, as it physically creates a
dvander@2806
   918
 * new command and can slow down dispatch in general.
dvander@2806
   919
 *
dvander@2841
   920
 * To see if this feature is available, use FeatureType_Capability and 
dvander@2841
   921
 * FEATURECAP_COMMANDLISTENER.
dvander@2841
   922
 *
dvander@2806
   923
 * @param callback      Callback.
dvander@2806
   924
 * @param command		Command, or if not specified, a global listener.
dvander@2806
   925
 *                      The command is case insensitive.
dvander@2806
   926
 * @return              True if this feature is available on the current game,
dvander@2806
   927
 *                      false otherwise.
dvander@2806
   928
 */
dvander@2806
   929
native bool:AddCommandListener(CommandListener:callback, const String:command[]="");
dvander@2806
   930
dvander@2806
   931
/**
dvander@2806
   932
 * Removes a previously added command listener, in reverse order of being added.
dvander@2806
   933
 *
dvander@2806
   934
 * @param callback		Callback.
dvander@2806
   935
 * @param command		Command, or if not specified, a global listener.
dvander@2806
   936
 *                      The command is case insensitive.
dvander@2806
   937
 * @error				Callback has no active listeners.
dvander@2806
   938
 */
dvander@2806
   939
native RemoveCommandListener(CommandListener:callback, const String:command[]="");
dvander@2806
   940