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 _sourcemod_included
19 #define _sourcemod_included
23 const String:name[], /* Plugin Name */
24 const String:description[], /* Plugin Description */
25 const String:author[], /* Plugin Author */
26 const String:version[], /* Plugin Version */
27 const String:url[], /* Plugin URL */
40 #include <usermessages>
44 * Declare this as a struct in your plugin to expose its information.
47 * public Plugin:myinfo =
56 * Called when the plugin is fully initialized and all known external references are resolved.
57 * This is called even if the plugin type is "private."
58 * NOTE: Errors in this function will cause the plugin to stop running.
62 forward OnPluginStart();
65 * Called before OnPluginStart, in case the plugin wants to check for load failure.
66 * This is called even if the plugin type is "private." Any natives from modules are
67 * not available at this point. Thus, this forward should only be used for explicit
68 * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
70 * NOTE: It is not safe to call externally resolved natives until OnPluginStart().
71 * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
73 * @param myself Handle to the plugin.
74 * @param late Whether or not the plugin was loaded "late" (after map load).
75 * @param error Error message buffer in case load failed.
76 * @param err_max Maximum number of characters for error message buffer.
77 * @return True if load success, false otherwise.
79 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
82 * Called when the plugin is about to be unloaded.
86 forward OnPluginEnd();
89 * Called when the plugin's pause status is changing.
91 * @param pause True if the plugin is being paused, false otherwise.
94 forward OnPluginPauseChange(bool:pause);
97 * Called before every server frame. Note that you should avoid
98 * doing expensive computations here, and you should declare large
99 * local arrays using 'decl' instead of 'new'.
101 forward OnGameFrame();
104 * Returns the calling plugin's Handle.
106 * @return Handle of the calling plugin.
108 native Handle:GetMyHandle();
112 * Aborts the current callback and throws an error. This function
113 * does not return in that no code is executed following it.
115 * @param format String format.
116 * @param ... Format arguments.
120 native ThrowError(const String:fmt[], {Handle,Float,String,_}:...);
123 * Logs a generic message to the HL2 logs.
125 * @param format String format.
126 * @param ... Format arguments.
129 native LogToGame(const String:format[], {Handle,Float,String,_}:...);
132 * Logs a plugin message to the SourceMod logs.
134 * @param format String format.
135 * @param ... Format arguments.
138 native LogMessage(const String:format[], {Handle,Float,String,_}:...);
141 * Logs a plugin error message to the SourceMod logs.
143 * @param format String format.
144 * @param ... Format arguments.
147 native LogError(const String:format[], {Handle,Float,String,_}:...);
150 * Gets the system time as a unix timestamp.
152 * @param bigStamp Optional array to store the 64bit timestamp in.
153 * @return 32bit timestamp (number of seconds since unix epoch).
155 native GetTime(bigStamp[2]={0,0});
158 * Sets the seed value for the global Half-Life 2 Random Stream
160 * @param seed Seed value.
163 native SetRandomSeed(seed);
166 * Returns a random floating point number from the Half-Life 2 Random Stream
168 * @param fMin Minimum random bound.
169 * @param fMax Maximum random bound.
170 * @return A random number between (inclusive) fMin and fMax.
172 native Float:GetRandomFloat(Float:fMin=0.0, Float:fMax=1.0);
175 * Returns a random number from the Half-Life 2 Random Stream
177 * @param nmin Minimum random bound.
178 * @param nmax Maximum random bound.
179 * @return A random number between (inclusive) nmin and nmax.
181 native GetRandomInt(nmin, nmax);
184 * Returns whether a map is valid or not.
186 * @param Map name, excluding .bsp extension.
187 * @return True if valid, false otherwise.
189 native bool:IsMapValid(const String:map[]);
192 * Returns whether the server is dedicated.
194 * @return True if dedicated, false otherwise.
196 native bool:IsDedicatedServer();
199 * Returns a high-precision time value for profiling the engine.
201 * @return A floating point time value.
203 native Float:GetEngineTime();
206 * Returns the game time based on the game tick.
208 * @return Game tick time.
210 native Float:GetGameTime();
213 * Returns the game description from the mod.
215 * @param buffer Buffer to store the description.
216 * @param maxlength Maximum size of the buffer.
217 * @param original If true, retrieves the original game description,
218 * ignoring any potential hooks from plugins.
219 * @return Number of bytes written to the buffer (UTF-8 safe).
221 native GetGameDescription(String:buffer[], maxlength, bool:original=false);
224 * Returns the current map name.
226 * @param buffer Buffer to store map name.
227 * @param maxlength Maximum length of buffer.
228 * @return Number of bytes written (UTF-8 safe).
230 native GetCurrentMap(String:buffer[], maxlength);