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