New stock to get m_fFlags, and #defines for its bits.
3 * =============================================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
33 #if defined _halflife_included
36 #define _halflife_included
38 #define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */
39 #define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */
40 #define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */
41 #define SOURCE_SDK_EPISODE2 30 /**< Engine released after Episode 2 (no SDK yet) */
43 #define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */
44 #define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */
45 #define MOTDPANEL_TYPE_URL 2 /**< Treat msg as an URL link */
46 #define MOTDPANEL_TYPE_FILE 3 /**< Treat msg as a filename to be openned */
50 DialogType_Msg = 0, /**< just an on screen message */
51 DialogType_Menu, /**< an options menu */
52 DialogType_Text, /**< a richtext dialog */
53 DialogType_Entry, /**< an entry box */
54 DialogType_AskConnect /**< ask the client to connect to a specified IP */
58 * Logs a generic message to the HL2 logs.
60 * @param format String format.
61 * @param ... Format arguments.
64 native LogToGame(const String:format[], any:...);
67 * Sets the seed value for the global Half-Life 2 Random Stream.
69 * @param seed Seed value.
72 native SetRandomSeed(seed);
75 * Returns a random floating point number from the Half-Life 2 Random Stream.
77 * @param fMin Minimum random bound.
78 * @param fMax Maximum random bound.
79 * @return A random number between (inclusive) fMin and fMax.
81 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
84 * Returns a random number from the Half-Life 2 Random Stream.
86 * @param nmin Minimum random bound.
87 * @param nmax Maximum random bound.
88 * @return A random number between (inclusive) nmin and nmax.
90 native GetRandomInt(nmin, nmax);
93 * Returns whether a map is valid or not.
95 * @param Map name, excluding .bsp extension.
96 * @return True if valid, false otherwise.
98 native bool:IsMapValid(const String:map[]);
101 * Returns whether the server is dedicated.
103 * @return True if dedicated, false otherwise.
105 native bool:IsDedicatedServer();
108 * Returns a high-precision time value for profiling the engine.
110 * @return A floating point time value.
112 native Float:GetEngineTime();
115 * Returns the game time based on the game tick.
117 * @return Game tick time.
119 native Float:GetGameTime();
122 * Returns the game description from the mod.
124 * @param buffer Buffer to store the description.
125 * @param maxlength Maximum size of the buffer.
126 * @param original If true, retrieves the original game description,
127 * ignoring any potential hooks from plugins.
128 * @return Number of bytes written to the buffer (UTF-8 safe).
130 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
133 * Returns the name of the game's directory.
135 * @param buffer Buffer to store the directory name.
136 * @param maxlength Maximum size of the buffer.
138 * return Number of bytes written to the buffer (UTF-8 safe).
140 native GetGameFolderName(String:buffer[], maxlength);
143 * Returns the current map name.
145 * @param buffer Buffer to store map name.
146 * @param maxlength Maximum length of buffer.
147 * @return Number of bytes written (UTF-8 safe).
149 native GetCurrentMap(String:buffer[], maxlength);
152 * Precaches a given model.
154 * @param model Name of the model to precache.
155 * @param preload If preload is true the file will be precached before level startup.
156 * @return Returns the model index, 0 for error.
158 native PrecacheModel(const String:model[], bool:preload=false);
161 * Precaches a given sentence file.
163 * @param file Name of the sentence file to precache.
164 * @param preload If preload is true the file will be precached before level startup.
165 * @return Returns a sentence file index.
167 native PrecacheSentenceFile(const String:file[], bool:preload=false);
170 * Precaches a given decal.
172 * @param decal Name of the decal to precache.
173 * @param preload If preload is true the file will be precached before level startup.
174 * @return Returns a decal index.
176 native PrecacheDecal(const String:decal[], bool:preload=false);
179 * Precaches a given generic file.
181 * @param generic Name of the generic file to precache.
182 * @param preload If preload is true the file will be precached before level startup.
183 * @return Returns a generic file index.
185 native PrecacheGeneric(const String:generic[], bool:preload=false);
188 * Returns if a given model is precached.
190 * @param model Name of the model to check.
191 * @return True if precached, false otherwise.
193 native bool:IsModelPrecached(const String:model[]);
196 * Returns if a given decal is precached.
198 * @param decal Name of the decal to check.
199 * @return True if precached, false otherwise.
201 native bool:IsDecalPrecached(const String:decal[]);
204 * Returns if a given generic file is precached.
206 * @param decal Name of the generic file to check.
207 * @return True if precached, false otherwise.
209 native bool:IsGenericPrecached(const String:generic[]);
212 * Precaches a given sound.
214 * @param sound Name of the sound to precache.
215 * @param preload If preload is true the file will be precached before level startup.
216 * @return True if successfully precached, false otherwise.
218 native bool:PrecacheSound(const String:sound[], bool:preload=false);
221 * Returns if a given sound is precached.
223 * @param sound Name of the sound to check.
224 * @return True if precached, false otherwise.
226 native bool:IsSoundPrecached(const String:sound[]);
229 * Creates different types of ingame messages.
231 * @param client Index of the client.
232 * @param kv KeyValues handle to set the menu keys and options. (Check iserverplugin.h for more information).
233 * @param type Message type to display ingame.
235 * @error Invalid client index, or client not connected.
237 native CreateDialog(client, Handle:kv, DialogType:type);
240 * Guesses the SDK version a mod was compiled against. If nothing
241 * specific is known about the game, the engine version is used instead.
243 * The return values are guaranteed to increase chronologically (that is,
244 * a later release will have a higher value).
246 * @return SOURCE_SDK version code.
248 native GuessSDKVersion();
251 * Prints a message to a specific client in the chat area.
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 PrintToChat(client, const String:format[], any:...);
262 * Prints a message to all clients in the chat area.
264 * @param format Formatting rules.
265 * @param ... Variable number of format parameters.
268 stock PrintToChatAll(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 PrintToChat(i, "%s", buffer);
285 * Prints a message to a specific client in the center of the screen.
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 PrintCenterText(client, const String:format[], any:...);
296 * Prints a message to all clients in the center of the screen.
298 * @param format Formatting rules.
299 * @param ... Variable number of format parameters.
302 stock PrintCenterTextAll(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 PrintCenterText(i, "%s", buffer);
319 * Prints a message to a specific client with a hint box.
321 * @param client Client index.
322 * @param format Formatting rules.
323 * @param ... Variable number of format parameters.
325 * @error If the client is not connected an error will be thrown.
327 native PrintHintText(client, const String:format[], any:...);
330 * Prints a message to all clients with a hint box.
332 * @param format Formatting rules.
333 * @param ... Variable number of format parameters.
336 stock PrintHintTextToAll(const String:format[], any:...)
338 new maxClients = GetMaxClients();
339 decl String:buffer[192];
341 for (new i = 1; i <= maxClients; i++)
343 if (IsClientInGame(i))
345 SetGlobalTransTarget(i);
346 VFormat(buffer, sizeof(buffer), format, 2);
347 PrintHintText(i, "%s", buffer);
353 * Shows a VGUI panel to a specific client.
355 * @param client Client index.
356 * @param name Panel type name (Check viewport_panel_names.h to see a list of some panel names).
357 * @param Kv KeyValues handle with all the data for the panel setup (Depends on the panel type and may be unused).
358 * @param show True to show the panel, or false to remove it from the client screen.
360 * @error If the client is not connected an error will be thrown.
362 native ShowVGUIPanel(client, const String:name[], Handle:Kv=INVALID_HANDLE, bool:show=true);
365 * Shows a MOTD panel to a specific client.
367 * @param client Client index.
368 * @param title Title of the panel (printed on the top border of the window).
369 * @param msg Contents of the panel, it can be treated as an url, filename or plain text
370 * depending on the type parameter (WARNING: msg has to be 192 bytes maximum!)
371 * @param type Determines the way to treat the message body of the panel.
373 * @error If the client is not connected an error will be thrown.
375 stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDPANEL_TYPE_INDEX)
378 new Handle:Kv = CreateKeyValues("data");
379 IntToString(type, num, sizeof(num));
381 KvSetString(Kv, "title", title);
382 KvSetString(Kv, "type", num);
383 KvSetString(Kv, "msg", msg);
384 ShowVGUIPanel(client, "info", Kv);
389 * Displays a panel asking the client to connect to a specified IP.
391 * @param client Client index.
392 * @param time Duration to hold the panel on the client's screen.
393 * @param ip Destionation IP.
396 stock DisplayAskConnectBox(client, Float:time, const String:ip[])
398 new Handle:Kv = CreateKeyValues("data");
399 KvSetFloat(Kv, "time", time);
400 KvSetString(Kv, "title", ip);
401 CreateDialog(client, Kv, DialogType_AskConnect);