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
13 * Version: $Id: sourcemod.inc 432 2007-02-02 22:47:14Z damagedsoul $
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 */
39 * Declare this as a struct in your plugin to expose its information.
42 * public Plugin:myinfo =
51 * Called when the plugin is fully initialized and all known external references are resolved.
52 * This is called even if the plugin type is "private."
53 * NOTE: Errors in this function will cause the plugin to stop running.
57 forward OnPluginStart(Handle:myself);
60 * Called before OnPluginStart, in case the plugin wants to check for load failure.
61 * This is called even if the plugin type is "private." Any natives from modules are
62 * not available at this point. Thus, this forward should only be used for explicit
63 * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
65 * NOTE: It is not safe to call externally resolved natives until OnPluginStart().
66 * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
68 * @param myself Handle to the plugin.
69 * @param late Whether or not the plugin was loaded "late" (after map load).
70 * @param error Error message buffer in case load failed.
71 * @param err_max Maximum number of characters for error message buffer.
72 * @return True if load success, false otherwise.
74 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
77 * Called when the plugin is about to be unloaded.
81 forward OnPluginEnd();
84 * Called when the plugin's pause status is changing.
86 * @param pause True if the plugin is being paused, false otherwise.
89 forward OnPluginPauseChange(bool:pause);
92 * Called on client connection.
94 * @param client Player index.
95 * @param rejectmsg Buffer to store the rejection message when the connection is refused.
96 * @param maxlen Maximum number of characters for rejection buffer.
97 * @return True to validate client's connection, false to refuse it.
99 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
102 * Called when a client is entering to the game.
104 * @param client Player index.
107 forward OnClientPutInServer(client);
110 * Called when a client is disconnecting from the server.
112 * @param client Player index.
115 forward OnClientDisconnect(client);
118 * Called when a client is disconnected from the server.
120 * @param client Player index.
123 forward OnClientDisconnect_Post(client);
126 * Called when a client is sending a command.
128 * @param client Player index.
131 forward OnClientCommand(client, argCount);
134 * Called whenever the client's settings are changed.
136 * @param client Player index.
139 forward OnClientSettingsChanged(client);
142 * Called when a client receives a Steam ID.
143 * @note This is called by bots, but the ID will be "BOT"
145 * @param client Player index.
146 * @param auth Player auth string.
148 forward OnClientAuthorized(client, const String:auth[]);
151 * Returns the maximum number of clients allowed on the server.
153 * @return Maximum number of clients allowed.
155 native GetMaxClients();
158 * Returns the client count put in the server.
160 * @param inGameOnly If false connecting players are also counted.
161 * @return Client count in the server.
163 native GetClientCount(bool:inGameOnly=true);
166 * Returns the client's name.
168 * @param client Player index.
169 * @param name Buffer to store the client's name.
170 * @param maxlen Maximum length of string buffer (includes NULL terminator).
171 * @return True on success, false otherwise.
172 * @error If the client is not connected an error will be thrown.
174 native bool:GetClientName(client, String:name[], maxlen);
177 * Retrieves a client's IP address.
179 * @param client Player index.
180 * @param name Buffer to store the client's ip address.
181 * @param maxlen Maximum length of string buffer (includes NULL terminator).
182 * @param remport Remove client's port from the ip string (true by default).
183 * @return True on success, false otherwise.
184 * @error If the client is not connected or the index is invalid.
186 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
189 * Retrieves a client's authentication string (SteamID).
191 * @param client Player index.
192 * @param auth Buffer to store the client's auth string.
193 * @param maxlen Maximum length of string buffer (includes NULL terminator).
194 * @return True on success, false otherwise.
195 * @error If the client is not connected or the index is invalid.
197 native bool:GetClientAuthString(client, String:auth[], maxlen);
200 * Retrieves a client's user id, which is an index incremented for every client
201 * that joins the server.
203 * @param client Player index.
204 * @return User id of the client.
205 * @error If the client is not connected or the index is invalid.
207 native GetClientUserId(client);
210 * Returns if a certain player is connected.
212 * @param client Player index.
213 * @return True if player is connected to the server, false otherwise.
215 native bool:IsClientConnected(client);
218 * Returns if a certain player has entered the game.
220 * @param client Player index.
221 * @return True if player has entered the game, false otherwise.
223 native bool:IsPlayerInGame(client);
226 * Returns if a certain player has been authenticated.
228 * @param client Player index.
229 * @return True if player has been authenticated, false otherwise.
231 native bool:IsClientAuthorized(client);
234 * Returns if a certain player is a fake client.
236 * @param client Player index.
237 * @return True if player is a fake client, false otherwise.
239 native bool:IsFakeClient(client);
242 * Retrieves values from client replicated keys.
244 * @param client Player's index.
245 * @param key Key string.
246 * @param value Buffer to store value.
247 * @param maxlen Maximum length of valve (UTF-8 safe).
248 * @return True on success, false otherwise.
249 * @error Invalid client index, or client not connected.
251 native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
254 * Sets a client's AdminId.
256 * @param client Player's index.
257 * @param id AdminId to set. INVALID_ADMIN_ID removes admin permissions.
258 * @param temp True if the id should be freed on disconnect.
260 * @error Invalid client index, client not connected, or bogus AdminId.
262 native SetUserAdmin(client, AdminId:id, bool:temp=false);
265 * Retrieves a client's AdminId.
267 * @param client Player's index.
268 * @return AdminId of the client, or INVALID_ADMIN_ID if none.
269 * @error Invalid client index, or client not connected.
271 native AdminId:GetUserAdmin(client);
274 * Sets access flags on a client. If the client is not an admin,
275 * a temporary, anonymous AdminId is given.
277 * @param client Player's index.
278 * @param ... Flags to set on the client.
280 * @error Invalid client index, or client not connected.
282 native AddUserFlags(client, {AdminFlag}:...);
285 * Removes flags from a client. If the client is not an admin,
286 * this has no effect.
288 * @param client Player's index.
289 * @param ... Flags to remove from the client.
291 * @error Invalid client index, or client not connected.
293 native RemoveUserFlags(client, {AdminFlag}:...);
296 * Sets access flags on a client using bits instead of flags. If the
297 * client is not an admin, and flags not 0, a temporary, anonymous AdminId is given.
299 * @param client Player's index.
300 * @param flags Bitstring of flags to set on client.
303 native SetUserFlagBits(client, flags);
306 * Returns client access flags. If the client is not an admin,
307 * the result is always 0.
309 * @param client Player's index.
311 * @error Invalid client index, or client not connected.
313 native GetUserFlagBits(client);
316 * Logs a generic message to the HL2 logs.
318 * @param format String format.
319 * @param ... Format arguments.
322 native LogToGame(const String:format[], {Handle,Float,String,_}:...);
325 * Logs a plugin message to the SourceMod logs.
327 * @param format String format.
328 * @param ... Format arguments.
331 native LogMessage(const String:format[], {Handle,Float,String,_}:...);
334 * Logs a plugin error message to the SourceMod logs.
336 * @param format String format.
337 * @param ... Format arguments.
340 native LogError(const String:format[], {Handle,Float,String,_}:...);