plugins/include/halflife.inc
author David Anderson <dvander@alliedmods.net>
Fri Jun 22 17:25:19 2007 +0000 (2007-06-22)
changeset 1003 9cfb161d1a55
parent 915 62c6fb7c533b
child 1034 5ac2c40f13de
permissions -rw-r--r--
tiny comment changes to halflife.inc
ds@873
     1
/**
ds@873
     2
 * vim: set ts=4 :
ds@873
     3
 * ===============================================================
ds@873
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@873
     5
 * ===============================================================
ds@873
     6
 *
ds@873
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
ds@873
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
ds@873
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
ds@873
    10
 * may change at any time.  To view the latest information, see:
ds@873
    11
 *   http://www.sourcemod.net/license.php
ds@873
    12
 *
ds@873
    13
 * Version: $Id$
ds@873
    14
 */
ds@873
    15
ds@873
    16
#if defined _halflife_included
ds@873
    17
 #endinput
ds@873
    18
#endif
ds@873
    19
#define _halflife_included
ds@873
    20
ds@873
    21
enum DialogType
ds@873
    22
{
ds@873
    23
	DialogType_Msg = 0,		/**< just an on screen message */
ds@873
    24
	DialogType_Menu, 		/**< an options menu */
ds@873
    25
	DialogType_Text, 		/**< a richtext dialog */
ds@873
    26
	DialogType_Entry 		/**< an entry box */
ds@873
    27
};
ds@873
    28
ds@873
    29
/**
ds@873
    30
 * Logs a generic message to the HL2 logs.
ds@873
    31
 *
ds@873
    32
 * @param format		String format.
ds@873
    33
 * @param ...			Format arguments.
ds@873
    34
 * @noreturn
ds@873
    35
 */
ds@873
    36
native LogToGame(const String:format[], any:...);
ds@873
    37
ds@873
    38
/**
dvander@1003
    39
 * Sets the seed value for the global Half-Life 2 Random Stream.
ds@873
    40
 *
ds@873
    41
 * @param seed			Seed value.
ds@873
    42
 * @noreturn	
ds@873
    43
 */
ds@873
    44
native SetRandomSeed(seed);
ds@873
    45
ds@873
    46
/**
dvander@1003
    47
 * Returns a random floating point number from the Half-Life 2 Random Stream.
ds@873
    48
 *
ds@873
    49
 * @param fMin			Minimum random bound.
ds@873
    50
 * @param fMax			Maximum random bound.
ds@873
    51
 * @return				A random number between (inclusive) fMin and fMax.
ds@873
    52
 */
ds@873
    53
native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
ds@873
    54
ds@873
    55
/**
dvander@1003
    56
 * Returns a random number from the Half-Life 2 Random Stream.
ds@873
    57
 *
ds@873
    58
 * @param nmin			Minimum random bound.
ds@873
    59
 * @param nmax			Maximum random bound.
ds@873
    60
 * @return				A random number between (inclusive) nmin and nmax.
ds@873
    61
 */
ds@873
    62
native GetRandomInt(nmin, nmax);
ds@873
    63
ds@873
    64
/**
ds@873
    65
 * Returns whether a map is valid or not.
ds@873
    66
 * 
ds@873
    67
 * @param 				Map name, excluding .bsp extension.
ds@873
    68
 * @return				True if valid, false otherwise.
ds@873
    69
 */
ds@873
    70
native bool:IsMapValid(const String:map[]);
ds@873
    71
ds@873
    72
/**
ds@873
    73
 * Returns whether the server is dedicated.
ds@873
    74
 *
ds@873
    75
 * @return				True if dedicated, false otherwise.
ds@873
    76
 */
ds@873
    77
native bool:IsDedicatedServer();
ds@873
    78
ds@873
    79
/**
ds@873
    80
 * Returns a high-precision time value for profiling the engine.
ds@873
    81
 *
ds@873
    82
 * @return				A floating point time value.
ds@873
    83
 */
ds@873
    84
native Float:GetEngineTime();
ds@873
    85
ds@873
    86
/** 
ds@873
    87
 * Returns the game time based on the game tick.
ds@873
    88
 *
ds@873
    89
 * @return				Game tick time.
ds@873
    90
 */
ds@873
    91
native Float:GetGameTime();
ds@873
    92
ds@873
    93
/**
ds@873
    94
 * Returns the game description from the mod.
ds@873
    95
 *
ds@873
    96
 * @param buffer		Buffer to store the description.
ds@873
    97
 * @param maxlength		Maximum size of the buffer.
ds@873
    98
 * @param original		If true, retrieves the original game description,
ds@873
    99
 *						ignoring any potential hooks from plugins.
ds@873
   100
 * @return				Number of bytes written to the buffer (UTF-8 safe).
ds@873
   101
 */
ds@873
   102
native GetGameDescription(String:buffer[], maxlength, bool:original=false);
ds@873
   103
ds@873
   104
/**
ds@873
   105
 * Returns the name of the game's directory.
ds@873
   106
 *
ds@873
   107
 * @param buffer		Buffer to store the directory name.
ds@873
   108
 * @param maxlength		Maximum size of the buffer.
ds@873
   109
 *
ds@873
   110
 * return				Number of bytes written to the buffer (UTF-8 safe).
ds@873
   111
 */
ds@873
   112
native GetGameFolderName(String:buffer[], maxlength);
ds@873
   113
ds@873
   114
/**
ds@873
   115
 * Returns the current map name.
ds@873
   116
 *
ds@873
   117
 * @param buffer		Buffer to store map name.
ds@873
   118
 * @param maxlength		Maximum length of buffer.
ds@873
   119
 * @return				Number of bytes written (UTF-8 safe).
ds@873
   120
 */
ds@873
   121
native GetCurrentMap(String:buffer[], maxlength);
ds@873
   122
ds@873
   123
/**
ds@873
   124
 * Precaches a given model.
ds@873
   125
 *
ds@873
   126
 * @param model			Name of the model to precache.
ds@873
   127
 * @param preload		If preload is true the file will be precached before level startup.
ds@892
   128
 * @return				Returns the model index, 0 for error.
ds@873
   129
 */
ds@873
   130
native PrecacheModel(const String:model[], bool:preload=false);
ds@873
   131
ds@873
   132
/**
ds@873
   133
 * Precaches a given sentence file.
ds@873
   134
 *
ds@873
   135
 * @param file			Name of the sentence file to precache.
ds@873
   136
 * @param preload		If preload is true the file will be precached before level startup.
ds@892
   137
 * @return				Returns a sentence file index.
ds@873
   138
 */
ds@873
   139
native PrecacheSentenceFile(const String:file[], bool:preload=false);
ds@873
   140
ds@873
   141
/**
ds@873
   142
 * Precaches a given decal.
ds@873
   143
 *
ds@873
   144
 * @param decal			Name of the decal to precache.
ds@873
   145
 * @param preload		If preload is true the file will be precached before level startup.
ds@892
   146
 * @return				Returns a decal index.
ds@873
   147
 */
ds@873
   148
native PrecacheDecal(const String:decal[], bool:preload=false);
ds@873
   149
ds@873
   150
/**
ds@873
   151
 * Precaches a given generic file.
ds@873
   152
 *
ds@873
   153
 * @param generic		Name of the generic file to precache.
ds@873
   154
 * @param preload		If preload is true the file will be precached before level startup.
ds@892
   155
 * @return				Returns a generic file index.
ds@873
   156
 */
ds@873
   157
native PrecacheGeneric(const String:generic[], bool:preload=false);
ds@873
   158
ds@873
   159
/**
ds@873
   160
 * Returns if a given model is precached.
ds@873
   161
 *
ds@873
   162
 * @param model			Name of the model to check.
ds@892
   163
 * @return				True if precached, false otherwise.
ds@873
   164
 */
ds@873
   165
native bool:IsModelPrecached(const String:model[]);
ds@873
   166
ds@873
   167
/**
ds@873
   168
 * Returns if a given decal is precached.
ds@873
   169
 *
ds@873
   170
 * @param decal			Name of the decal to check.
ds@892
   171
 * @return				True if precached, false otherwise.
ds@873
   172
 */
ds@873
   173
native bool:IsDecalPrecached(const String:decal[]);
ds@873
   174
ds@873
   175
/**
ds@873
   176
 * Returns if a given generic file is precached.
ds@873
   177
 *
ds@873
   178
 * @param decal			Name of the generic file to check.
ds@892
   179
 * @return				True if precached, false otherwise.
ds@873
   180
 */
ds@873
   181
native bool:IsGenericPrecached(const String:generic[]);
ds@873
   182
ds@873
   183
/**
ds@873
   184
 * Precaches a given sound.
ds@873
   185
 *
ds@873
   186
 * @param sound			Name of the sound to precache.
ds@873
   187
 * @param preload		If preload is true the file will be precached before level startup.
ds@892
   188
 * @return				True if successfully precached, false otherwise.
ds@873
   189
 */
ds@873
   190
native bool:PrecacheSound(const String:sound[], bool:preload=false);
ds@873
   191
ds@873
   192
/**
ds@873
   193
 * Returns if a given sound is precached.
ds@873
   194
 *
ds@873
   195
 * @param sound			Name of the sound to check.
ds@892
   196
 * @return				True if precached, false otherwise.
ds@873
   197
 */
ds@873
   198
native bool:IsSoundPrecached(const String:sound[]);
ds@873
   199
ds@873
   200
/**
ds@873
   201
 * Creates different types of ingame messages.
ds@873
   202
 *
ds@873
   203
 * @param client		Index of the client.
ds@873
   204
 * @param kv			KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
ds@873
   205
 * @param type			Message type to display ingame.
ds@873
   206
 * @noreturn
ds@873
   207
 * @error				Invalid client index, or client not connected.
ds@873
   208
 */
ds@873
   209
native CreateDialog(client, Handle:kv, DialogType:type);
ds@873
   210
ds@873
   211
/**
ds@892
   212
 * Prints a message to a specific client in the chat area.
ds@873
   213
 *
ds@892
   214
 * @param client		Client index.
ds@873
   215
 * @param format		Formatting rules.
ds@873
   216
 * @param ...			Variable number of format parameters.
ds@873
   217
 * @noreturn
ds@873
   218
 * @error				If the client is not connected an error will be thrown.
ds@873
   219
 */
ds@873
   220
native PrintToChat(client, const String:format[], any:...);
ds@873
   221
ds@873
   222
/**
ds@892
   223
 * Prints a message to all clients in the chat area.
ds@873
   224
 *
ds@892
   225
 * @param format		Formatting rules.
ds@892
   226
 * @param ...			Variable number of format parameters.
ds@892
   227
 * @noreturn
ds@892
   228
 */
ds@892
   229
stock PrintToChatAll(const String:format[], any:...)
ds@892
   230
{
ds@915
   231
	new maxClients = GetMaxClients();
ds@898
   232
	decl String:buffer[192];
ds@892
   233
	
ds@892
   234
	VFormat(buffer, sizeof(buffer), format, 2);
ds@892
   235
	
ds@915
   236
	for (new i = 1; i <= maxClients; i++)
ds@892
   237
	{
ds@892
   238
		if (IsClientInGame(i))
ds@892
   239
		{
ds@892
   240
			PrintToChat(i, "%s", buffer);
ds@892
   241
		}
ds@892
   242
	}
ds@892
   243
}
ds@892
   244
ds@892
   245
/**
ds@892
   246
 * Prints a message to a specific client in the center of the screen.
ds@892
   247
 *
ds@892
   248
 * @param client		Client index.
ds@873
   249
 * @param format		Formatting rules.
ds@873
   250
 * @param ...			Variable number of format parameters.
ds@873
   251
 * @noreturn
ds@873
   252
 * @error				If the client is not connected an error will be thrown.
ds@873
   253
 */
ds@873
   254
native PrintCenterText(client, const String:format[], any:...);
ds@892
   255
ds@892
   256
/**
ds@892
   257
 * Prints a message to all clients in the center of the screen.
ds@892
   258
 *
ds@892
   259
 * @param format		Formatting rules.
ds@892
   260
 * @param ...			Variable number of format parameters.
ds@892
   261
 * @noreturn
ds@892
   262
 */
ds@892
   263
stock PrintCenterTextAll(const String:format[], any:...)
ds@892
   264
{
ds@915
   265
	new maxClients = GetMaxClients();
ds@898
   266
	decl String:buffer[192];
ds@892
   267
	
ds@892
   268
	VFormat(buffer, sizeof(buffer), format, 2);
ds@892
   269
	
ds@915
   270
	for (new i = 1; i <= maxClients; i++)
ds@892
   271
	{
ds@892
   272
		if (IsClientInGame(i))
ds@892
   273
		{
ds@892
   274
			PrintCenterText(i, "%s", buffer);
ds@892
   275
		}
ds@892
   276
	}
ds@892
   277
}