3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _halflife_included
19 #define _halflife_included
23 DialogType_Msg = 0, /**< just an on screen message */
24 DialogType_Menu, /**< an options menu */
25 DialogType_Text, /**< a richtext dialog */
26 DialogType_Entry /**< an entry box */
30 * Logs a generic message to the HL2 logs.
32 * @param format String format.
33 * @param ... Format arguments.
36 native LogToGame(const String:format[], any:...);
39 * Sets the seed value for the global Half-Life 2 Random Stream.
41 * @param seed Seed value.
44 native SetRandomSeed(seed);
47 * Returns a random floating point number from the Half-Life 2 Random Stream.
49 * @param fMin Minimum random bound.
50 * @param fMax Maximum random bound.
51 * @return A random number between (inclusive) fMin and fMax.
53 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
56 * Returns a random number from the Half-Life 2 Random Stream.
58 * @param nmin Minimum random bound.
59 * @param nmax Maximum random bound.
60 * @return A random number between (inclusive) nmin and nmax.
62 native GetRandomInt(nmin, nmax);
65 * Returns whether a map is valid or not.
67 * @param Map name, excluding .bsp extension.
68 * @return True if valid, false otherwise.
70 native bool:IsMapValid(const String:map[]);
73 * Returns whether the server is dedicated.
75 * @return True if dedicated, false otherwise.
77 native bool:IsDedicatedServer();
80 * Returns a high-precision time value for profiling the engine.
82 * @return A floating point time value.
84 native Float:GetEngineTime();
87 * Returns the game time based on the game tick.
89 * @return Game tick time.
91 native Float:GetGameTime();
94 * Returns the game description from the mod.
96 * @param buffer Buffer to store the description.
97 * @param maxlength Maximum size of the buffer.
98 * @param original If true, retrieves the original game description,
99 * ignoring any potential hooks from plugins.
100 * @return Number of bytes written to the buffer (UTF-8 safe).
102 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
105 * Returns the name of the game's directory.
107 * @param buffer Buffer to store the directory name.
108 * @param maxlength Maximum size of the buffer.
110 * return Number of bytes written to the buffer (UTF-8 safe).
112 native GetGameFolderName(String:buffer[], maxlength);
115 * Returns the current map name.
117 * @param buffer Buffer to store map name.
118 * @param maxlength Maximum length of buffer.
119 * @return Number of bytes written (UTF-8 safe).
121 native GetCurrentMap(String:buffer[], maxlength);
124 * Precaches a given model.
126 * @param model Name of the model to precache.
127 * @param preload If preload is true the file will be precached before level startup.
128 * @return Returns the model index, 0 for error.
130 native PrecacheModel(const String:model[], bool:preload=false);
133 * Precaches a given sentence file.
135 * @param file Name of the sentence file to precache.
136 * @param preload If preload is true the file will be precached before level startup.
137 * @return Returns a sentence file index.
139 native PrecacheSentenceFile(const String:file[], bool:preload=false);
142 * Precaches a given decal.
144 * @param decal Name of the decal to precache.
145 * @param preload If preload is true the file will be precached before level startup.
146 * @return Returns a decal index.
148 native PrecacheDecal(const String:decal[], bool:preload=false);
151 * Precaches a given generic file.
153 * @param generic Name of the generic file to precache.
154 * @param preload If preload is true the file will be precached before level startup.
155 * @return Returns a generic file index.
157 native PrecacheGeneric(const String:generic[], bool:preload=false);
160 * Returns if a given model is precached.
162 * @param model Name of the model to check.
163 * @return True if precached, false otherwise.
165 native bool:IsModelPrecached(const String:model[]);
168 * Returns if a given decal is precached.
170 * @param decal Name of the decal to check.
171 * @return True if precached, false otherwise.
173 native bool:IsDecalPrecached(const String:decal[]);
176 * Returns if a given generic file is precached.
178 * @param decal Name of the generic file to check.
179 * @return True if precached, false otherwise.
181 native bool:IsGenericPrecached(const String:generic[]);
184 * Precaches a given sound.
186 * @param sound Name of the sound to precache.
187 * @param preload If preload is true the file will be precached before level startup.
188 * @return True if successfully precached, false otherwise.
190 native bool:PrecacheSound(const String:sound[], bool:preload=false);
193 * Returns if a given sound is precached.
195 * @param sound Name of the sound to check.
196 * @return True if precached, false otherwise.
198 native bool:IsSoundPrecached(const String:sound[]);
201 * Creates different types of ingame messages.
203 * @param client Index of the client.
204 * @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
205 * @param type Message type to display ingame.
207 * @error Invalid client index, or client not connected.
209 native CreateDialog(client, Handle:kv, DialogType:type);
212 * Prints a message to a specific client in the chat area.
214 * @param client Client index.
215 * @param format Formatting rules.
216 * @param ... Variable number of format parameters.
218 * @error If the client is not connected an error will be thrown.
220 native PrintToChat(client, const String:format[], any:...);
223 * Prints a message to all clients in the chat area.
225 * @param format Formatting rules.
226 * @param ... Variable number of format parameters.
229 stock PrintToChatAll(const String:format[], any:...)
231 new maxClients = GetMaxClients();
232 decl String:buffer[192];
234 for (new i = 1; i <= maxClients; i++)
236 if (IsClientInGame(i))
238 SetGlobalTransTarget(i);
239 VFormat(buffer, sizeof(buffer), format, 2);
240 PrintToChat(i, "%s", buffer);
246 * Prints a message to a specific client in the center of the screen.
248 * @param client Client index.
249 * @param format Formatting rules.
250 * @param ... Variable number of format parameters.
252 * @error If the client is not connected an error will be thrown.
254 native PrintCenterText(client, const String:format[], any:...);
257 * Prints a message to all clients in the center of the screen.
259 * @param format Formatting rules.
260 * @param ... Variable number of format parameters.
263 stock PrintCenterTextAll(const String:format[], any:...)
265 new maxClients = GetMaxClients();
266 decl String:buffer[192];
268 VFormat(buffer, sizeof(buffer), format, 2);
270 for (new i = 1; i <= maxClients; i++)
272 if (IsClientInGame(i))
274 PrintCenterText(i, "%s", buffer);