plugins/include/halflife.inc
author Nicholas Hastings <skamonkey@gmail.com>
Mon Feb 08 20:14:52 2010 -0800 (2010-02-08)
changeset 2920 1d5645ab7ae0
parent 2894 8b7300d96395
child 3099 1b7bf8509625
permissions -rw-r--r--
Fixed base plugins using GetMaxClients() instead of MaxClients (bug 3985, r=dvander).
ds@873
     1
/**
ds@873
     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.
ds@873
     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>.
ds@873
    29
 *
ds@873
    30
 * Version: $Id$
ds@873
    31
 */
ds@873
    32
ds@873
    33
#if defined _halflife_included
ds@873
    34
 #endinput
ds@873
    35
#endif
ds@873
    36
#define _halflife_included
ds@873
    37
dvander@1837
    38
#define SOURCE_SDK_UNKNOWN			0		/**< Could not determine the engine version */
dvander@1837
    39
#define SOURCE_SDK_ORIGINAL			10		/**< Original Source engine (still used by "The Ship") */
ds@2583
    40
#define SOURCE_SDK_DARKMESSIAH		15		/**< Modified version of original engine used by Dark Messiah (no SDK) */
dvander@1837
    41
#define SOURCE_SDK_EPISODE1			20		/**< SDK+Engine released after Episode 1 */
ds@2400
    42
#define SOURCE_SDK_EPISODE2			30		/**< SDK+Engine released after Episode 2/Orange Box */
skamonkey@2893
    43
#define SOURCE_SDK_EPISODE2VALVE	35		/**< SDK+Engine released after Episode 2/Orange Box */
ds@2400
    44
#define SOURCE_SDK_LEFT4DEAD		40		/**< Engine released after Left 4 Dead (no SDK yet) */
skamonkey@2894
    45
#define SOURCE_SDK_LEFT4DEAD2		50		/**< Engine released after Left 4 Dead 2 (no SDK yet) */
dvander@1837
    46
faluco@1218
    47
dvander@1837
    48
#define MOTDPANEL_TYPE_TEXT		0	/**< Treat msg as plain text */
faluco@1218
    49
#define MOTDPANEL_TYPE_INDEX	1	/**< Msg is auto determined by the engine */
faluco@1218
    50
#define MOTDPANEL_TYPE_URL		2	/**< Treat msg as an URL link */
faluco@1218
    51
#define MOTDPANEL_TYPE_FILE		3	/**< Treat msg as a filename to be openned */
ds@873
    52
ds@873
    53
enum DialogType
ds@873
    54
{
ds@873
    55
	DialogType_Msg = 0,		/**< just an on screen message */
ds@873
    56
	DialogType_Menu, 		/**< an options menu */
faluco@1413
    57
	DialogType_Text, 		/**< a richtext dialog */
ds@2400
    58
	DialogType_Entry, 		/**< an entry box */
ds@873
    59
	DialogType_AskConnect	/**< ask the client to connect to a specified IP */
ds@873
    60
};
pred@2746
    61
pred@2746
    62
#define INVALID_ENT_REFERENCE 0xFFFFFFFF
ds@873
    63
ds@873
    64
/**
ds@873
    65
 * Logs a generic message to the HL2 logs.
ds@873
    66
 *
ds@873
    67
 * @param format		String format.
ds@873
    68
 * @param ...			Format arguments.
ds@873
    69
 * @noreturn
ds@873
    70
 */
ds@873
    71
native LogToGame(const String:format[], any:...);
ds@873
    72
dvander@1003
    73
/**
ds@873
    74
 * Sets the seed value for the global Half-Life 2 Random Stream.
ds@873
    75
 *
ds@873
    76
 * @param seed			Seed value.
ds@873
    77
 * @noreturn	
ds@873
    78
 */
ds@873
    79
native SetRandomSeed(seed);
ds@873
    80
dvander@1003
    81
/**
ds@873
    82
 * Returns a random floating point number from the Half-Life 2 Random Stream.
ds@873
    83
 *
ds@873
    84
 * @param fMin			Minimum random bound.
ds@873
    85
 * @param fMax			Maximum random bound.
ds@873
    86
 * @return				A random number between (inclusive) fMin and fMax.
ds@873
    87
 */
ds@873
    88
native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
ds@873
    89
dvander@1003
    90
/**
ds@873
    91
 * Returns a random number from the Half-Life 2 Random Stream.
ds@873
    92
 *
ds@873
    93
 * @param nmin			Minimum random bound.
ds@873
    94
 * @param nmax			Maximum random bound.
ds@873
    95
 * @return				A random number between (inclusive) nmin and nmax.
ds@873
    96
 */
ds@873
    97
native GetRandomInt(nmin, nmax);
ds@873
    98
ds@873
    99
/**
ds@873
   100
 * Returns whether a map is valid or not.
ds@873
   101
 * 
ds@873
   102
 * @param 				Map name, excluding .bsp extension.
ds@873
   103
 * @return				True if valid, false otherwise.
ds@873
   104
 */
ds@873
   105
native bool:IsMapValid(const String:map[]);
ds@873
   106
ds@873
   107
/**
ds@873
   108
 * Returns whether the server is dedicated.
ds@873
   109
 *
ds@873
   110
 * @return				True if dedicated, false otherwise.
ds@873
   111
 */
ds@873
   112
native bool:IsDedicatedServer();
ds@873
   113
ds@873
   114
/**
ds@873
   115
 * Returns a high-precision time value for profiling the engine.
ds@873
   116
 *
ds@873
   117
 * @return				A floating point time value.
ds@873
   118
 */
ds@873
   119
native Float:GetEngineTime();
ds@873
   120
ds@873
   121
/** 
ds@873
   122
 * Returns the game time based on the game tick.
ds@873
   123
 *
ds@873
   124
 * @return				Game tick time.
ds@873
   125
 */
ds@873
   126
native Float:GetGameTime();
ds@873
   127
ds@873
   128
/**
ds@873
   129
 * Returns the game description from the mod.
ds@873
   130
 *
ds@873
   131
 * @param buffer		Buffer to store the description.
ds@873
   132
 * @param maxlength		Maximum size of the buffer.
ds@873
   133
 * @param original		If true, retrieves the original game description,
ds@873
   134
 *						ignoring any potential hooks from plugins.
ds@873
   135
 * @return				Number of bytes written to the buffer (UTF-8 safe).
ds@873
   136
 */
ds@873
   137
native GetGameDescription(String:buffer[], maxlength, bool:original=false);
ds@873
   138
ds@873
   139
/**
ds@873
   140
 * Returns the name of the game's directory.
ds@873
   141
 *
ds@873
   142
 * @param buffer		Buffer to store the directory name.
ds@873
   143
 * @param maxlength		Maximum size of the buffer.
ds@873
   144
 *
ds@873
   145
 * return				Number of bytes written to the buffer (UTF-8 safe).
ds@873
   146
 */
ds@873
   147
native GetGameFolderName(String:buffer[], maxlength);
ds@873
   148
ds@873
   149
/**
ds@873
   150
 * Returns the current map name.
ds@873
   151
 *
ds@873
   152
 * @param buffer		Buffer to store map name.
ds@873
   153
 * @param maxlength		Maximum length of buffer.
ds@873
   154
 * @return				Number of bytes written (UTF-8 safe).
ds@873
   155
 */
ds@873
   156
native GetCurrentMap(String:buffer[], maxlength);
ds@873
   157
ds@873
   158
/**
ds@873
   159
 * Precaches a given model.
ds@873
   160
 *
ds@873
   161
 * @param model			Name of the model to precache.
ds@892
   162
 * @param preload		If preload is true the file will be precached before level startup.
ds@873
   163
 * @return				Returns the model index, 0 for error.
ds@873
   164
 */
ds@873
   165
native PrecacheModel(const String:model[], bool:preload=false);
ds@873
   166
ds@873
   167
/**
ds@873
   168
 * Precaches a given sentence file.
ds@873
   169
 *
ds@873
   170
 * @param file			Name of the sentence file to precache.
ds@892
   171
 * @param preload		If preload is true the file will be precached before level startup.
ds@873
   172
 * @return				Returns a sentence file index.
ds@873
   173
 */
ds@873
   174
native PrecacheSentenceFile(const String:file[], bool:preload=false);
ds@873
   175
ds@873
   176
/**
ds@873
   177
 * Precaches a given decal.
ds@873
   178
 *
ds@873
   179
 * @param decal			Name of the decal to precache.
ds@892
   180
 * @param preload		If preload is true the file will be precached before level startup.
ds@873
   181
 * @return				Returns a decal index.
ds@873
   182
 */
ds@873
   183
native PrecacheDecal(const String:decal[], bool:preload=false);
ds@873
   184
ds@873
   185
/**
ds@873
   186
 * Precaches a given generic file.
ds@873
   187
 *
ds@873
   188
 * @param generic		Name of the generic file to precache.
ds@892
   189
 * @param preload		If preload is true the file will be precached before level startup.
ds@873
   190
 * @return				Returns a generic file index.
ds@873
   191
 */
ds@873
   192
native PrecacheGeneric(const String:generic[], bool:preload=false);
ds@873
   193
ds@873
   194
/**
ds@873
   195
 * Returns if a given model is precached.
ds@873
   196
 *
ds@892
   197
 * @param model			Name of the model to check.
ds@873
   198
 * @return				True if precached, false otherwise.
ds@873
   199
 */
ds@873
   200
native bool:IsModelPrecached(const String:model[]);
ds@873
   201
ds@873
   202
/**
ds@873
   203
 * Returns if a given decal is precached.
ds@873
   204
 *
ds@892
   205
 * @param decal			Name of the decal to check.
ds@873
   206
 * @return				True if precached, false otherwise.
ds@873
   207
 */
ds@873
   208
native bool:IsDecalPrecached(const String:decal[]);
ds@873
   209
ds@873
   210
/**
ds@873
   211
 * Returns if a given generic file is precached.
ds@873
   212
 *
ds@892
   213
 * @param decal			Name of the generic file to check.
ds@873
   214
 * @return				True if precached, false otherwise.
ds@873
   215
 */
ds@873
   216
native bool:IsGenericPrecached(const String:generic[]);
ds@873
   217
ds@873
   218
/**
ds@873
   219
 * Precaches a given sound.
ds@873
   220
 *
ds@873
   221
 * @param sound			Name of the sound to precache.
ds@892
   222
 * @param preload		If preload is true the file will be precached before level startup.
ds@873
   223
 * @return				True if successfully precached, false otherwise.
ds@873
   224
 */
ds@873
   225
native bool:PrecacheSound(const String:sound[], bool:preload=false);
ds@873
   226
ds@873
   227
/**
ds@873
   228
 * Returns if a given sound is precached.
ds@873
   229
 *
ds@892
   230
 * @param sound			Name of the sound to check.
ds@873
   231
 * @return				True if precached, false otherwise.
ds@873
   232
 */
ds@873
   233
native bool:IsSoundPrecached(const String:sound[]);
ds@873
   234
ds@873
   235
/**
ds@873
   236
 * Creates different types of ingame messages.
ds@873
   237
 *
ds@873
   238
 * @param client		Index of the client.
ds@873
   239
 * @param kv			KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
ds@873
   240
 * @param type			Message type to display ingame.
ds@873
   241
 * @noreturn
ds@873
   242
 * @error				Invalid client index, or client not connected.
ds@873
   243
 */
ds@873
   244
native CreateDialog(client, Handle:kv, DialogType:type);
ds@873
   245
dvander@1837
   246
/**
dvander@1837
   247
 * Guesses the SDK version a mod was compiled against.  If nothing 
dvander@1837
   248
 * specific is known about the game, the engine version is used instead.
dvander@1837
   249
 *
dvander@1837
   250
 * The return values are guaranteed to increase chronologically (that is, 
dvander@1837
   251
 * a later release will have a higher value).
dvander@1837
   252
 *
dvander@1837
   253
 * @return				SOURCE_SDK version code.
dvander@1837
   254
 */
dvander@1837
   255
native GuessSDKVersion();
dvander@1837
   256
ds@892
   257
/**
ds@873
   258
 * Prints a message to a specific client in the chat area.
ds@892
   259
 *
ds@873
   260
 * @param client		Client index.
ds@873
   261
 * @param format		Formatting rules.
ds@873
   262
 * @param ...			Variable number of format parameters.
ds@873
   263
 * @noreturn
ds@873
   264
 * @error				If the client is not connected an error will be thrown.
ds@873
   265
 */
ds@873
   266
native PrintToChat(client, const String:format[], any:...);
ds@873
   267
ds@892
   268
/**
ds@873
   269
 * Prints a message to all clients in the chat area.
ds@892
   270
 *
ds@892
   271
 * @param format		Formatting rules.
ds@892
   272
 * @param ...			Variable number of format parameters.
ds@892
   273
 * @noreturn
ds@892
   274
 */
ds@892
   275
stock PrintToChatAll(const String:format[], any:...)
ds@898
   276
{
ds@892
   277
	decl String:buffer[192];
skamonkey@2920
   278
	
ds@892
   279
	for (new i = 1; i <= MaxClients; i++)
ds@892
   280
	{
ds@892
   281
		if (IsClientInGame(i))
dvander@1034
   282
		{
dvander@1034
   283
			SetGlobalTransTarget(i);
ds@892
   284
			VFormat(buffer, sizeof(buffer), format, 2);
ds@892
   285
			PrintToChat(i, "%s", buffer);
ds@892
   286
		}
ds@892
   287
	}
ds@892
   288
}
ds@892
   289
ds@892
   290
/**
ds@892
   291
 * Prints a message to a specific client in the center of the screen.
ds@892
   292
 *
ds@873
   293
 * @param client		Client index.
ds@873
   294
 * @param format		Formatting rules.
ds@873
   295
 * @param ...			Variable number of format parameters.
ds@873
   296
 * @noreturn
ds@873
   297
 * @error				If the client is not connected an error will be thrown.
ds@873
   298
 */
ds@892
   299
native PrintCenterText(client, const String:format[], any:...);
ds@892
   300
ds@892
   301
/**
ds@892
   302
 * Prints a message to all clients in the center of the screen.
ds@892
   303
 *
ds@892
   304
 * @param format		Formatting rules.
ds@892
   305
 * @param ...			Variable number of format parameters.
ds@892
   306
 * @noreturn
ds@892
   307
 */
ds@892
   308
stock PrintCenterTextAll(const String:format[], any:...)
ds@898
   309
{
teame06@1217
   310
	decl String:buffer[192];
skamonkey@2920
   311
ds@892
   312
	for (new i = 1; i <= MaxClients; i++)
ds@892
   313
	{
ds@892
   314
		if (IsClientInGame(i))
teame06@1217
   315
		{
teame06@1217
   316
			SetGlobalTransTarget(i);
ds@892
   317
			VFormat(buffer, sizeof(buffer), format, 2);
ds@892
   318
			PrintCenterText(i, "%s", buffer);
ds@892
   319
		}
ds@892
   320
	}
faluco@1218
   321
}
faluco@1218
   322
faluco@1218
   323
/**
faluco@1218
   324
 * Prints a message to a specific client with a hint box.
faluco@1218
   325
 *
faluco@1218
   326
 * @param client		Client index.
faluco@1218
   327
 * @param format		Formatting rules.
faluco@1218
   328
 * @param ...			Variable number of format parameters.
faluco@1218
   329
 * @noreturn
faluco@1218
   330
 * @error				If the client is not connected an error will be thrown.
faluco@1218
   331
 */
faluco@1218
   332
native PrintHintText(client, const String:format[], any:...);
faluco@1218
   333
faluco@1218
   334
/**
faluco@1218
   335
 * Prints a message to all clients with a hint box.
faluco@1218
   336
 *
faluco@1218
   337
 * @param format		Formatting rules.
faluco@1218
   338
 * @param ...			Variable number of format parameters.
faluco@1218
   339
 * @noreturn
faluco@1218
   340
 */
faluco@1218
   341
stock PrintHintTextToAll(const String:format[], any:...)
faluco@1218
   342
{
faluco@1218
   343
	decl String:buffer[192];
skamonkey@2920
   344
	
faluco@1218
   345
	for (new i = 1; i <= MaxClients; i++)
faluco@1218
   346
	{
faluco@1218
   347
		if (IsClientInGame(i))
faluco@1218
   348
		{
faluco@1218
   349
			SetGlobalTransTarget(i);
faluco@1218
   350
			VFormat(buffer, sizeof(buffer), format, 2);
faluco@1218
   351
			PrintHintText(i, "%s", buffer);
faluco@1218
   352
		}
faluco@1218
   353
	}
faluco@1218
   354
}
faluco@1218
   355
faluco@1218
   356
/**
faluco@1218
   357
 * Shows a VGUI panel to a specific client.
faluco@1218
   358
 *
dvander@1915
   359
 * @param client		Client index.
dvander@1915
   360
 * @param name			Panel type name (Check viewport_panel_names.h to see a list of 
dvander@1915
   361
 *						some panel names).
dvander@1915
   362
 * @param Kv			KeyValues handle with all the data for the panel setup (Depends 
faluco@1218
   363
 *						on the panel type and may be unused).
faluco@1218
   364
 * @param show			True to show the panel, or false to remove it from the client screen.
faluco@1218
   365
 * @noreturn
faluco@1218
   366
 * @error				If the client is not connected an error will be thrown.
faluco@1218
   367
 */
faluco@1218
   368
native ShowVGUIPanel(client, const String:name[], Handle:Kv=INVALID_HANDLE, bool:show=true);
faluco@1218
   369
dvander@1915
   370
/**
dvander@1915
   371
 * Creates a HUD synchronization object.  This object is used to automatically assign and 
dvander@1915
   372
 * re-use channels for a set of messages.  
dvander@1915
   373
 *
dvander@1915
   374
 * The HUD has a hardcoded number of channels (usually 6) for displaying 
dvander@1915
   375
 * text.  You can use any channel for any area of the screen.  Text on 
dvander@1915
   376
 * different channels can overlap, but text on the same channel will 
dvander@1915
   377
 * erase the old text first.  This overlapping and overwriting gets problematic.
dvander@1915
   378
 *
dvander@1915
   379
 * A HUD synchronization object automatically selects channels for you based on 
dvander@1915
   380
 * the following heuristics:
dvander@1915
   381
 *  - If channel X was last used by the object, and hasn't been modified again, 
dvander@1915
   382
 *    channel X gets re-used.
dvander@1915
   383
 *  - Otherwise, a new channel is chosen based on the least-recently-used channel.
dvander@1915
   384
 *
dvander@1915
   385
 * This ensures that if you display text on a sync object, that the previous text 
dvander@1915
   386
 * displayed on it will always be cleared first.  This is because your new text 
dvander@1915
   387
 * will either overwrite the old text on the same channel, or because another 
dvander@1915
   388
 * channel has already erased your text.
dvander@1915
   389
 *
dvander@1915
   390
 * Note that messages can still overlap if they are on different synchronization 
dvander@1915
   391
 * objects, or they are displayed to manual channels.
dvander@1915
   392
 *
dvander@1915
   393
 * These are particularly useful for displaying repeating or refreshing HUD text, in 
dvander@1915
   394
 * addition to displaying multiple message sets in one area of the screen (for example, 
dvander@1915
   395
 * center-say messages that may pop up randomly that you don't want to overlap each 
dvander@1915
   396
 * other).
dvander@1915
   397
 *
dvander@1915
   398
 * @return				New HUD synchronization object.
dvander@1915
   399
 *						The Handle can be closed with CloseHandle().
dvander@1915
   400
 *						If HUD text is not supported on this mod, then 
dvander@1915
   401
 *						INVALID_HANDLE is returned.
dvander@1915
   402
 */
dvander@1915
   403
native Handle:CreateHudSynchronizer();
dvander@1915
   404
dvander@1915
   405
/**
dvander@1915
   406
 * Sets the HUD parameters for drawing text.  These parameters are stored 
dvander@1915
   407
 * globally, although nothing other than this function and SetHudTextParamsEx 
dvander@1915
   408
 * modify them.
dvander@1915
   409
 *
dvander@1915
   410
 * You must call this function before drawing text.  If you are drawing 
dvander@1915
   411
 * text to multiple clients, you can set the parameters once, since 
dvander@1915
   412
 * they won't be modified.  However, as soon as you pass control back 
dvander@1915
   413
 * to other plugins, you must reset the parameters next time you draw.
dvander@1915
   414
 *
dvander@1915
   415
 * @param x				x coordinate, from 0 to 1.  -1.0 is the center.
dvander@1915
   416
 * @param y				y coordinate, from 0 to 1.  -1.0 is the center.
dvander@1915
   417
 * @param holdTime		Number of seconds to hold the text.
dvander@1915
   418
 * @param r				Red color value.
dvander@1915
   419
 * @param g				Green color value.
dvander@1915
   420
 * @param b				Blue color value.
dvander@1915
   421
 * @param a				Alpha transparency value.
dvander@1915
   422
 * @param effect 		0/1 causes the text to fade in and fade out.
dvander@1915
   423
 *						2 causes the text to flash[?].
dvander@1915
   424
 * @param fxTime		Duration of chosen effect (may not apply to all effects).
dvander@1915
   425
 * @param fadeIn		Number of seconds to spend fading in.
dvander@1915
   426
 * @param fadeOut		Number of seconds to spend fading out.
dvander@1915
   427
 * @noreturn
dvander@1915
   428
 */
dvander@1915
   429
native SetHudTextParams(Float:x, Float:y, Float:holdTime, r, g, b, a, effect = 0,
dvander@1915
   430
						Float:fxTime=6.0, Float:fadeIn=0.1, Float:fadeOut=0.2);
dvander@1915
   431
						
dvander@1915
   432
/**
dvander@1915
   433
 * Sets the HUD parameters for drawing text.  These parameters are stored 
dvander@1915
   434
 * globally, although nothing other than this function and SetHudTextParams
dvander@1915
   435
 * modify them.
dvander@1915
   436
 *
dvander@1915
   437
 * This is the same as SetHudTextParams(), except it lets you set the alternate 
dvander@1915
   438
 * color for when effects require it.  
dvander@1915
   439
 *
dvander@1915
   440
 * @param x				x coordinate, from 0 to 1.  -1.0 is the center.
dvander@1915
   441
 * @param y				y coordinate, from 0 to 1.  -1.0 is the center.
dvander@1915
   442
 * @param holdTime		Number of seconds to hold the text.
dvander@1915
   443
 * @param color1		First color set, array values being [red, green, blue, alpha]
dvander@1915
   444
 * @param color2		Second color set, array values being [red, green, blue, alpha]
dvander@1915
   445
 * @param effect 		0/1 causes the text to fade in and fade out.
dvander@1915
   446
 *						2 causes the text to flash[?].
dvander@1915
   447
 * @param fxTime		Duration of chosen effect (may not apply to all effects).
dvander@1915
   448
 * @param fadeIn		Number of seconds to spend fading in.
dvander@1915
   449
 * @param fadeOut		Number of seconds to spend fading out.
dvander@1915
   450
 * @noreturn
dvander@1915
   451
 */
dvander@1915
   452
native SetHudTextParamsEx(Float:x, Float:y, Float:holdTime, color1[4], 
dvander@1915
   453
						  color2[4]={255,255,255,0}, effect = 0, Float:fxTime=6.0, 
dvander@1915
   454
						  Float:fadeIn=0.1, Float:fadeOut=0.2);
dvander@1915
   455
dvander@1915
   456
/**
dvander@1915
   457
 * Shows a synchronized HUD message to a client.  
dvander@1915
   458
 *
dvander@1915
   459
 * As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
dvander@1915
   460
 *
dvander@1915
   461
 * @param client		Client index to send the message to.
dvander@1915
   462
 * @param sync			Synchronization object.
dvander@1915
   463
 * @param message		Message text or formatting rules.
dvander@1915
   464
 * @param ...			Message formatting parameters.
dvander@1915
   465
 * @return				-1 on failure, anything else on success.
dvander@1915
   466
 *						This function fails if the mod does not support it.
dvander@1915
   467
 * @error				Client not in-game, or sync object not valid.
dvander@1915
   468
 */
dvander@1915
   469
native ShowSyncHudText(client, Handle:sync, const String:message[], any:...);
dvander@1915
   470
dvander@1915
   471
/**
dvander@1915
   472
 * Clears the text on a synchronized HUD channel. 
dvander@1915
   473
 *
dvander@1915
   474
 * This is not the same as sending "" because it guarantees that it won't 
dvander@1915
   475
 * overwrite text on another channel.  For example, consider the scenario: 
dvander@1915
   476
 *
dvander@1915
   477
 * 1. Your synchronized message goes to channel 3.
dvander@1915
   478
 * 2. Someone else's non-synchronized message goes to channel 3.
dvander@1915
   479
 *
dvander@1915
   480
 * If you were to simply send "" on your synchronized message, 
dvander@1915
   481
 * then someone else's text could be overwritten.
dvander@1915
   482
 *
dvander@1915
   483
 * @param client		Client index to send the message to.
dvander@1915
   484
 * @param sync			Synchronization object.
dvander@1915
   485
 * @noreturn
dvander@1915
   486
 * @error				Client not in-game, or sync object not valid.
dvander@1915
   487
 */
dvander@1915
   488
native ClearSyncHud(client, Handle:sync);
dvander@1915
   489
dvander@1915
   490
/**
dvander@1915
   491
 * Shows a HUD message to a client on the given channel.
dvander@1915
   492
 *
dvander@1915
   493
 * As of this writing, only TF, HL2MP, and SourceForts support HUD Text.
dvander@1915
   494
 * 
dvander@1915
   495
 * @param client		Client index to send the message to.
dvander@1915
   496
 * @param channel		A channel number.
dvander@1915
   497
 *						If -1, then a channel will automatically be selected 
dvander@1915
   498
 *						based on the least-recently-used channel.  If the 
dvander@1915
   499
 *						channel is any other number, it will be modulo'd with 
dvander@1915
   500
 *						the channel count to get a final channel number.
dvander@1915
   501
 * @param message		Message text or formatting rules.
dvander@1915
   502
 * @param ...			Message formatting parameters.
dvander@1915
   503
 * @return				-1 on failure (lack of mod support).
dvander@1915
   504
 *						Any other return value is the channel number that was 
dvander@1915
   505
 *						used to render the text.
dvander@1915
   506
 */
dvander@1915
   507
native ShowHudText(client, channel, const String:message[], any:...);
dvander@1915
   508
faluco@1218
   509
/**
faluco@1218
   510
 * Shows a MOTD panel to a specific client.
faluco@1218
   511
 *
faluco@1218
   512
 * @param client		Client index.
faluco@1218
   513
 * @param title			Title of the panel (printed on the top border of the window).
dvander@1915
   514
 * @param msg			Contents of the panel, it can be treated as an url, filename or plain text
faluco@1218
   515
 *				 		depending on the type parameter (WARNING: msg has to be 192 bytes maximum!)
faluco@1218
   516
 * @param type			Determines the way to treat the message body of the panel.
faluco@1218
   517
 * @noreturn
faluco@1218
   518
 * @error				If the client is not connected an error will be thrown.
faluco@1218
   519
 */
faluco@1218
   520
stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDPANEL_TYPE_INDEX)
faluco@1218
   521
{
faluco@1218
   522
	decl String:num[3];
faluco@1218
   523
	new Handle:Kv = CreateKeyValues("data");
faluco@1218
   524
	IntToString(type, num, sizeof(num));
faluco@1218
   525
faluco@1218
   526
	KvSetString(Kv, "title", title);
faluco@1218
   527
	KvSetString(Kv, "type", num);
faluco@1218
   528
	KvSetString(Kv, "msg", msg);
faluco@1218
   529
	ShowVGUIPanel(client, "info", Kv);
faluco@1218
   530
	CloseHandle(Kv);
faluco@1413
   531
}
faluco@1413
   532
faluco@1413
   533
/**
faluco@1413
   534
 * Displays a panel asking the client to connect to a specified IP.
faluco@1413
   535
 *
faluco@1413
   536
 * @param client		Client index.
faluco@1413
   537
 * @param time			Duration to hold the panel on the client's screen.
faluco@1413
   538
 * @param ip			Destionation IP.
faluco@1413
   539
 * @noreturn
faluco@1413
   540
 */
faluco@1413
   541
stock DisplayAskConnectBox(client, Float:time, const String:ip[])
faluco@1413
   542
{
faluco@1413
   543
	new Handle:Kv = CreateKeyValues("data");
faluco@1413
   544
	KvSetFloat(Kv, "time", time);
faluco@1413
   545
	KvSetString(Kv, "title", ip);
faluco@1413
   546
	CreateDialog(client, Kv, DialogType_AskConnect);
faluco@1413
   547
	CloseHandle(Kv);
pred@2746
   548
}
pred@2746
   549
pred@2746
   550
/**
pred@2746
   551
 * Converts an entity index into a serial encoded entity reference.
pred@2746
   552
 *
pred@2746
   553
 * @param entity		Entity index.
pred@2746
   554
 * @return				Entity reference.
pred@2746
   555
 */
pred@2746
   556
native EntIndexToEntRef(entity);
pred@2746
   557
pred@2746
   558
/**
pred@2746
   559
 * Retrieves the entity index from a reference.
pred@2746
   560
 *
pred@2746
   561
 * @param ref			Entity reference.
pred@2746
   562
 * @return				Entity index.
pred@2746
   563
 */
pred@2746
   564
native EntRefToEntIndex(ref);
pred@2746
   565
pred@2746
   566
/**
pred@2746
   567
 * Converts a reference into a backwards compatible version.
pred@2746
   568
 *
pred@2746
   569
 * @param ref			Entity reference.
pred@2746
   570
 * @return				Bcompat reference.
pred@2746
   571
 */
pred@2746
   572
native MakeCompatEntRef(ref);