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