Updated license header.
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
21 #define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */
22 #define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */
23 #define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */
24 #define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be openned */
28 DialogType_Msg = 0, /**< just an on screen message */
29 DialogType_Menu, /**< an options menu */
30 DialogType_Text, /**< a richtext dialog */
31 DialogType_Entry /**< an entry box */
35 * Logs a generic message to the HL2 logs.
37 * @param format String format.
38 * @param ... Format arguments.
41 native LogToGame(const String:format[], any:...);
44 * Sets the seed value for the global Half-Life 2 Random Stream.
46 * @param seed Seed value.
49 native SetRandomSeed(seed);
52 * Returns a random floating point number from the Half-Life 2 Random Stream.
54 * @param fMin Minimum random bound.
55 * @param fMax Maximum random bound.
56 * @return A random number between (inclusive) fMin and fMax.
58 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
61 * Returns a random number from the Half-Life 2 Random Stream.
63 * @param nmin Minimum random bound.
64 * @param nmax Maximum random bound.
65 * @return A random number between (inclusive) nmin and nmax.
67 native GetRandomInt(nmin, nmax);
70 * Returns whether a map is valid or not.
72 * @param Map name, excluding .bsp extension.
73 * @return True if valid, false otherwise.
75 native bool:IsMapValid(const String:map[]);
78 * Returns whether the server is dedicated.
80 * @return True if dedicated, false otherwise.
82 native bool:IsDedicatedServer();
85 * Returns a high-precision time value for profiling the engine.
87 * @return A floating point time value.
89 native Float:GetEngineTime();
92 * Returns the game time based on the game tick.
94 * @return Game tick time.
96 native Float:GetGameTime();
99 * Returns the game description from the mod.
101 * @param buffer Buffer to store the description.
102 * @param maxlength Maximum size of the buffer.
103 * @param original If true, retrieves the original game description,
104 * ignoring any potential hooks from plugins.
105 * @return Number of bytes written to the buffer (UTF-8 safe).
107 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
110 * Returns the name of the game's directory.
112 * @param buffer Buffer to store the directory name.
113 * @param maxlength Maximum size of the buffer.
115 * return Number of bytes written to the buffer (UTF-8 safe).
117 native GetGameFolderName(String:buffer[], maxlength);
120 * Returns the current map name.
122 * @param buffer Buffer to store map name.
123 * @param maxlength Maximum length of buffer.
124 * @return Number of bytes written (UTF-8 safe).
126 native GetCurrentMap(String:buffer[], maxlength);
129 * Precaches a given model.
131 * @param model Name of the model to precache.
132 * @param preload If preload is true the file will be precached before level startup.
133 * @return Returns the model index, 0 for error.
135 native PrecacheModel(const String:model[], bool:preload=false);
138 * Precaches a given sentence file.
140 * @param file Name of the sentence file to precache.
141 * @param preload If preload is true the file will be precached before level startup.
142 * @return Returns a sentence file index.
144 native PrecacheSentenceFile(const String:file[], bool:preload=false);
147 * Precaches a given decal.
149 * @param decal Name of the decal to precache.
150 * @param preload If preload is true the file will be precached before level startup.
151 * @return Returns a decal index.
153 native PrecacheDecal(const String:decal[], bool:preload=false);
156 * Precaches a given generic file.
158 * @param generic Name of the generic file to precache.
159 * @param preload If preload is true the file will be precached before level startup.
160 * @return Returns a generic file index.
162 native PrecacheGeneric(const String:generic[], bool:preload=false);
165 * Returns if a given model is precached.
167 * @param model Name of the model to check.
168 * @return True if precached, false otherwise.
170 native bool:IsModelPrecached(const String:model[]);
173 * Returns if a given decal is precached.
175 * @param decal Name of the decal to check.
176 * @return True if precached, false otherwise.
178 native bool:IsDecalPrecached(const String:decal[]);
181 * Returns if a given generic file is precached.
183 * @param decal Name of the generic file to check.
184 * @return True if precached, false otherwise.
186 native bool:IsGenericPrecached(const String:generic[]);
189 * Precaches a given sound.
191 * @param sound Name of the sound to precache.
192 * @param preload If preload is true the file will be precached before level startup.
193 * @return True if successfully precached, false otherwise.
195 native bool:PrecacheSound(const String:sound[], bool:preload=false);
198 * Returns if a given sound is precached.
200 * @param sound Name of the sound to check.
201 * @return True if precached, false otherwise.
203 native bool:IsSoundPrecached(const String:sound[]);
206 * Creates different types of ingame messages.
208 * @param client Index of the client.
209 * @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
210 * @param type Message type to display ingame.
212 * @error Invalid client index, or client not connected.
214 native CreateDialog(client, Handle:kv, DialogType:type);
217 * Prints a message to a specific client in the chat area.
219 * @param client Client index.
220 * @param format Formatting rules.
221 * @param ... Variable number of format parameters.
223 * @error If the client is not connected an error will be thrown.
225 native PrintToChat(client, const String:format[], any:...);
228 * Prints a message to all clients in the chat area.
230 * @param format Formatting rules.
231 * @param ... Variable number of format parameters.
234 stock PrintToChatAll(const String:format[], any:...)
236 new maxClients = GetMaxClients();
237 decl String:buffer[192];
239 for (new i = 1; i <= maxClients; i++)
241 if (IsClientInGame(i))
243 SetGlobalTransTarget(i);
244 VFormat(buffer, sizeof(buffer), format, 2);
245 PrintToChat(i, "%s", buffer);
251 * Prints a message to a specific client in the center of the screen.
253 * @param client Client index.
254 * @param format Formatting rules.
255 * @param ... Variable number of format parameters.
257 * @error If the client is not connected an error will be thrown.
259 native PrintCenterText(client, const String:format[], any:...);
262 * Prints a message to all clients in the center of the screen.
264 * @param format Formatting rules.
265 * @param ... Variable number of format parameters.
268 stock PrintCenterTextAll(const String:format[], any:...)
270 new maxClients = GetMaxClients();
271 decl String:buffer[192];
273 for (new i = 1; i <= maxClients; i++)
275 if (IsClientInGame(i))
277 SetGlobalTransTarget(i);
278 VFormat(buffer, sizeof(buffer), format, 2);
279 PrintCenterText(i, "%s", buffer);
285 * Prints a message to a specific client with a hint box.
287 * @param client Client index.
288 * @param format Formatting rules.
289 * @param ... Variable number of format parameters.
291 * @error If the client is not connected an error will be thrown.
293 native PrintHintText(client, const String:format[], any:...);
296 * Prints a message to all clients with a hint box.
298 * @param format Formatting rules.
299 * @param ... Variable number of format parameters.
302 stock PrintHintTextToAll(const String:format[], any:...)
304 new maxClients = GetMaxClients();
305 decl String:buffer[192];
307 for (new i = 1; i <= maxClients; i++)
309 if (IsClientInGame(i))
311 SetGlobalTransTarget(i);
312 VFormat(buffer, sizeof(buffer), format, 2);
313 PrintHintText(i, "%s", buffer);
319 * Shows a VGUI panel to a specific client.
321 * @param client Client index.
322 * @param name Panel type name (Check viewport_panel_names.h to see a list of some panel names).
323 * @param Kv KeyValues handle with all the data for the panel setup (Depends on the panel type and may be unused).
324 * @param show True to show the panel, or false to remove it from the client screen.
326 * @error If the client is not connected an error will be thrown.
328 native ShowVGUIPanel(client, const String:name[], Handle:Kv=INVALID_HANDLE, bool:show=true);
331 * Shows a MOTD panel to a specific client.
333 * @param client Client index.
334 * @param title Title of the panel (printed on the top border of the window).
335 * @param msg Contents of the panel, it can be treated as an url, filename or plain text
336 * depending on the type parameter (WARNING: msg has to be 192 bytes maximum!)
337 * @param type Determines the way to treat the message body of the panel.
339 * @error If the client is not connected an error will be thrown.
341 stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDPANEL_TYPE_INDEX)
344 new Handle:Kv = CreateKeyValues("data");
345 IntToString(type, num, sizeof(num));
347 KvSetString(Kv, "title", title);
348 KvSetString(Kv, "type", num);
349 KvSetString(Kv, "msg", msg);
350 ShowVGUIPanel(client, "info", Kv);