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