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