plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Wed Oct 28 00:37:34 2009 -0700 (2009-10-28)
changeset 2841 dde3dd0b4b8b
parent 2675 1502dc625325
child 2901 f5a1cf24f505
permissions -rw-r--r--
Added feature testing functionality (bug 4021, r=pred).
dvander@429
     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.
dvander@429
     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>.
dvander@429
    29
 *
faluco@506
    30
 * Version: $Id$
dvander@429
    31
 */
dvander@429
    32
dvander@429
    33
#if defined _sourcemod_included
dvander@429
    34
 #endinput
dvander@429
    35
#endif
dvander@429
    36
#define _sourcemod_included
dvander@429
    37
dvander@619
    38
/**
dvander@619
    39
 * Plugin public information.
dvander@619
    40
 */
dvander@429
    41
struct Plugin
dvander@429
    42
{
dvander@619
    43
   const String:name[],			/**< Plugin Name */
dvander@619
    44
   const String:description[],	/**< Plugin Description */
dvander@619
    45
   const String:author[],		/**< Plugin Author */
dvander@619
    46
   const String:version[],		/**< Plugin Version */
dvander@619
    47
   const String:url[],			/**< Plugin URL */
dvander@429
    48
};
dvander@429
    49
dvander@429
    50
#include <core>
dvander@429
    51
#include <float>
dvander@1069
    52
#include <vector>
ds@873
    53
#include <string>
dvander@429
    54
#include <handles>
dvander@601
    55
#include <functions>
ds@873
    56
#include <files>
dvander@1914
    57
#include <logging>
dvander@643
    58
#include <timers>
ds@873
    59
#include <admin>
dvander@2357
    60
#include <keyvalues>
dvander@868
    61
#include <dbi>
ds@913
    62
#include <lang>
ds@873
    63
#include <sorting>
ds@913
    64
#include <textparse>
ds@873
    65
#include <clients>
ds@873
    66
#include <console>
ds@873
    67
#include <events>
ds@873
    68
#include <bitbuffer>
ds@873
    69
#include <usermessages>
ds@873
    70
#include <menus>
ds@898
    71
#include <halflife>
dvander@1156
    72
#include <adt>
dvander@1423
    73
#include <banning>
dvander@1621
    74
#include <commandfilters>
pred@2133
    75
#include <nextmap>
ds@898
    76
fyrenmoo@2675
    77
enum APLRes
fyrenmoo@2675
    78
{
fyrenmoo@2675
    79
	APLRes_Success = 0,		/**< Plugin should load */
fyrenmoo@2675
    80
	APLRes_Failure,			/**< Plugin shouldn't load and should display an error */
fyrenmoo@2675
    81
	APLRes_SilentFailure	/**< Plugin shouldn't load but do so silently */
fyrenmoo@2675
    82
};
fyrenmoo@2675
    83
dvander@429
    84
/**
dvander@429
    85
 * Declare this as a struct in your plugin to expose its information.
dvander@429
    86
 * Example:
dvander@429
    87
 *
dvander@429
    88
 * public Plugin:myinfo =
dvander@429
    89
 * {
dvander@429
    90
 *    name = "My Plugin",
dvander@429
    91
 *    //etc
dvander@429
    92
 * };
dvander@429
    93
 */
dvander@429
    94
public Plugin:myinfo;
dvander@429
    95
 
dvander@429
    96
/**
dvander@1869
    97
 * Called when the plugin is fully initialized and all known external references 
dvander@1869
    98
 * are resolved. This is only called once in the lifetime of the plugin, and is 
dvander@1869
    99
 * paired with OnPluginEnd().
dvander@1869
   100
 *
dvander@1869
   101
 * If any run-time error is thrown during this callback, the plugin will be marked 
dvander@1869
   102
 * as failed.
dvander@429
   103
 *
dvander@1914
   104
 * It is not necessary to close any handles or remove hooks in this function.  
dvander@1914
   105
 * SourceMod guarantees that plugin shutdown automatically and correctly releases 
dvander@1914
   106
 * all resources.
dvander@1914
   107
 *
dvander@429
   108
 * @noreturn
dvander@429
   109
 */
dvander@536
   110
forward OnPluginStart();
fyrenmoo@2675
   111
fyrenmoo@2675
   112
/**
fyrenmoo@2675
   113
 * @deprecated Use AskPluginLoad2() instead.
fyrenmoo@2675
   114
 * If a plugin contains both AskPluginLoad() and AskPluginLoad2(), the former will
fyrenmoo@2675
   115
 * not be called, but old plugins with only AskPluginLoad() will work.
fyrenmoo@2675
   116
 */
fyrenmoo@2675
   117
#pragma deprecated Use AskPluginLoad2() instead
fyrenmoo@2675
   118
forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
fyrenmoo@2675
   119
dvander@429
   120
/**
dvander@979
   121
 * Called before OnPluginStart, in case the plugin wants to check for load failure.
dvander@429
   122
 * This is called even if the plugin type is "private."  Any natives from modules are 
dvander@429
   123
 * not available at this point.  Thus, this forward should only be used for explicit 
fyrenmoo@2675
   124
 * pre-emptive things, such as adding dynamic natives, setting certain types of load 
fyrenmoo@2675
   125
 * filters (such as not loading the plugin for certain games).
dvander@429
   126
 * 
dvander@619
   127
 * @note It is not safe to call externally resolved natives until OnPluginStart().
dvander@619
   128
 * @note Any sort of RTE in this function will cause the plugin to fail loading.
fyrenmoo@2675
   129
 * @note If you do not return anything, it is treated like returning success. 
fyrenmoo@2675
   130
 * @note If a plugin has an AskPluginLoad2(), AskPluginLoad() will not be called.
fyrenmoo@2675
   131
 *
dvander@429
   132
 *
dvander@429
   133
 * @param myself	Handle to the plugin.
dvander@429
   134
 * @param late		Whether or not the plugin was loaded "late" (after map load).
dvander@429
   135
 * @param error		Error message buffer in case load failed.
dvander@429
   136
 * @param err_max	Maximum number of characters for error message buffer.
fyrenmoo@2675
   137
 * @return			APLRes_Success for load success, APLRes_Failure or APLRes_SilentFailure otherwise
dvander@429
   138
 */
fyrenmoo@2675
   139
forward APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max);
dvander@429
   140
dvander@429
   141
/**
dvander@429
   142
 * Called when the plugin is about to be unloaded.
dvander@429
   143
 *
dvander@429
   144
 * @noreturn
dvander@429
   145
 */
dvander@429
   146
forward OnPluginEnd();
dvander@429
   147
dvander@429
   148
/**
dvander@429
   149
 * Called when the plugin's pause status is changing.
dvander@429
   150
 *
ds@475
   151
 * @param pause			True if the plugin is being paused, false otherwise.
dvander@429
   152
 * @noreturn
dvander@429
   153
 */
dvander@429
   154
forward OnPluginPauseChange(bool:pause);
dvander@429
   155
dvander@429
   156
/**
dvander@531
   157
 * Called before every server frame.  Note that you should avoid
dvander@531
   158
 * doing expensive computations here, and you should declare large
dvander@531
   159
 * local arrays using 'decl' instead of 'new'.
dvander@531
   160
 */
dvander@531
   161
forward OnGameFrame();
dvander@531
   162
dvander@531
   163
/**
dvander@717
   164
 * Called when the map is loaded.
dvander@717
   165
 *
dvander@723
   166
 * @note This used to be OnServerLoad(), which is now deprecated.
dvander@717
   167
 * Plugins still using the old forward will work.
dvander@643
   168
 */
dvander@717
   169
forward OnMapStart();
dvander@643
   170
dvander@643
   171
/**
dvander@718
   172
 * Called right before a map ends.
dvander@718
   173
 */
dvander@718
   174
forward OnMapEnd();
dvander@718
   175
dvander@718
   176
/**
dvander@978
   177
 * Called when the map has loaded, servercfgfile (server.cfg) has been 
dvander@978
   178
 * executed, and all plugin configs are done executing.  This is the best
dvander@1732
   179
 * place to initialize plugin functions which are based on cvar data.  
dvander@723
   180
 *
dvander@978
   181
 * @note This will always be called once and only once per map.  It will be 
dvander@978
   182
 * called after OnMapStart().
dvander@978
   183
 *
dvander@978
   184
 * @noreturn
dvander@723
   185
 */
dvander@978
   186
forward OnConfigsExecuted();
dvander@723
   187
dvander@723
   188
/**
dvander@2065
   189
 * This is called once, right after OnMapStart() but any time before 
dvander@2065
   190
 * OnConfigsExecuted().  It is called after the "exec sourcemod.cfg" 
dvander@2065
   191
 * command and all AutoExecConfig() exec commands have been added to 
dvander@2065
   192
 * the ServerCommand() buffer.
dvander@2065
   193
 *
dvander@2065
   194
 * If you need to load per-map settings that override default values, 
dvander@2065
   195
 * adding commands to the ServerCommand() buffer here will guarantee 
dvander@2065
   196
 * that they're set before OnConfigsExecuted().
dvander@2065
   197
 *
dvander@2065
   198
 * Unlike OnMapStart() and OnConfigsExecuted(), this is not called on 
dvander@2065
   199
 * late loads that occur after OnMapStart().
dvander@2065
   200
 *
dvander@2065
   201
 * @noreturn
dvander@2065
   202
 */
dvander@2065
   203
forward OnAutoConfigsBuffered();
dvander@2065
   204
dvander@2065
   205
/**
dvander@979
   206
 * @deprecated Use OnConfigsExecuted() instead.
dvander@979
   207
 */
ds@1268
   208
#pragma deprecated Use OnConfigsExecuted() instead
dvander@979
   209
forward OnServerCfg();
dvander@979
   210
dvander@979
   211
/**
dvander@1630
   212
 * Called after all plugins have been loaded.  This is called once for 
dvander@1630
   213
 * every plugin.  If a plugin late loads, it will be called immediately 
dvander@1630
   214
 * after OnPluginStart().
faluco@1221
   215
 */
faluco@1221
   216
forward OnAllPluginsLoaded();
faluco@1221
   217
faluco@1221
   218
/**
dvander@536
   219
 * Returns the calling plugin's Handle.
dvander@536
   220
 *
dvander@536
   221
 * @return				Handle of the calling plugin.
dvander@536
   222
 */
dvander@536
   223
native Handle:GetMyHandle();
dvander@536
   224
dvander@618
   225
/**
dvander@618
   226
 * Returns an iterator that can be used to search through plugins.
dvander@618
   227
 *
dvander@618
   228
 * @return				Handle to iterate with.  Must be closed via 
dvander@618
   229
 * 						CloseHandle().
dvander@618
   230
 * @error				Invalid Handle.
dvander@618
   231
 */
dvander@618
   232
native Handle:GetPluginIterator();
dvander@618
   233
dvander@618
   234
/**
dvander@618
   235
 * Returns whether there are more plugins available in the iterator.
dvander@618
   236
 *
dvander@618
   237
 * @param iter			Handle to the plugin iterator.
dvander@618
   238
 * @return				True on more plugins, false otherwise.
dvander@618
   239
 * @error				Invalid Handle.
dvander@618
   240
 */
dvander@618
   241
native bool:MorePlugins(Handle:iter);
dvander@618
   242
dvander@618
   243
/**
dvander@618
   244
 * Returns the current plugin in the iterator and advances the iterator.
dvander@618
   245
 *
dvander@618
   246
 * @param iter			Handle to the plugin iterator.
dvander@618
   247
 * @return				Current plugin the iterator is at, before
dvander@618
   248
 *						the iterator is advanced.
dvander@618
   249
 * @error				Invalid Handle.
dvander@618
   250
 */
dvander@618
   251
native Handle:ReadPlugin(Handle:iter);
dvander@618
   252
dvander@618
   253
/**
dvander@618
   254
 * Returns a plugin's status.
dvander@618
   255
 *
dvander@618
   256
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   257
 * @return				Status code for the plugin.
dvander@618
   258
 * @error				Invalid Handle.
dvander@618
   259
 */
dvander@618
   260
native PluginStatus:GetPluginStatus(Handle:plugin);
dvander@618
   261
dvander@618
   262
/**
dvander@618
   263
 * Retrieves a plugin's file name relative to the plugins folder.
dvander@618
   264
 *
dvander@618
   265
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   266
 * @param buffer		Buffer to the store the file name.
dvander@618
   267
 * @param maxlength		Maximum length of the name buffer.
dvander@618
   268
 * @noreturn
dvander@618
   269
 * @error				Invalid Handle.
dvander@618
   270
 */
dvander@618
   271
native GetPluginFilename(Handle:plugin, String:buffer[], maxlength);
dvander@618
   272
dvander@618
   273
/**
dvander@618
   274
 * Retrieves whether or not a plugin is being debugged.
dvander@618
   275
 *
dvander@618
   276
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   277
 * @return				True if being debugged, false otherwise.
dvander@618
   278
 * @error				Invalid Handle.
dvander@618
   279
 */
dvander@618
   280
native bool:IsPluginDebugging(Handle:hndl);
dvander@618
   281
dvander@618
   282
/**
dvander@618
   283
 * Retrieves a plugin's public info.
dvander@618
   284
 *
dvander@618
   285
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   286
 * @param info			Plugin info property to retrieve.
dvander@618
   287
 * @param buffer		Buffer to store info in.
dvander@618
   288
 * @param maxlength		Maximum length of buffer.
dvander@618
   289
 * @return				True on success, false if property is not available.
dvander@618
   290
 * @error				Invalid Handle.
dvander@618
   291
 */
dvander@618
   292
native bool:GetPluginInfo(Handle:plugin, PluginInfo:info, String:buffer[], maxlength);
dvander@560
   293
dvander@560
   294
/**
dvander@1798
   295
 * Finds a plugin by its order in the list from the "plugins list" server 
dvander@1798
   296
 * "sm" command.  You should not use this function to loop through all plugins, 
dvander@1798
   297
 * use the iterator instead.  Looping through all plugins using this native 
dvander@1798
   298
 * is O(n^2), whereas using the iterator is O(n).
dvander@1798
   299
 *
dvander@1798
   300
 * @param order_num		Number of the plugin as it appears in "sm plugins list".
dvander@1798
   301
 * @return				Plugin Handle on success, INVALID_HANDLE if no plugin 
dvander@1798
   302
 *						matches the given number.
dvander@1798
   303
 */
dvander@1798
   304
native Handle:FindPluginByNumber(order_num);
dvander@1798
   305
dvander@1798
   306
/**
dvander@837
   307
 * Causes the plugin to enter a failed state.  An error will be thrown and
dvander@837
   308
 * the plugin will be paused until it is unloaded or reloaded.
dvander@837
   309
 *
dvander@1833
   310
 * For backwards compatibility, if no extra arguments are passed, no 
dvander@1833
   311
 * formatting is applied.  If one or more additional arguments is passed, 
dvander@1833
   312
 * the string is formatted using Format().  If any errors are encountered 
dvander@1833
   313
 * during formatting, both the format specifier string and an additional 
dvander@1833
   314
 * error message are written.
dvander@1833
   315
 *
dvander@1833
   316
 * This function does not return, and no further code in the plugin is 
dvander@1833
   317
 * executed.
dvander@1833
   318
 *
dvander@1833
   319
 * @param string		Format specifier string.
dvander@1833
   320
 * @param ...			Formatting arguments.
dvander@837
   321
 * @noreturn
dvander@838
   322
 * @error				Always throws SP_ERROR_ABORT.
dvander@837
   323
 */
dvander@1833
   324
native SetFailState(const String:string[], any:...);
dvander@837
   325
dvander@837
   326
/**
dvander@560
   327
 * Aborts the current callback and throws an error.  This function
dvander@560
   328
 * does not return in that no code is executed following it.
dvander@560
   329
 *
dvander@560
   330
 * @param format		String format.
dvander@560
   331
 * @param ...			Format arguments.
dvander@560
   332
 * @noreturn
dvander@560
   333
 * @error				Always!
dvander@560
   334
 */
ds@634
   335
native ThrowError(const String:fmt[], any:...);
dvander@560
   336
dvander@536
   337
/**
dvander@595
   338
 * Gets the system time as a unix timestamp.
dvander@595
   339
 *
dvander@595
   340
 * @param bigStamp		Optional array to store the 64bit timestamp in.
dvander@595
   341
 * @return				32bit timestamp (number of seconds since unix epoch).
dvander@595
   342
 */
dvander@595
   343
native GetTime(bigStamp[2]={0,0});
dvander@595
   344
dvander@595
   345
/**
dvander@1334
   346
 * Produces a date and/or time string value for a timestamp.
dvander@1334
   347
 *
dvander@1334
   348
 * See this URL for valid parameters: 
dvander@1972
   349
 * http://cplusplus.com/reference/clibrary/ctime/strftime.html
faluco@1037
   350
 *
faluco@1037
   351
 * @param buffer		Destination string buffer.
faluco@1037
   352
 * @param maxlength		Maximum length of output string buffer.
faluco@1359
   353
 * @param format		Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
faluco@1041
   354
 * @param stamp			Optional time stamp.
faluco@1037
   355
 * @noreturn
dvander@1334
   356
 * @error			Buffer too small or invalid time format.
faluco@1037
   357
 */
faluco@1041
   358
native FormatTime(String:buffer[], maxlength, const String:format[], stamp=-1);
faluco@1037
   359
faluco@1037
   360
/**
faluco@703
   361
 * Loads a game config file.
faluco@703
   362
 *
faluco@703
   363
 * @param file			File to load.  The path must be relative to the 'gamedata' folder under the config folder 
faluco@703
   364
 *					and the extension should be omitted.
faluco@703
   365
 * @return			A handle to the game config file or INVALID_HANDLE in failure.
faluco@703
   366
 */
faluco@703
   367
native Handle:LoadGameConfigFile(const String:file[]);
faluco@703
   368
faluco@703
   369
/**
faluco@703
   370
 * Returns an offset value.
faluco@703
   371
 *
faluco@703
   372
 * @param gc			Game config handle.
faluco@703
   373
 * @param key			Key to retrieve from the offset section.
faluco@703
   374
 * @return			An offset, or -1 on failure.
faluco@703
   375
 */
faluco@703
   376
native GameConfGetOffset(Handle:gc, const String:key[]);
faluco@703
   377
faluco@703
   378
/**
faluco@703
   379
 * Gets the value of a key from the "Keys" section.
faluco@703
   380
 *
faluco@703
   381
 * @param gc			Game config handle.
faluco@703
   382
 * @param key			Key to retrieve from the Keys section.
faluco@703
   383
 * @param buffer		Destination string buffer.
faluco@703
   384
 * @param maxlen		Maximum length of output string buffer.
dvander@886
   385
 * @return				True if key existed, false otherwise.
faluco@703
   386
 */
faluco@703
   387
native bool:GameConfGetKeyValue(Handle:gc, const String:key[], String:buffer[], maxlen);
faluco@703
   388
dvander@886
   389
/**
dvander@886
   390
 * Returns the operating system's "tick count," which is a number of 
dvander@886
   391
 * milliseconds since the operating system loaded.  This can be used
dvander@886
   392
 * for basic benchmarks.
dvander@886
   393
 *
dvander@886
   394
 * @return				Tick count in milliseconds.
dvander@886
   395
 */
dvander@886
   396
native GetSysTickCount();
dvander@886
   397
dvander@978
   398
/**
dvander@978
   399
 * Specifies that the given config file should be executed after plugin load.
dvander@978
   400
 * OnConfigsExecuted() will not be called until the config file has executed, 
dvander@978
   401
 * but it will be called if the execution fails.
dvander@978
   402
 *
dvander@978
   403
 * @param autoCreate	If true, and the config file does not exist, such a config
dvander@978
   404
 *						file will be automatically created and populated with
dvander@978
   405
 *						information from the plugin's registered cvars.
dvander@978
   406
 * @param name			Name of the config file, excluding the .cfg extension.
dvander@978
   407
 *						If empty, <plugin.filename.cfg> is assumed.
dvander@978
   408
 * @param folder		Folder under cfg/ to use.  By default this is "sourcemod."
dvander@978
   409
 * @noreturn
dvander@978
   410
 */
dvander@978
   411
native AutoExecConfig(bool:autoCreate=true, const String:name[]="", const String:folder[]="sourcemod");
dvander@978
   412
faluco@1112
   413
/**
faluco@1112
   414
 * Registers a library name for identifying as a dependency to 
faluco@1112
   415
 * other plugins.
faluco@1112
   416
 *
faluco@1112
   417
 * @param name			Library name.
faluco@1112
   418
 * @noreturn
faluco@1112
   419
 */
faluco@1112
   420
native RegPluginLibrary(const String:name[]);
faluco@1112
   421
dvander@1124
   422
/**
dvander@1573
   423
 * Returns whether a library exists.  This function should be considered 
dvander@1573
   424
 * expensive; it should only be called on plugin to determine availability 
dvander@1573
   425
 * of resources.  Use OnLibraryAdded()/OnLibraryRemoved() to detect changes 
dvander@1573
   426
 * in optional resources.
dvander@1124
   427
 *
dvander@1573
   428
 * @param name			Library name of a plugin or extension.
dvander@1124
   429
 * @return				True if exists, false otherwise.
dvander@1124
   430
 */
dvander@1124
   431
native bool:LibraryExists(const String:name[]);
dvander@1124
   432
dvander@1124
   433
/**
dvander@1419
   434
 * Returns the status of an extension, by filename.
dvander@1419
   435
 *
dvander@1419
   436
 * @param name			Extension name (like "sdktools.ext").
dvander@1419
   437
 * @param error			Optional error message buffer.
dvander@1419
   438
 * @param maxlength		Length of optional error message buffer.
dvander@1419
   439
 * @return				-2 if the extension was not found.
dvander@1419
   440
 *						-1 if the extension was found but failed to load.
dvander@1419
   441
 * 						 0 if the extension loaded but reported an error.
dvander@1419
   442
 * 						 1 if the extension is running without error.
dvander@1419
   443
 */
dvander@1419
   444
native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength=0);
dvander@1419
   445
dvander@1419
   446
/**
dvander@1572
   447
 * Called after a library is added that the current plugin references 
dvander@1572
   448
 * optionally. A library is either a plugin name or extension name, as 
dvander@1572
   449
 * exposed via its include file.
dvander@1124
   450
 *
dvander@1124
   451
 * @param name			Library name.
dvander@1124
   452
 */
dvander@1124
   453
forward OnLibraryAdded(const String:name[]);
dvander@1124
   454
dvander@1124
   455
/**
dvander@1572
   456
 * Called right before a library is removed that the current plugin references 
dvander@1572
   457
 * optionally.  A library is either a plugin name or extension name, as 
dvander@1572
   458
 * exposed via its include file.
dvander@1124
   459
 *
dvander@1124
   460
 * @param name			Library name.
dvander@1124
   461
 */
dvander@1124
   462
forward OnLibraryRemoved(const String:name[]);
dvander@1124
   463
dvander@1738
   464
#define MAPLIST_FLAG_MAPSFOLDER		(1<<0)		/**< On failure, use all maps in the maps folder. */
dvander@1738
   465
#define MAPLIST_FLAG_CLEARARRAY		(1<<1)		/**< If an input array is specified, clear it before adding. */
dvander@1738
   466
#define MAPLIST_FLAG_NO_DEFAULT		(1<<2)		/**< Do not read "default" or "mapcyclefile" on failure. */
dvander@1738
   467
dvander@1738
   468
/**
dvander@1738
   469
 * Loads a map list to an ADT Array.
dvander@1738
   470
 *
dvander@1738
   471
 * A map list is a list of maps from a file.  SourceMod allows easy configuration of 
dvander@1738
   472
 * maplists through addons/sourcemod/configs/maplists.cfg.  Each entry is given a 
dvander@1738
   473
 * name and a file (for example, "rtv" => "rtv.cfg"), or a name and a redirection 
dvander@1738
   474
 * (for example, "rtv" => "default").  This native will read a map list entry, 
dvander@1738
   475
 * cache the file, and return the list of maps it holds.  
dvander@1738
   476
 *
dvander@1738
   477
 * Serial change numbers are used to identify if a map list has changed.  Thus, if 
dvander@1738
   478
 * you pass a serial change number and it's equal to what SourceMod currently knows 
dvander@1738
   479
 * about the map list, then SourceMod won't reparse the file.
dvander@1738
   480
 *
dvander@1738
   481
 * If the maps end up being read from the maps folder (MAPLIST_FLAG_MAPSFOLDER), they 
dvander@1738
   482
 * are automatically sorted in alphabetical, ascending order.
dvander@1738
   483
 *
dvander@1739
   484
 * Arrays created by this function are temporary and must be freed via CloseHandle().
dvander@1739
   485
 * Modifying arrays created by this function will not affect future return values or 
dvander@1739
   486
 * or the contents of arrays returned to other plugins.
dvander@1739
   487
 *
dvander@1738
   488
 * @param array			Array to store the map list.  If INVALID_HANDLE, a new blank 
dvander@1738
   489
 *						array will be created.  The blocksize should be at least 16; 
dvander@1738
   490
 *						otherwise results may be truncated.  Items are added to the array 
dvander@1738
   491
 *						as strings.  The array is never checked for duplicates, and it is 
dvander@1738
   492
 *						not read beforehand.  Only the serial number is used to detect 
dvander@1738
   493
 *						changes.
dvander@1772
   494
 * @param serial		Serial number to identify last known map list change.  If -1, the 
dvander@1772
   495
 *						the value will not be checked.  If the map list has since changed, 
dvander@1772
   496
 *						the serial is updated (even if -1 was passed).  If there is an error 
dvander@1772
   497
 *						finding a valid maplist, then the serial is set to -1.
dvander@1738
   498
 * @param str			Config name, or "default" for the default map list.  Config names 
dvander@1738
   499
 *						should be somewhat descriptive.  For example, the admin menu uses 
dvander@1738
   500
 *						a config name of "admin menu".  The list names can be configured 
dvander@1738
   501
 *						by users in addons/sourcemod/configs/maplists.cfg.
dvander@1738
   502
 * @param flags			MAPLIST_FLAG flags.
dvander@1738
   503
 * @return				On failure:
dvander@1738
   504
 *						 INVALID_HANDLE is returned, the serial is set to -1, and the input 
dvander@1738
   505
 *						 array (if any) is left unchanged.
dvander@1738
   506
 *						On no change:
dvander@1738
   507
 						 INVALID_HANDLE is returned, the serial is unchanged, and the input 
dvander@1738
   508
 						 array (if any) is left unchanged.
dvander@1738
   509
 *						On success:
dvander@1738
   510
 *						 A valid array Handle is returned, containing at least one map string.  
dvander@1738
   511
 *						 If an array was passed, the return value is equal to the passed Array 
dvander@1738
   512
 *						 Handle.  If the passed array was not cleared, it will have grown by at 
dvander@1738
   513
 *						 least one item.  The serial number is updated to a positive number.
dvander@1738
   514
 * @error				Invalid array Handle that is not INVALID_HANDLE.
dvander@1738
   515
 */
dvander@1738
   516
native Handle:ReadMapList(Handle:array=INVALID_HANDLE,
dvander@1738
   517
						  &serial=-1,
dvander@1738
   518
						  const String:str[]="default",
dvander@1738
   519
						  flags=MAPLIST_FLAG_CLEARARRAY);
dvander@1738
   520
						  
dvander@1738
   521
/**
dvander@1738
   522
 * Makes a compatibility binding for map lists.  For example, if a function previously used 
dvander@1738
   523
 * "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that 
dvander@1738
   524
 * will be overridden if it's in the maplists.cfg file.
dvander@1738
   525
 *
dvander@1738
   526
 * @param name			Configuration name that would be used with ReadMapList().
dvander@1738
   527
 * @param file			Default file to use.
dvander@1738
   528
 * @noreturn
dvander@1738
   529
 */
dvander@1738
   530
native SetMapListCompatBind(const String:name[], const String:file[]);
dvander@1738
   531
dvander@1925
   532
/**
dvander@1925
   533
 * Called when a client has sent chat text.  This must return either true or 
dvander@1925
   534
 * false to indicate that a client is or is not spamming the server.
dvander@1925
   535
 *
dvander@1925
   536
 * The return value is a hint only.  Core or another plugin may decide 
dvander@1925
   537
 * otherwise.
dvander@1925
   538
 *
dvander@1925
   539
 * @param client		Client index.  The server (0) will never be passed.
dvander@1925
   540
 * @return				True if client is spamming the server, false otherwise.
dvander@1925
   541
 */
dvander@1925
   542
forward bool:OnClientFloodCheck(client);
dvander@1925
   543
dvander@1925
   544
/**
dvander@1925
   545
 * Called after a client's flood check has been computed.  This can be used 
dvander@1925
   546
 * by antiflood algorithms to decay/increase flooding weights.
dvander@1925
   547
 *
dvander@1925
   548
 * Since the result from "OnClientFloodCheck" isn't guaranteed to be the 
dvander@1925
   549
 * final result, it is generally a good idea to use this to play with other 
dvander@1925
   550
 * algorithms nicely.
dvander@1925
   551
 *
dvander@1925
   552
 * @param client		Client index.  The server (0) will never be passed.
dvander@1925
   553
 * @param blocked		True if client flooded last "say", false otherwise.
dvander@1925
   554
 * @noreturn
dvander@1925
   555
 */
dvander@1925
   556
forward OnClientFloodResult(client, bool:blocked);
dvander@1925
   557
dvander@2841
   558
/**
dvander@2841
   559
 * Feature types.
dvander@2841
   560
 */
dvander@2841
   561
enum FeatureType
dvander@2841
   562
{
dvander@2841
   563
	/**
dvander@2841
   564
	 * A native function call.
dvander@2841
   565
	 */
dvander@2841
   566
	FeatureType_Native,
dvander@2841
   567
	
dvander@2841
   568
	/**
dvander@2841
   569
	 * A named capability. This is distinctly different from checking for a
dvander@2841
   570
	 * native, because the underlying functionality could be enabled on-demand
dvander@2841
   571
	 * to improve loading time. Thus a native may appear to exist, but it might
dvander@2841
   572
	 * be part of a set of features that are not compatible with the current game
dvander@2841
   573
	 * or version of SourceMod.
dvander@2841
   574
	 */
dvander@2841
   575
	FeatureType_Capability
dvander@2841
   576
};
dvander@2841
   577
dvander@2841
   578
/**
dvander@2841
   579
 * Feature statuses.
dvander@2841
   580
 */
dvander@2841
   581
enum FeatureStatus
dvander@2841
   582
{
dvander@2841
   583
	/**
dvander@2841
   584
	 * Feature is available for use.
dvander@2841
   585
	 */
dvander@2841
   586
	FeatureStatus_Available,
dvander@2841
   587
	
dvander@2841
   588
	/**
dvander@2841
   589
	 * Feature is not available.
dvander@2841
   590
	 */
dvander@2841
   591
	FeatureStatus_Unavailable,
dvander@2841
   592
	
dvander@2841
   593
	/**
dvander@2841
   594
	 * Feature is not known at all.
dvander@2841
   595
	 */
dvander@2841
   596
	FeatureStatus_Unknown
dvander@2841
   597
};
dvander@2841
   598
dvander@2841
   599
/**
dvander@2841
   600
 * Returns whether "GetFeatureStatus" will work. Using this native
dvander@2841
   601
 * or this function will not cause SourceMod to fail loading on older versions,
dvander@2841
   602
 * however, GetFeatureStatus will only work if this function returns true.
dvander@2841
   603
 *
dvander@2841
   604
 * @return              True if GetFeatureStatus will work, false otherwise.
dvander@2841
   605
 */
dvander@2841
   606
stock bool:CanTestFeatures()
dvander@2841
   607
{
dvander@2841
   608
	return LibraryExists("__CanTestFeatures__");
dvander@2841
   609
}
dvander@2841
   610
dvander@2841
   611
/**
dvander@2841
   612
 * Returns whether a feature exists, and if so, whether it is usable.
dvander@2841
   613
 *
dvander@2841
   614
 * @param type          Feature type.
dvander@2841
   615
 * @param name          Feature name.
dvander@2841
   616
 * @return              Feature status.
dvander@2841
   617
 */
dvander@2841
   618
native FeatureStatus:GetFeatureStatus(FeatureType:type, const String:name[]);
dvander@2841
   619
dvander@2841
   620
/**
dvander@2841
   621
 * Requires that a given feature is available. If it is not, SetFailState()
dvander@2841
   622
 * is called with the given message.
dvander@2841
   623
 *
dvander@2841
   624
 * @param type          Feature type.
dvander@2841
   625
 * @param name          Feature name.
dvander@2841
   626
 * @param fmt           Message format string, or empty to use default.
dvander@2841
   627
 * @param ...           Message format parameters, if any.
dvander@2841
   628
 * @noreturn
dvander@2841
   629
 */
dvander@2841
   630
native RequireFeature(FeatureType:type, const String:name[],
dvander@2841
   631
                      const String:fmt[]="", any:...);
dvander@2841
   632
dvander@460
   633
#include <helpers>
dvander@560
   634
#include <entity>
ferret99gt@1800
   635
#include <entity_prop_stocks>
dvander@1419
   636