plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Fri Jul 11 06:51:21 2008 +0000 (2008-07-11)
branchrefac-jit
changeset 2192 7602d7fb60d9
parent 2168 c24a6fa957db
permissions -rw-r--r--
fixed a compat regression, forgot msvc does funky things with overloaded virtual calls
dvander@2168
     1
/**
dvander@2168
     2
 * vim: set ts=4 :
dvander@2168
     3
 * =============================================================================
dvander@2168
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
dvander@2168
     5
 * =============================================================================
dvander@2168
     6
 *
dvander@2168
     7
 * This file is part of the SourceMod/SourcePawn SDK.
dvander@2168
     8
 *
dvander@2168
     9
 * This program is free software; you can redistribute it and/or modify it under
dvander@2168
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
dvander@2168
    11
 * Free Software Foundation.
dvander@2168
    12
 * 
dvander@2168
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@2168
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@2168
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dvander@2168
    16
 * details.
dvander@2168
    17
 *
dvander@2168
    18
 * You should have received a copy of the GNU General Public License along with
dvander@2168
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@2168
    20
 *
dvander@2168
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
dvander@2168
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@2168
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@2168
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
dvander@2168
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
dvander@2168
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
dvander@2168
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@2168
    28
 * or <http://www.sourcemod.net/license.php>.
dvander@2168
    29
 *
dvander@2168
    30
 * Version: $Id$
dvander@2168
    31
 */
dvander@2168
    32
dvander@2168
    33
#if defined _sourcemod_included
dvander@2168
    34
 #endinput
dvander@2168
    35
#endif
dvander@2168
    36
#define _sourcemod_included
dvander@2168
    37
dvander@2168
    38
/**
dvander@2168
    39
 * Plugin public information.
dvander@2168
    40
 */
dvander@2168
    41
struct Plugin
dvander@2168
    42
{
dvander@2168
    43
   const String:name[],			/**< Plugin Name */
dvander@2168
    44
   const String:description[],	/**< Plugin Description */
dvander@2168
    45
   const String:author[],		/**< Plugin Author */
dvander@2168
    46
   const String:version[],		/**< Plugin Version */
dvander@2168
    47
   const String:url[],			/**< Plugin URL */
dvander@2168
    48
};
dvander@2168
    49
dvander@2168
    50
#include <core>
dvander@2168
    51
#include <float>
dvander@2168
    52
#include <vector>
dvander@2168
    53
#include <string>
dvander@2168
    54
#include <handles>
dvander@2168
    55
#include <functions>
dvander@2168
    56
#include <files>
dvander@2168
    57
#include <logging>
dvander@2168
    58
#include <timers>
dvander@2168
    59
#include <admin>
dvander@2168
    60
#include <dbi>
dvander@2168
    61
#include <lang>
dvander@2168
    62
#include <sorting>
dvander@2168
    63
#include <textparse>
dvander@2168
    64
#include <clients>
dvander@2168
    65
#include <console>
dvander@2168
    66
#include <events>
dvander@2168
    67
#include <bitbuffer>
dvander@2168
    68
#include <usermessages>
dvander@2168
    69
#include <keyvalues>
dvander@2168
    70
#include <menus>
dvander@2168
    71
#include <halflife>
dvander@2168
    72
#include <adt>
dvander@2168
    73
#include <banning>
dvander@2168
    74
#include <commandfilters>
dvander@2168
    75
#include <nextmap>
dvander@2168
    76
dvander@2168
    77
/**
dvander@2168
    78
 * Declare this as a struct in your plugin to expose its information.
dvander@2168
    79
 * Example:
dvander@2168
    80
 *
dvander@2168
    81
 * public Plugin:myinfo =
dvander@2168
    82
 * {
dvander@2168
    83
 *    name = "My Plugin",
dvander@2168
    84
 *    //etc
dvander@2168
    85
 * };
dvander@2168
    86
 */
dvander@2168
    87
public Plugin:myinfo;
dvander@2168
    88
 
dvander@2168
    89
/**
dvander@2168
    90
 * Called when the plugin is fully initialized and all known external references 
dvander@2168
    91
 * are resolved. This is only called once in the lifetime of the plugin, and is 
dvander@2168
    92
 * paired with OnPluginEnd().
dvander@2168
    93
 *
dvander@2168
    94
 * If any run-time error is thrown during this callback, the plugin will be marked 
dvander@2168
    95
 * as failed.
dvander@2168
    96
 *
dvander@2168
    97
 * It is not necessary to close any handles or remove hooks in this function.  
dvander@2168
    98
 * SourceMod guarantees that plugin shutdown automatically and correctly releases 
dvander@2168
    99
 * all resources.
dvander@2168
   100
 *
dvander@2168
   101
 * @noreturn
dvander@2168
   102
 */
dvander@2168
   103
forward OnPluginStart();
dvander@2168
   104
 
dvander@2168
   105
/**
dvander@2168
   106
 * Called before OnPluginStart, in case the plugin wants to check for load failure.
dvander@2168
   107
 * This is called even if the plugin type is "private."  Any natives from modules are 
dvander@2168
   108
 * not available at this point.  Thus, this forward should only be used for explicit 
dvander@2168
   109
 * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
dvander@2168
   110
 * 
dvander@2168
   111
 * @note It is not safe to call externally resolved natives until OnPluginStart().
dvander@2168
   112
 * @note Any sort of RTE in this function will cause the plugin to fail loading.
dvander@2168
   113
 * @note You MUST remember to return SOMETHING here.  The act of not returning is 
dvander@2168
   114
 *       equivalent to returning 0 (false).  If you forgot to return, it will 
dvander@2168
   115
 *       cause your plugin to not load with a very strange error message.
dvander@2168
   116
 *
dvander@2168
   117
 * @param myself	Handle to the plugin.
dvander@2168
   118
 * @param late		Whether or not the plugin was loaded "late" (after map load).
dvander@2168
   119
 * @param error		Error message buffer in case load failed.
dvander@2168
   120
 * @param err_max	Maximum number of characters for error message buffer.
dvander@2168
   121
 * @return			True if load success, false otherwise.
dvander@2168
   122
 */
dvander@2168
   123
forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
dvander@2168
   124
dvander@2168
   125
/**
dvander@2168
   126
 * Called when the plugin is about to be unloaded.
dvander@2168
   127
 *
dvander@2168
   128
 * @noreturn
dvander@2168
   129
 */
dvander@2168
   130
forward OnPluginEnd();
dvander@2168
   131
dvander@2168
   132
/**
dvander@2168
   133
 * Called when the plugin's pause status is changing.
dvander@2168
   134
 *
dvander@2168
   135
 * @param pause			True if the plugin is being paused, false otherwise.
dvander@2168
   136
 * @noreturn
dvander@2168
   137
 */
dvander@2168
   138
forward OnPluginPauseChange(bool:pause);
dvander@2168
   139
dvander@2168
   140
/**
dvander@2168
   141
 * Called before every server frame.  Note that you should avoid
dvander@2168
   142
 * doing expensive computations here, and you should declare large
dvander@2168
   143
 * local arrays using 'decl' instead of 'new'.
dvander@2168
   144
 */
dvander@2168
   145
forward OnGameFrame();
dvander@2168
   146
dvander@2168
   147
/**
dvander@2168
   148
 * Called when the map is loaded.
dvander@2168
   149
 *
dvander@2168
   150
 * @note This used to be OnServerLoad(), which is now deprecated.
dvander@2168
   151
 * Plugins still using the old forward will work.
dvander@2168
   152
 */
dvander@2168
   153
forward OnMapStart();
dvander@2168
   154
dvander@2168
   155
/**
dvander@2168
   156
 * Called right before a map ends.
dvander@2168
   157
 */
dvander@2168
   158
forward OnMapEnd();
dvander@2168
   159
dvander@2168
   160
/**
dvander@2168
   161
 * Called when the map has loaded, servercfgfile (server.cfg) has been 
dvander@2168
   162
 * executed, and all plugin configs are done executing.  This is the best
dvander@2168
   163
 * place to initialize plugin functions which are based on cvar data.  
dvander@2168
   164
 *
dvander@2168
   165
 * @note This will always be called once and only once per map.  It will be 
dvander@2168
   166
 * called after OnMapStart().
dvander@2168
   167
 *
dvander@2168
   168
 * @noreturn
dvander@2168
   169
 */
dvander@2168
   170
forward OnConfigsExecuted();
dvander@2168
   171
dvander@2168
   172
/**
dvander@2168
   173
 * This is called once, right after OnMapStart() but any time before 
dvander@2168
   174
 * OnConfigsExecuted().  It is called after the "exec sourcemod.cfg" 
dvander@2168
   175
 * command and all AutoExecConfig() exec commands have been added to 
dvander@2168
   176
 * the ServerCommand() buffer.
dvander@2168
   177
 *
dvander@2168
   178
 * If you need to load per-map settings that override default values, 
dvander@2168
   179
 * adding commands to the ServerCommand() buffer here will guarantee 
dvander@2168
   180
 * that they're set before OnConfigsExecuted().
dvander@2168
   181
 *
dvander@2168
   182
 * Unlike OnMapStart() and OnConfigsExecuted(), this is not called on 
dvander@2168
   183
 * late loads that occur after OnMapStart().
dvander@2168
   184
 *
dvander@2168
   185
 * @noreturn
dvander@2168
   186
 */
dvander@2168
   187
forward OnAutoConfigsBuffered();
dvander@2168
   188
dvander@2168
   189
/**
dvander@2168
   190
 * @deprecated Use OnConfigsExecuted() instead.
dvander@2168
   191
 */
dvander@2168
   192
#pragma deprecated Use OnConfigsExecuted() instead
dvander@2168
   193
forward OnServerCfg();
dvander@2168
   194
dvander@2168
   195
/**
dvander@2168
   196
 * Called after all plugins have been loaded.  This is called once for 
dvander@2168
   197
 * every plugin.  If a plugin late loads, it will be called immediately 
dvander@2168
   198
 * after OnPluginStart().
dvander@2168
   199
 */
dvander@2168
   200
forward OnAllPluginsLoaded();
dvander@2168
   201
dvander@2168
   202
/**
dvander@2168
   203
 * Returns the calling plugin's Handle.
dvander@2168
   204
 *
dvander@2168
   205
 * @return				Handle of the calling plugin.
dvander@2168
   206
 */
dvander@2168
   207
native Handle:GetMyHandle();
dvander@2168
   208
dvander@2168
   209
/**
dvander@2168
   210
 * Returns an iterator that can be used to search through plugins.
dvander@2168
   211
 *
dvander@2168
   212
 * @return				Handle to iterate with.  Must be closed via 
dvander@2168
   213
 * 						CloseHandle().
dvander@2168
   214
 * @error				Invalid Handle.
dvander@2168
   215
 */
dvander@2168
   216
native Handle:GetPluginIterator();
dvander@2168
   217
dvander@2168
   218
/**
dvander@2168
   219
 * Returns whether there are more plugins available in the iterator.
dvander@2168
   220
 *
dvander@2168
   221
 * @param iter			Handle to the plugin iterator.
dvander@2168
   222
 * @return				True on more plugins, false otherwise.
dvander@2168
   223
 * @error				Invalid Handle.
dvander@2168
   224
 */
dvander@2168
   225
native bool:MorePlugins(Handle:iter);
dvander@2168
   226
dvander@2168
   227
/**
dvander@2168
   228
 * Returns the current plugin in the iterator and advances the iterator.
dvander@2168
   229
 *
dvander@2168
   230
 * @param iter			Handle to the plugin iterator.
dvander@2168
   231
 * @return				Current plugin the iterator is at, before
dvander@2168
   232
 *						the iterator is advanced.
dvander@2168
   233
 * @error				Invalid Handle.
dvander@2168
   234
 */
dvander@2168
   235
native Handle:ReadPlugin(Handle:iter);
dvander@2168
   236
dvander@2168
   237
/**
dvander@2168
   238
 * Returns a plugin's status.
dvander@2168
   239
 *
dvander@2168
   240
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@2168
   241
 * @return				Status code for the plugin.
dvander@2168
   242
 * @error				Invalid Handle.
dvander@2168
   243
 */
dvander@2168
   244
native PluginStatus:GetPluginStatus(Handle:plugin);
dvander@2168
   245
dvander@2168
   246
/**
dvander@2168
   247
 * Retrieves a plugin's file name relative to the plugins folder.
dvander@2168
   248
 *
dvander@2168
   249
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@2168
   250
 * @param buffer		Buffer to the store the file name.
dvander@2168
   251
 * @param maxlength		Maximum length of the name buffer.
dvander@2168
   252
 * @noreturn
dvander@2168
   253
 * @error				Invalid Handle.
dvander@2168
   254
 */
dvander@2168
   255
native GetPluginFilename(Handle:plugin, String:buffer[], maxlength);
dvander@2168
   256
dvander@2168
   257
/**
dvander@2168
   258
 * Retrieves whether or not a plugin is being debugged.
dvander@2168
   259
 *
dvander@2168
   260
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@2168
   261
 * @return				True if being debugged, false otherwise.
dvander@2168
   262
 * @error				Invalid Handle.
dvander@2168
   263
 */
dvander@2168
   264
native bool:IsPluginDebugging(Handle:hndl);
dvander@2168
   265
dvander@2168
   266
/**
dvander@2168
   267
 * Retrieves a plugin's public info.
dvander@2168
   268
 *
dvander@2168
   269
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@2168
   270
 * @param info			Plugin info property to retrieve.
dvander@2168
   271
 * @param buffer		Buffer to store info in.
dvander@2168
   272
 * @param maxlength		Maximum length of buffer.
dvander@2168
   273
 * @return				True on success, false if property is not available.
dvander@2168
   274
 * @error				Invalid Handle.
dvander@2168
   275
 */
dvander@2168
   276
native bool:GetPluginInfo(Handle:plugin, PluginInfo:info, String:buffer[], maxlength);
dvander@2168
   277
dvander@2168
   278
/**
dvander@2168
   279
 * Finds a plugin by its order in the list from the "plugins list" server 
dvander@2168
   280
 * "sm" command.  You should not use this function to loop through all plugins, 
dvander@2168
   281
 * use the iterator instead.  Looping through all plugins using this native 
dvander@2168
   282
 * is O(n^2), whereas using the iterator is O(n).
dvander@2168
   283
 *
dvander@2168
   284
 * @param order_num		Number of the plugin as it appears in "sm plugins list".
dvander@2168
   285
 * @return				Plugin Handle on success, INVALID_HANDLE if no plugin 
dvander@2168
   286
 *						matches the given number.
dvander@2168
   287
 */
dvander@2168
   288
native Handle:FindPluginByNumber(order_num);
dvander@2168
   289
dvander@2168
   290
/**
dvander@2168
   291
 * Causes the plugin to enter a failed state.  An error will be thrown and
dvander@2168
   292
 * the plugin will be paused until it is unloaded or reloaded.
dvander@2168
   293
 *
dvander@2168
   294
 * For backwards compatibility, if no extra arguments are passed, no 
dvander@2168
   295
 * formatting is applied.  If one or more additional arguments is passed, 
dvander@2168
   296
 * the string is formatted using Format().  If any errors are encountered 
dvander@2168
   297
 * during formatting, both the format specifier string and an additional 
dvander@2168
   298
 * error message are written.
dvander@2168
   299
 *
dvander@2168
   300
 * This function does not return, and no further code in the plugin is 
dvander@2168
   301
 * executed.
dvander@2168
   302
 *
dvander@2168
   303
 * @param string		Format specifier string.
dvander@2168
   304
 * @param ...			Formatting arguments.
dvander@2168
   305
 * @noreturn
dvander@2168
   306
 * @error				Always throws SP_ERROR_ABORT.
dvander@2168
   307
 */
dvander@2168
   308
native SetFailState(const String:string[], any:...);
dvander@2168
   309
dvander@2168
   310
/**
dvander@2168
   311
 * Aborts the current callback and throws an error.  This function
dvander@2168
   312
 * does not return in that no code is executed following it.
dvander@2168
   313
 *
dvander@2168
   314
 * @param format		String format.
dvander@2168
   315
 * @param ...			Format arguments.
dvander@2168
   316
 * @noreturn
dvander@2168
   317
 * @error				Always!
dvander@2168
   318
 */
dvander@2168
   319
native ThrowError(const String:fmt[], any:...);
dvander@2168
   320
dvander@2168
   321
/**
dvander@2168
   322
 * Gets the system time as a unix timestamp.
dvander@2168
   323
 *
dvander@2168
   324
 * @param bigStamp		Optional array to store the 64bit timestamp in.
dvander@2168
   325
 * @return				32bit timestamp (number of seconds since unix epoch).
dvander@2168
   326
 */
dvander@2168
   327
native GetTime(bigStamp[2]={0,0});
dvander@2168
   328
dvander@2168
   329
/**
dvander@2168
   330
 * Produces a date and/or time string value for a timestamp.
dvander@2168
   331
 *
dvander@2168
   332
 * See this URL for valid parameters: 
dvander@2168
   333
 * http://cplusplus.com/reference/clibrary/ctime/strftime.html
dvander@2168
   334
 *
dvander@2168
   335
 * @param buffer		Destination string buffer.
dvander@2168
   336
 * @param maxlength		Maximum length of output string buffer.
dvander@2168
   337
 * @param format		Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
dvander@2168
   338
 * @param stamp			Optional time stamp.
dvander@2168
   339
 * @noreturn
dvander@2168
   340
 * @error			Buffer too small or invalid time format.
dvander@2168
   341
 */
dvander@2168
   342
native FormatTime(String:buffer[], maxlength, const String:format[], stamp=-1);
dvander@2168
   343
dvander@2168
   344
/**
dvander@2168
   345
 * Loads a game config file.
dvander@2168
   346
 *
dvander@2168
   347
 * @param file			File to load.  The path must be relative to the 'gamedata' folder under the config folder 
dvander@2168
   348
 *					and the extension should be omitted.
dvander@2168
   349
 * @return			A handle to the game config file or INVALID_HANDLE in failure.
dvander@2168
   350
 */
dvander@2168
   351
native Handle:LoadGameConfigFile(const String:file[]);
dvander@2168
   352
dvander@2168
   353
/**
dvander@2168
   354
 * Returns an offset value.
dvander@2168
   355
 *
dvander@2168
   356
 * @param gc			Game config handle.
dvander@2168
   357
 * @param key			Key to retrieve from the offset section.
dvander@2168
   358
 * @return			An offset, or -1 on failure.
dvander@2168
   359
 */
dvander@2168
   360
native GameConfGetOffset(Handle:gc, const String:key[]);
dvander@2168
   361
dvander@2168
   362
/**
dvander@2168
   363
 * Gets the value of a key from the "Keys" section.
dvander@2168
   364
 *
dvander@2168
   365
 * @param gc			Game config handle.
dvander@2168
   366
 * @param key			Key to retrieve from the Keys section.
dvander@2168
   367
 * @param buffer		Destination string buffer.
dvander@2168
   368
 * @param maxlen		Maximum length of output string buffer.
dvander@2168
   369
 * @return				True if key existed, false otherwise.
dvander@2168
   370
 */
dvander@2168
   371
native bool:GameConfGetKeyValue(Handle:gc, const String:key[], String:buffer[], maxlen);
dvander@2168
   372
dvander@2168
   373
/**
dvander@2168
   374
 * Returns the operating system's "tick count," which is a number of 
dvander@2168
   375
 * milliseconds since the operating system loaded.  This can be used
dvander@2168
   376
 * for basic benchmarks.
dvander@2168
   377
 *
dvander@2168
   378
 * @return				Tick count in milliseconds.
dvander@2168
   379
 */
dvander@2168
   380
native GetSysTickCount();
dvander@2168
   381
dvander@2168
   382
/**
dvander@2168
   383
 * Specifies that the given config file should be executed after plugin load.
dvander@2168
   384
 * OnConfigsExecuted() will not be called until the config file has executed, 
dvander@2168
   385
 * but it will be called if the execution fails.
dvander@2168
   386
 *
dvander@2168
   387
 * @param autoCreate	If true, and the config file does not exist, such a config
dvander@2168
   388
 *						file will be automatically created and populated with
dvander@2168
   389
 *						information from the plugin's registered cvars.
dvander@2168
   390
 * @param name			Name of the config file, excluding the .cfg extension.
dvander@2168
   391
 *						If empty, <plugin.filename.cfg> is assumed.
dvander@2168
   392
 * @param folder		Folder under cfg/ to use.  By default this is "sourcemod."
dvander@2168
   393
 * @noreturn
dvander@2168
   394
 */
dvander@2168
   395
native AutoExecConfig(bool:autoCreate=true, const String:name[]="", const String:folder[]="sourcemod");
dvander@2168
   396
dvander@2168
   397
/**
dvander@2168
   398
 * Sets a native as optional, such that if it is unloaded, removed,
dvander@2168
   399
 * or otherwise non-existent, the plugin will still work.  Calling
dvander@2168
   400
 * removed natives results in a run-time error.
dvander@2168
   401
 *
dvander@2168
   402
 * @param name			Native name.
dvander@2168
   403
 * @noreturn
dvander@2168
   404
 */
dvander@2168
   405
native MarkNativeAsOptional(const String:name[]);
dvander@2168
   406
dvander@2168
   407
/**
dvander@2168
   408
 * Registers a library name for identifying as a dependency to 
dvander@2168
   409
 * other plugins.
dvander@2168
   410
 *
dvander@2168
   411
 * @param name			Library name.
dvander@2168
   412
 * @noreturn
dvander@2168
   413
 */
dvander@2168
   414
native RegPluginLibrary(const String:name[]);
dvander@2168
   415
dvander@2168
   416
/**
dvander@2168
   417
 * Returns whether a library exists.  This function should be considered 
dvander@2168
   418
 * expensive; it should only be called on plugin to determine availability 
dvander@2168
   419
 * of resources.  Use OnLibraryAdded()/OnLibraryRemoved() to detect changes 
dvander@2168
   420
 * in optional resources.
dvander@2168
   421
 *
dvander@2168
   422
 * @param name			Library name of a plugin or extension.
dvander@2168
   423
 * @return				True if exists, false otherwise.
dvander@2168
   424
 */
dvander@2168
   425
native bool:LibraryExists(const String:name[]);
dvander@2168
   426
dvander@2168
   427
/**
dvander@2168
   428
 * Returns the status of an extension, by filename.
dvander@2168
   429
 *
dvander@2168
   430
 * @param name			Extension name (like "sdktools.ext").
dvander@2168
   431
 * @param error			Optional error message buffer.
dvander@2168
   432
 * @param maxlength		Length of optional error message buffer.
dvander@2168
   433
 * @return				-2 if the extension was not found.
dvander@2168
   434
 *						-1 if the extension was found but failed to load.
dvander@2168
   435
 * 						 0 if the extension loaded but reported an error.
dvander@2168
   436
 * 						 1 if the extension is running without error.
dvander@2168
   437
 */
dvander@2168
   438
native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength=0);
dvander@2168
   439
dvander@2168
   440
/**
dvander@2168
   441
 * Called after a library is added that the current plugin references 
dvander@2168
   442
 * optionally. A library is either a plugin name or extension name, as 
dvander@2168
   443
 * exposed via its include file.
dvander@2168
   444
 *
dvander@2168
   445
 * @param name			Library name.
dvander@2168
   446
 */
dvander@2168
   447
forward OnLibraryAdded(const String:name[]);
dvander@2168
   448
dvander@2168
   449
/**
dvander@2168
   450
 * Called right before a library is removed that the current plugin references 
dvander@2168
   451
 * optionally.  A library is either a plugin name or extension name, as 
dvander@2168
   452
 * exposed via its include file.
dvander@2168
   453
 *
dvander@2168
   454
 * @param name			Library name.
dvander@2168
   455
 */
dvander@2168
   456
forward OnLibraryRemoved(const String:name[]);
dvander@2168
   457
dvander@2168
   458
#define MAPLIST_FLAG_MAPSFOLDER		(1<<0)		/**< On failure, use all maps in the maps folder. */
dvander@2168
   459
#define MAPLIST_FLAG_CLEARARRAY		(1<<1)		/**< If an input array is specified, clear it before adding. */
dvander@2168
   460
#define MAPLIST_FLAG_NO_DEFAULT		(1<<2)		/**< Do not read "default" or "mapcyclefile" on failure. */
dvander@2168
   461
dvander@2168
   462
/**
dvander@2168
   463
 * Loads a map list to an ADT Array.
dvander@2168
   464
 *
dvander@2168
   465
 * A map list is a list of maps from a file.  SourceMod allows easy configuration of 
dvander@2168
   466
 * maplists through addons/sourcemod/configs/maplists.cfg.  Each entry is given a 
dvander@2168
   467
 * name and a file (for example, "rtv" => "rtv.cfg"), or a name and a redirection 
dvander@2168
   468
 * (for example, "rtv" => "default").  This native will read a map list entry, 
dvander@2168
   469
 * cache the file, and return the list of maps it holds.  
dvander@2168
   470
 *
dvander@2168
   471
 * Serial change numbers are used to identify if a map list has changed.  Thus, if 
dvander@2168
   472
 * you pass a serial change number and it's equal to what SourceMod currently knows 
dvander@2168
   473
 * about the map list, then SourceMod won't reparse the file.
dvander@2168
   474
 *
dvander@2168
   475
 * If the maps end up being read from the maps folder (MAPLIST_FLAG_MAPSFOLDER), they 
dvander@2168
   476
 * are automatically sorted in alphabetical, ascending order.
dvander@2168
   477
 *
dvander@2168
   478
 * Arrays created by this function are temporary and must be freed via CloseHandle().
dvander@2168
   479
 * Modifying arrays created by this function will not affect future return values or 
dvander@2168
   480
 * or the contents of arrays returned to other plugins.
dvander@2168
   481
 *
dvander@2168
   482
 * @param array			Array to store the map list.  If INVALID_HANDLE, a new blank 
dvander@2168
   483
 *						array will be created.  The blocksize should be at least 16; 
dvander@2168
   484
 *						otherwise results may be truncated.  Items are added to the array 
dvander@2168
   485
 *						as strings.  The array is never checked for duplicates, and it is 
dvander@2168
   486
 *						not read beforehand.  Only the serial number is used to detect 
dvander@2168
   487
 *						changes.
dvander@2168
   488
 * @param serial		Serial number to identify last known map list change.  If -1, the 
dvander@2168
   489
 *						the value will not be checked.  If the map list has since changed, 
dvander@2168
   490
 *						the serial is updated (even if -1 was passed).  If there is an error 
dvander@2168
   491
 *						finding a valid maplist, then the serial is set to -1.
dvander@2168
   492
 * @param str			Config name, or "default" for the default map list.  Config names 
dvander@2168
   493
 *						should be somewhat descriptive.  For example, the admin menu uses 
dvander@2168
   494
 *						a config name of "admin menu".  The list names can be configured 
dvander@2168
   495
 *						by users in addons/sourcemod/configs/maplists.cfg.
dvander@2168
   496
 * @param flags			MAPLIST_FLAG flags.
dvander@2168
   497
 * @return				On failure:
dvander@2168
   498
 *						 INVALID_HANDLE is returned, the serial is set to -1, and the input 
dvander@2168
   499
 *						 array (if any) is left unchanged.
dvander@2168
   500
 *						On no change:
dvander@2168
   501
 						 INVALID_HANDLE is returned, the serial is unchanged, and the input 
dvander@2168
   502
 						 array (if any) is left unchanged.
dvander@2168
   503
 *						On success:
dvander@2168
   504
 *						 A valid array Handle is returned, containing at least one map string.  
dvander@2168
   505
 *						 If an array was passed, the return value is equal to the passed Array 
dvander@2168
   506
 *						 Handle.  If the passed array was not cleared, it will have grown by at 
dvander@2168
   507
 *						 least one item.  The serial number is updated to a positive number.
dvander@2168
   508
 * @error				Invalid array Handle that is not INVALID_HANDLE.
dvander@2168
   509
 */
dvander@2168
   510
native Handle:ReadMapList(Handle:array=INVALID_HANDLE,
dvander@2168
   511
						  &serial=-1,
dvander@2168
   512
						  const String:str[]="default",
dvander@2168
   513
						  flags=MAPLIST_FLAG_CLEARARRAY);
dvander@2168
   514
						  
dvander@2168
   515
/**
dvander@2168
   516
 * Makes a compatibility binding for map lists.  For example, if a function previously used 
dvander@2168
   517
 * "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that 
dvander@2168
   518
 * will be overridden if it's in the maplists.cfg file.
dvander@2168
   519
 *
dvander@2168
   520
 * @param name			Configuration name that would be used with ReadMapList().
dvander@2168
   521
 * @param file			Default file to use.
dvander@2168
   522
 * @noreturn
dvander@2168
   523
 */
dvander@2168
   524
native SetMapListCompatBind(const String:name[], const String:file[]);
dvander@2168
   525
dvander@2168
   526
/**
dvander@2168
   527
 * Called when a client has sent chat text.  This must return either true or 
dvander@2168
   528
 * false to indicate that a client is or is not spamming the server.
dvander@2168
   529
 *
dvander@2168
   530
 * The return value is a hint only.  Core or another plugin may decide 
dvander@2168
   531
 * otherwise.
dvander@2168
   532
 *
dvander@2168
   533
 * @param client		Client index.  The server (0) will never be passed.
dvander@2168
   534
 * @return				True if client is spamming the server, false otherwise.
dvander@2168
   535
 */
dvander@2168
   536
forward bool:OnClientFloodCheck(client);
dvander@2168
   537
dvander@2168
   538
/**
dvander@2168
   539
 * Called after a client's flood check has been computed.  This can be used 
dvander@2168
   540
 * by antiflood algorithms to decay/increase flooding weights.
dvander@2168
   541
 *
dvander@2168
   542
 * Since the result from "OnClientFloodCheck" isn't guaranteed to be the 
dvander@2168
   543
 * final result, it is generally a good idea to use this to play with other 
dvander@2168
   544
 * algorithms nicely.
dvander@2168
   545
 *
dvander@2168
   546
 * @param client		Client index.  The server (0) will never be passed.
dvander@2168
   547
 * @param blocked		True if client flooded last "say", false otherwise.
dvander@2168
   548
 * @noreturn
dvander@2168
   549
 */
dvander@2168
   550
forward OnClientFloodResult(client, bool:blocked);
dvander@2168
   551
dvander@2168
   552
#include <helpers>
dvander@2168
   553
#include <entity>
dvander@2168
   554
#include <entity_prop_stocks>
dvander@2168
   555