plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Fri Jan 04 16:20:25 2008 +0000 (2008-01-04)
changeset 1833 3bb2c9cb63d2
parent 1800 1f02d51c5c1e
child 1869 49274af1f67c
permissions -rw-r--r--
added amb1348 - SetFailState() formatting
dvander@429
     1
/**
ds@475
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@429
     4
 * SourceMod (C)2004-2007 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@643
    57
#include <timers>
ds@873
    58
#include <admin>
dvander@868
    59
#include <dbi>
ds@913
    60
#include <lang>
ds@873
    61
#include <sorting>
ds@913
    62
#include <textparse>
ds@873
    63
#include <clients>
ds@873
    64
#include <console>
ds@873
    65
#include <events>
ds@873
    66
#include <bitbuffer>
ds@873
    67
#include <usermessages>
ds@913
    68
#include <keyvalues>
ds@873
    69
#include <menus>
ds@898
    70
#include <halflife>
dvander@1156
    71
#include <adt>
dvander@1423
    72
#include <banning>
dvander@1621
    73
#include <commandfilters>
ds@898
    74
dvander@429
    75
/**
dvander@429
    76
 * Declare this as a struct in your plugin to expose its information.
dvander@429
    77
 * Example:
dvander@429
    78
 *
dvander@429
    79
 * public Plugin:myinfo =
dvander@429
    80
 * {
dvander@429
    81
 *    name = "My Plugin",
dvander@429
    82
 *    //etc
dvander@429
    83
 * };
dvander@429
    84
 */
dvander@429
    85
public Plugin:myinfo;
dvander@429
    86
 
dvander@429
    87
/**
dvander@429
    88
 * Called when the plugin is fully initialized and all known external references are resolved.
dvander@429
    89
 * This is called even if the plugin type is "private."
dvander@619
    90
 * @note Errors in this function will cause the plugin to stop running.
dvander@429
    91
 *
dvander@429
    92
 * @noreturn
dvander@429
    93
 */
dvander@536
    94
forward OnPluginStart();
dvander@429
    95
 
dvander@429
    96
/**
dvander@979
    97
 * Called before OnPluginStart, in case the plugin wants to check for load failure.
dvander@429
    98
 * This is called even if the plugin type is "private."  Any natives from modules are 
dvander@429
    99
 * not available at this point.  Thus, this forward should only be used for explicit 
dvander@429
   100
 * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
dvander@429
   101
 * 
dvander@619
   102
 * @note It is not safe to call externally resolved natives until OnPluginStart().
dvander@619
   103
 * @note Any sort of RTE in this function will cause the plugin to fail loading.
dvander@429
   104
 *
dvander@429
   105
 * @param myself	Handle to the plugin.
dvander@429
   106
 * @param late		Whether or not the plugin was loaded "late" (after map load).
dvander@429
   107
 * @param error		Error message buffer in case load failed.
dvander@429
   108
 * @param err_max	Maximum number of characters for error message buffer.
dvander@429
   109
 * @return			True if load success, false otherwise.
dvander@429
   110
 */
dvander@429
   111
forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
dvander@429
   112
dvander@429
   113
/**
dvander@429
   114
 * Called when the plugin is about to be unloaded.
dvander@429
   115
 *
dvander@429
   116
 * @noreturn
dvander@429
   117
 */
dvander@429
   118
forward OnPluginEnd();
dvander@429
   119
dvander@429
   120
/**
dvander@429
   121
 * Called when the plugin's pause status is changing.
dvander@429
   122
 *
ds@475
   123
 * @param pause			True if the plugin is being paused, false otherwise.
dvander@429
   124
 * @noreturn
dvander@429
   125
 */
dvander@429
   126
forward OnPluginPauseChange(bool:pause);
dvander@429
   127
dvander@429
   128
/**
dvander@531
   129
 * Called before every server frame.  Note that you should avoid
dvander@531
   130
 * doing expensive computations here, and you should declare large
dvander@531
   131
 * local arrays using 'decl' instead of 'new'.
dvander@531
   132
 */
dvander@531
   133
forward OnGameFrame();
dvander@531
   134
dvander@531
   135
/**
dvander@717
   136
 * Called when the map is loaded.
dvander@717
   137
 *
dvander@723
   138
 * @note This used to be OnServerLoad(), which is now deprecated.
dvander@717
   139
 * Plugins still using the old forward will work.
dvander@643
   140
 */
dvander@717
   141
forward OnMapStart();
dvander@643
   142
dvander@643
   143
/**
dvander@718
   144
 * Called right before a map ends.
dvander@718
   145
 */
dvander@718
   146
forward OnMapEnd();
dvander@718
   147
dvander@718
   148
/**
dvander@978
   149
 * Called when the map has loaded, servercfgfile (server.cfg) has been 
dvander@978
   150
 * executed, and all plugin configs are done executing.  This is the best
dvander@1732
   151
 * place to initialize plugin functions which are based on cvar data.  
dvander@723
   152
 *
dvander@978
   153
 * @note This will always be called once and only once per map.  It will be 
dvander@978
   154
 * called after OnMapStart().
dvander@978
   155
 *
dvander@978
   156
 * @noreturn
dvander@723
   157
 */
dvander@978
   158
forward OnConfigsExecuted();
dvander@723
   159
dvander@723
   160
/**
dvander@979
   161
 * @deprecated Use OnConfigsExecuted() instead.
dvander@979
   162
 */
ds@1268
   163
#pragma deprecated Use OnConfigsExecuted() instead
dvander@979
   164
forward OnServerCfg();
dvander@979
   165
dvander@979
   166
/**
dvander@1630
   167
 * Called after all plugins have been loaded.  This is called once for 
dvander@1630
   168
 * every plugin.  If a plugin late loads, it will be called immediately 
dvander@1630
   169
 * after OnPluginStart().
faluco@1221
   170
 */
faluco@1221
   171
forward OnAllPluginsLoaded();
faluco@1221
   172
faluco@1221
   173
/**
dvander@1378
   174
 * Called when an action is going to be logged.
dvander@1378
   175
 *
dvander@1378
   176
 * @param source		Handle to the object logging the action, or INVALID_HANDLE 
dvander@1378
   177
 *						if Core is logging the action.
dvander@1378
   178
 * @param ident			Type of object logging the action (plugin, ext, or core).
dvander@1378
   179
 * @param client		Client the action is from; 0 for server, -1 if not applicable.
dvander@1378
   180
 * @param target		Client the action is targetting, or -1 if not applicable.
dvander@1378
   181
 * @param message		Message that is being logged.
dvander@1378
   182
 * @return				Plugin_Continue will cause Core to defaulty log the message.
dvander@1378
   183
 *						Plugin_Handled will stop Core from logging the message.
dvander@1378
   184
 * 						Plugin_Stop is the same as Handled, but prevents any other 
dvander@1378
   185
 *						plugins from handling the message.
dvander@1378
   186
 */
dvander@1378
   187
forward Action:OnLogAction(Handle:source, 
dvander@1378
   188
						   Identity:ident,
dvander@1378
   189
						   client,
dvander@1378
   190
						   target,
dvander@1378
   191
						   const String:message[]);
dvander@1378
   192
dvander@1378
   193
/**
dvander@536
   194
 * Returns the calling plugin's Handle.
dvander@536
   195
 *
dvander@536
   196
 * @return				Handle of the calling plugin.
dvander@536
   197
 */
dvander@536
   198
native Handle:GetMyHandle();
dvander@536
   199
dvander@618
   200
/**
dvander@618
   201
 * Returns an iterator that can be used to search through plugins.
dvander@618
   202
 *
dvander@618
   203
 * @return				Handle to iterate with.  Must be closed via 
dvander@618
   204
 * 						CloseHandle().
dvander@618
   205
 * @error				Invalid Handle.
dvander@618
   206
 */
dvander@618
   207
native Handle:GetPluginIterator();
dvander@618
   208
dvander@618
   209
/**
dvander@618
   210
 * Returns whether there are more plugins available in the iterator.
dvander@618
   211
 *
dvander@618
   212
 * @param iter			Handle to the plugin iterator.
dvander@618
   213
 * @return				True on more plugins, false otherwise.
dvander@618
   214
 * @error				Invalid Handle.
dvander@618
   215
 */
dvander@618
   216
native bool:MorePlugins(Handle:iter);
dvander@618
   217
dvander@618
   218
/**
dvander@618
   219
 * Returns the current plugin in the iterator and advances the iterator.
dvander@618
   220
 *
dvander@618
   221
 * @param iter			Handle to the plugin iterator.
dvander@618
   222
 * @return				Current plugin the iterator is at, before
dvander@618
   223
 *						the iterator is advanced.
dvander@618
   224
 * @error				Invalid Handle.
dvander@618
   225
 */
dvander@618
   226
native Handle:ReadPlugin(Handle:iter);
dvander@618
   227
dvander@618
   228
/**
dvander@618
   229
 * Returns a plugin's status.
dvander@618
   230
 *
dvander@618
   231
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   232
 * @return				Status code for the plugin.
dvander@618
   233
 * @error				Invalid Handle.
dvander@618
   234
 */
dvander@618
   235
native PluginStatus:GetPluginStatus(Handle:plugin);
dvander@618
   236
dvander@618
   237
/**
dvander@618
   238
 * Retrieves a plugin's file name relative to the plugins folder.
dvander@618
   239
 *
dvander@618
   240
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   241
 * @param buffer		Buffer to the store the file name.
dvander@618
   242
 * @param maxlength		Maximum length of the name buffer.
dvander@618
   243
 * @noreturn
dvander@618
   244
 * @error				Invalid Handle.
dvander@618
   245
 */
dvander@618
   246
native GetPluginFilename(Handle:plugin, String:buffer[], maxlength);
dvander@618
   247
dvander@618
   248
/**
dvander@618
   249
 * Retrieves whether or not a plugin is being debugged.
dvander@618
   250
 *
dvander@618
   251
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   252
 * @return				True if being debugged, false otherwise.
dvander@618
   253
 * @error				Invalid Handle.
dvander@618
   254
 */
dvander@618
   255
native bool:IsPluginDebugging(Handle:hndl);
dvander@618
   256
dvander@618
   257
/**
dvander@618
   258
 * Retrieves a plugin's public info.
dvander@618
   259
 *
dvander@618
   260
 * @param plugin		Plugin Handle (INVALID_HANDLE uses the calling plugin).
dvander@618
   261
 * @param info			Plugin info property to retrieve.
dvander@618
   262
 * @param buffer		Buffer to store info in.
dvander@618
   263
 * @param maxlength		Maximum length of buffer.
dvander@618
   264
 * @return				True on success, false if property is not available.
dvander@618
   265
 * @error				Invalid Handle.
dvander@618
   266
 */
dvander@618
   267
native bool:GetPluginInfo(Handle:plugin, PluginInfo:info, String:buffer[], maxlength);
dvander@560
   268
dvander@560
   269
/**
dvander@1798
   270
 * Finds a plugin by its order in the list from the "plugins list" server 
dvander@1798
   271
 * "sm" command.  You should not use this function to loop through all plugins, 
dvander@1798
   272
 * use the iterator instead.  Looping through all plugins using this native 
dvander@1798
   273
 * is O(n^2), whereas using the iterator is O(n).
dvander@1798
   274
 *
dvander@1798
   275
 * @param order_num		Number of the plugin as it appears in "sm plugins list".
dvander@1798
   276
 * @return				Plugin Handle on success, INVALID_HANDLE if no plugin 
dvander@1798
   277
 *						matches the given number.
dvander@1798
   278
 */
dvander@1798
   279
native Handle:FindPluginByNumber(order_num);
dvander@1798
   280
dvander@1798
   281
/**
dvander@837
   282
 * Causes the plugin to enter a failed state.  An error will be thrown and
dvander@837
   283
 * the plugin will be paused until it is unloaded or reloaded.
dvander@837
   284
 *
dvander@1833
   285
 * For backwards compatibility, if no extra arguments are passed, no 
dvander@1833
   286
 * formatting is applied.  If one or more additional arguments is passed, 
dvander@1833
   287
 * the string is formatted using Format().  If any errors are encountered 
dvander@1833
   288
 * during formatting, both the format specifier string and an additional 
dvander@1833
   289
 * error message are written.
dvander@1833
   290
 *
dvander@1833
   291
 * This function does not return, and no further code in the plugin is 
dvander@1833
   292
 * executed.
dvander@1833
   293
 *
dvander@1833
   294
 * @param string		Format specifier string.
dvander@1833
   295
 * @param ...			Formatting arguments.
dvander@837
   296
 * @noreturn
dvander@838
   297
 * @error				Always throws SP_ERROR_ABORT.
dvander@837
   298
 */
dvander@1833
   299
native SetFailState(const String:string[], any:...);
dvander@837
   300
dvander@837
   301
/**
dvander@560
   302
 * Aborts the current callback and throws an error.  This function
dvander@560
   303
 * does not return in that no code is executed following it.
dvander@560
   304
 *
dvander@560
   305
 * @param format		String format.
dvander@560
   306
 * @param ...			Format arguments.
dvander@560
   307
 * @noreturn
dvander@560
   308
 * @error				Always!
dvander@560
   309
 */
ds@634
   310
native ThrowError(const String:fmt[], any:...);
dvander@560
   311
dvander@536
   312
/**
dvander@1378
   313
 * Logs a plugin message to the SourceMod logs.  The log message will be 
dvander@1378
   314
 * prefixed by the plugin's logtag (filename).
dvander@429
   315
 *
ds@475
   316
 * @param format		String format.
ds@475
   317
 * @param ...			Format arguments.
dvander@429
   318
 * @noreturn
dvander@429
   319
 */
ds@634
   320
native LogMessage(const String:format[], any:...);
dvander@429
   321
dvander@429
   322
/**
dvander@1378
   323
 * Logs a message to the SourceMod logs without any plugin logtag.  This is 
dvander@1378
   324
 * useful for re-routing messages from other plugins, for example, messages 
dvander@1378
   325
 * from LogAction().
dvander@1378
   326
 *
dvander@1378
   327
 * @param format		String format.
dvander@1378
   328
 * @param ...			Format arguments.
dvander@1378
   329
 * @noreturn
dvander@1378
   330
 */
dvander@1378
   331
native LogMessageEx(const String:format[], any:...);
dvander@1378
   332
dvander@1378
   333
/**
dvander@1378
   334
 * Logs a message to any file.  The log message will be in the normal 
dvander@1378
   335
 * SourceMod format, with the plugin logtag prepended.
dvander@1378
   336
 *
dvander@1378
   337
 * @param file			File to write the log message in.
dvander@1378
   338
 * @param format		String format.
dvander@1378
   339
 * @param ...			Format arguments.
dvander@1378
   340
 * @noreturn
dvander@1378
   341
 * @error				File could not be opened/written.
dvander@1378
   342
 */
dvander@1378
   343
native LogToFile(const String:file[], const String:format[], any:...);
dvander@1378
   344
dvander@1378
   345
/**
dvander@1378
   346
 * Same as LogToFile(), except no plugin logtag is prepended.
dvander@1378
   347
 *
dvander@1378
   348
 * @param file			File to write the log message in.
dvander@1378
   349
 * @param format		String format.
dvander@1378
   350
 * @param ...			Format arguments.
dvander@1378
   351
 * @noreturn
dvander@1378
   352
 * @error				File could not be opened/written.
dvander@1378
   353
 */
dvander@1378
   354
native LogToFileEx(const String:file[], const String:format[], any:...);
dvander@1378
   355
dvander@1378
   356
/**
dvander@1378
   357
 * Logs an action from a command or event whereby interception and routing may 
dvander@1378
   358
 * be important.  This is intended to be a logging version of ShowActivity().
dvander@1378
   359
 *
dvander@1378
   360
 * @param client		Client performing the action, 0 for server, or -1 if not 
dvander@1378
   361
 *						applicable.
dvander@1378
   362
 * @param target		Client being targetted, or -1 if not applicable.
dvander@1378
   363
 * @param message		Message format.
dvander@1378
   364
 * @param ...			Message formatting parameters.
dvander@1378
   365
 * @noreturn
dvander@1378
   366
 */
dvander@1378
   367
native LogAction(client, target, const String:message[], any:...);
dvander@1378
   368
dvander@1378
   369
/**
dvander@429
   370
 * Logs a plugin error message to the SourceMod logs.
dvander@429
   371
 *
ds@475
   372
 * @param format		String format.
ds@475
   373
 * @param ...			Format arguments.
dvander@429
   374
 * @noreturn
dvander@429
   375
 */
ds@634
   376
native LogError(const String:format[], any:...);
dvander@460
   377
dvander@530
   378
/**
dvander@595
   379
 * Gets the system time as a unix timestamp.
dvander@595
   380
 *
dvander@595
   381
 * @param bigStamp		Optional array to store the 64bit timestamp in.
dvander@595
   382
 * @return				32bit timestamp (number of seconds since unix epoch).
dvander@595
   383
 */
dvander@595
   384
native GetTime(bigStamp[2]={0,0});
dvander@595
   385
dvander@595
   386
/**
dvander@1334
   387
 * Produces a date and/or time string value for a timestamp.
dvander@1334
   388
 *
dvander@1334
   389
 * See this URL for valid parameters: 
dvander@1334
   390
 * http://opengroup.org/onlinepubs/007908799/xsh/strftime.html
faluco@1037
   391
 *
faluco@1037
   392
 * @param buffer		Destination string buffer.
faluco@1037
   393
 * @param maxlength		Maximum length of output string buffer.
faluco@1359
   394
 * @param format		Formatting rules (passing NULL_STRING will use the rules defined in sm_datetime_format).
faluco@1041
   395
 * @param stamp			Optional time stamp.
faluco@1037
   396
 * @noreturn
dvander@1334
   397
 * @error			Buffer too small or invalid time format.
faluco@1037
   398
 */
faluco@1041
   399
native FormatTime(String:buffer[], maxlength, const String:format[], stamp=-1);
faluco@1037
   400
faluco@1037
   401
/**
faluco@703
   402
 * Loads a game config file.
faluco@703
   403
 *
faluco@703
   404
 * @param file			File to load.  The path must be relative to the 'gamedata' folder under the config folder 
faluco@703
   405
 *					and the extension should be omitted.
faluco@703
   406
 * @return			A handle to the game config file or INVALID_HANDLE in failure.
faluco@703
   407
 */
faluco@703
   408
native Handle:LoadGameConfigFile(const String:file[]);
faluco@703
   409
faluco@703
   410
/**
faluco@703
   411
 * Returns an offset value.
faluco@703
   412
 *
faluco@703
   413
 * @param gc			Game config handle.
faluco@703
   414
 * @param key			Key to retrieve from the offset section.
faluco@703
   415
 * @return			An offset, or -1 on failure.
faluco@703
   416
 */
faluco@703
   417
native GameConfGetOffset(Handle:gc, const String:key[]);
faluco@703
   418
faluco@703
   419
/**
faluco@703
   420
 * Gets the value of a key from the "Keys" section.
faluco@703
   421
 *
faluco@703
   422
 * @param gc			Game config handle.
faluco@703
   423
 * @param key			Key to retrieve from the Keys section.
faluco@703
   424
 * @param buffer		Destination string buffer.
faluco@703
   425
 * @param maxlen		Maximum length of output string buffer.
dvander@886
   426
 * @return				True if key existed, false otherwise.
faluco@703
   427
 */
faluco@703
   428
native bool:GameConfGetKeyValue(Handle:gc, const String:key[], String:buffer[], maxlen);
faluco@703
   429
dvander@886
   430
/**
dvander@886
   431
 * Returns the operating system's "tick count," which is a number of 
dvander@886
   432
 * milliseconds since the operating system loaded.  This can be used
dvander@886
   433
 * for basic benchmarks.
dvander@886
   434
 *
dvander@886
   435
 * @return				Tick count in milliseconds.
dvander@886
   436
 */
dvander@886
   437
native GetSysTickCount();
dvander@886
   438
dvander@978
   439
/**
dvander@978
   440
 * Specifies that the given config file should be executed after plugin load.
dvander@978
   441
 * OnConfigsExecuted() will not be called until the config file has executed, 
dvander@978
   442
 * but it will be called if the execution fails.
dvander@978
   443
 *
dvander@978
   444
 * @param autoCreate	If true, and the config file does not exist, such a config
dvander@978
   445
 *						file will be automatically created and populated with
dvander@978
   446
 *						information from the plugin's registered cvars.
dvander@978
   447
 * @param name			Name of the config file, excluding the .cfg extension.
dvander@978
   448
 *						If empty, <plugin.filename.cfg> is assumed.
dvander@978
   449
 * @param folder		Folder under cfg/ to use.  By default this is "sourcemod."
dvander@978
   450
 * @noreturn
dvander@978
   451
 */
dvander@978
   452
native AutoExecConfig(bool:autoCreate=true, const String:name[]="", const String:folder[]="sourcemod");
dvander@978
   453
faluco@1112
   454
/**
faluco@1112
   455
 * Sets a native as optional, such that if it is unloaded, removed,
faluco@1112
   456
 * or otherwise non-existent, the plugin will still work.  Calling
faluco@1112
   457
 * removed natives results in a run-time error.
faluco@1112
   458
 *
faluco@1112
   459
 * @param name			Native name.
faluco@1112
   460
 * @noreturn
faluco@1112
   461
 */
faluco@1112
   462
native MarkNativeAsOptional(const String:name[]);
faluco@1112
   463
faluco@1112
   464
/**
faluco@1112
   465
 * Registers a library name for identifying as a dependency to 
faluco@1112
   466
 * other plugins.
faluco@1112
   467
 *
faluco@1112
   468
 * @param name			Library name.
faluco@1112
   469
 * @noreturn
faluco@1112
   470
 */
faluco@1112
   471
native RegPluginLibrary(const String:name[]);
faluco@1112
   472
dvander@1124
   473
/**
dvander@1573
   474
 * Returns whether a library exists.  This function should be considered 
dvander@1573
   475
 * expensive; it should only be called on plugin to determine availability 
dvander@1573
   476
 * of resources.  Use OnLibraryAdded()/OnLibraryRemoved() to detect changes 
dvander@1573
   477
 * in optional resources.
dvander@1124
   478
 *
dvander@1573
   479
 * @param name			Library name of a plugin or extension.
dvander@1124
   480
 * @return				True if exists, false otherwise.
dvander@1124
   481
 */
dvander@1124
   482
native bool:LibraryExists(const String:name[]);
dvander@1124
   483
dvander@1124
   484
/**
dvander@1419
   485
 * Returns the status of an extension, by filename.
dvander@1419
   486
 *
dvander@1419
   487
 * @param name			Extension name (like "sdktools.ext").
dvander@1419
   488
 * @param error			Optional error message buffer.
dvander@1419
   489
 * @param maxlength		Length of optional error message buffer.
dvander@1419
   490
 * @return				-2 if the extension was not found.
dvander@1419
   491
 *						-1 if the extension was found but failed to load.
dvander@1419
   492
 * 						 0 if the extension loaded but reported an error.
dvander@1419
   493
 * 						 1 if the extension is running without error.
dvander@1419
   494
 */
dvander@1419
   495
native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength=0);
dvander@1419
   496
dvander@1419
   497
/**
dvander@1572
   498
 * Called after a library is added that the current plugin references 
dvander@1572
   499
 * optionally. A library is either a plugin name or extension name, as 
dvander@1572
   500
 * exposed via its include file.
dvander@1124
   501
 *
dvander@1124
   502
 * @param name			Library name.
dvander@1124
   503
 */
dvander@1124
   504
forward OnLibraryAdded(const String:name[]);
dvander@1124
   505
dvander@1124
   506
/**
dvander@1572
   507
 * Called right before a library is removed that the current plugin references 
dvander@1572
   508
 * optionally.  A library is either a plugin name or extension name, as 
dvander@1572
   509
 * exposed via its include file.
dvander@1124
   510
 *
dvander@1124
   511
 * @param name			Library name.
dvander@1124
   512
 */
dvander@1124
   513
forward OnLibraryRemoved(const String:name[]);
dvander@1124
   514
dvander@1738
   515
#define MAPLIST_FLAG_MAPSFOLDER		(1<<0)		/**< On failure, use all maps in the maps folder. */
dvander@1738
   516
#define MAPLIST_FLAG_CLEARARRAY		(1<<1)		/**< If an input array is specified, clear it before adding. */
dvander@1738
   517
#define MAPLIST_FLAG_NO_DEFAULT		(1<<2)		/**< Do not read "default" or "mapcyclefile" on failure. */
dvander@1738
   518
dvander@1738
   519
/**
dvander@1738
   520
 * Loads a map list to an ADT Array.
dvander@1738
   521
 *
dvander@1738
   522
 * A map list is a list of maps from a file.  SourceMod allows easy configuration of 
dvander@1738
   523
 * maplists through addons/sourcemod/configs/maplists.cfg.  Each entry is given a 
dvander@1738
   524
 * name and a file (for example, "rtv" => "rtv.cfg"), or a name and a redirection 
dvander@1738
   525
 * (for example, "rtv" => "default").  This native will read a map list entry, 
dvander@1738
   526
 * cache the file, and return the list of maps it holds.  
dvander@1738
   527
 *
dvander@1738
   528
 * Serial change numbers are used to identify if a map list has changed.  Thus, if 
dvander@1738
   529
 * you pass a serial change number and it's equal to what SourceMod currently knows 
dvander@1738
   530
 * about the map list, then SourceMod won't reparse the file.
dvander@1738
   531
 *
dvander@1738
   532
 * If the maps end up being read from the maps folder (MAPLIST_FLAG_MAPSFOLDER), they 
dvander@1738
   533
 * are automatically sorted in alphabetical, ascending order.
dvander@1738
   534
 *
dvander@1739
   535
 * Arrays created by this function are temporary and must be freed via CloseHandle().
dvander@1739
   536
 * Modifying arrays created by this function will not affect future return values or 
dvander@1739
   537
 * or the contents of arrays returned to other plugins.
dvander@1739
   538
 *
dvander@1738
   539
 * @param array			Array to store the map list.  If INVALID_HANDLE, a new blank 
dvander@1738
   540
 *						array will be created.  The blocksize should be at least 16; 
dvander@1738
   541
 *						otherwise results may be truncated.  Items are added to the array 
dvander@1738
   542
 *						as strings.  The array is never checked for duplicates, and it is 
dvander@1738
   543
 *						not read beforehand.  Only the serial number is used to detect 
dvander@1738
   544
 *						changes.
dvander@1772
   545
 * @param serial		Serial number to identify last known map list change.  If -1, the 
dvander@1772
   546
 *						the value will not be checked.  If the map list has since changed, 
dvander@1772
   547
 *						the serial is updated (even if -1 was passed).  If there is an error 
dvander@1772
   548
 *						finding a valid maplist, then the serial is set to -1.
dvander@1738
   549
 * @param str			Config name, or "default" for the default map list.  Config names 
dvander@1738
   550
 *						should be somewhat descriptive.  For example, the admin menu uses 
dvander@1738
   551
 *						a config name of "admin menu".  The list names can be configured 
dvander@1738
   552
 *						by users in addons/sourcemod/configs/maplists.cfg.
dvander@1738
   553
 * @param flags			MAPLIST_FLAG flags.
dvander@1738
   554
 * @return				On failure:
dvander@1738
   555
 *						 INVALID_HANDLE is returned, the serial is set to -1, and the input 
dvander@1738
   556
 *						 array (if any) is left unchanged.
dvander@1738
   557
 *						On no change:
dvander@1738
   558
 						 INVALID_HANDLE is returned, the serial is unchanged, and the input 
dvander@1738
   559
 						 array (if any) is left unchanged.
dvander@1738
   560
 *						On success:
dvander@1738
   561
 *						 A valid array Handle is returned, containing at least one map string.  
dvander@1738
   562
 *						 If an array was passed, the return value is equal to the passed Array 
dvander@1738
   563
 *						 Handle.  If the passed array was not cleared, it will have grown by at 
dvander@1738
   564
 *						 least one item.  The serial number is updated to a positive number.
dvander@1738
   565
 * @error				Invalid array Handle that is not INVALID_HANDLE.
dvander@1738
   566
 */
dvander@1738
   567
native Handle:ReadMapList(Handle:array=INVALID_HANDLE,
dvander@1738
   568
						  &serial=-1,
dvander@1738
   569
						  const String:str[]="default",
dvander@1738
   570
						  flags=MAPLIST_FLAG_CLEARARRAY);
dvander@1738
   571
						  
dvander@1738
   572
/**
dvander@1738
   573
 * Makes a compatibility binding for map lists.  For example, if a function previously used 
dvander@1738
   574
 * "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that 
dvander@1738
   575
 * will be overridden if it's in the maplists.cfg file.
dvander@1738
   576
 *
dvander@1738
   577
 * @param name			Configuration name that would be used with ReadMapList().
dvander@1738
   578
 * @param file			Default file to use.
dvander@1738
   579
 * @noreturn
dvander@1738
   580
 */
dvander@1738
   581
native SetMapListCompatBind(const String:name[], const String:file[]);
dvander@1738
   582
dvander@460
   583
#include <helpers>
dvander@560
   584
#include <entity>
ferret99gt@1800
   585
#include <entity_prop_stocks>
dvander@1419
   586