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 _clients_included
19 #define _clients_included
22 * Called on client connection.
24 * @param client Player index.
25 * @param rejectmsg Buffer to store the rejection message when the connection is refused.
26 * @param maxlen Maximum number of characters for rejection buffer.
27 * @return True to validate client's connection, false to refuse it.
29 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
32 * Called when a client is entering to the game.
34 * @param client Player index.
37 forward OnClientPutInServer(client);
40 * Called when a client is disconnecting from the server.
42 * @param client Player index.
45 forward OnClientDisconnect(client);
48 * Called when a client is disconnected from the server.
50 * @param client Player index.
53 forward OnClientDisconnect_Post(client);
56 * Called when a client is sending a command.
58 * @param client Player index.
59 * @param args Number of arguments.
62 forward Action:OnClientCommand(client, args);
65 * Called whenever the client's settings are changed.
67 * @param client Player index.
70 forward OnClientSettingsChanged(client);
73 * Called when a client receives a Steam ID.
74 * @note This is called by bots, but the ID will be "BOT"
76 * @param client Player index.
77 * @param auth Player auth string.
79 forward OnClientAuthorized(client, const String:auth[]);
82 * Returns the maximum number of clients allowed on the server.
84 * @return Maximum number of clients allowed.
86 native GetMaxClients();
89 * Returns the client count put in the server.
91 * @param inGameOnly If false connecting players are also counted.
92 * @return Client count in the server.
94 native GetClientCount(bool:inGameOnly=true);
97 * Returns the client's name.
99 * @param client Player index.
100 * @param name Buffer to store the client's name.
101 * @param maxlen Maximum length of string buffer (includes NULL terminator).
102 * @return True on success, false otherwise.
103 * @error If the client is not connected an error will be thrown.
105 native bool:GetClientName(client, String:name[], maxlen);
108 * Retrieves a client's IP address.
110 * @param client Player index.
111 * @param name Buffer to store the client's ip address.
112 * @param maxlen Maximum length of string buffer (includes NULL terminator).
113 * @param remport Remove client's port from the ip string (true by default).
114 * @return True on success, false otherwise.
115 * @error If the client is not connected or the index is invalid.
117 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
120 * Retrieves a client's authentication string (SteamID).
122 * @param client Player index.
123 * @param auth Buffer to store the client's auth string.
124 * @param maxlen Maximum length of string buffer (includes NULL terminator).
125 * @return True on success, false otherwise.
126 * @error If the client is not connected or the index is invalid.
128 native bool:GetClientAuthString(client, String:auth[], maxlen);
131 * Retrieves a client's user id, which is an index incremented for every client
132 * that joins the server.
134 * @param client Player index.
135 * @return User id of the client.
136 * @error If the client is not connected or the index is invalid.
138 native GetClientUserId(client);
141 * Returns if a certain player is connected.
143 * @param client Player index.
144 * @return True if player is connected to the server, false otherwise.
146 native bool:IsClientConnected(client);
149 * Returns if a certain player has entered the game.
151 * @param client Player index.
152 * @return True if player has entered the game, false otherwise.
154 native bool:IsPlayerInGame(client);
157 * Returns if a certain player has been authenticated.
159 * @param client Player index.
160 * @return True if player has been authenticated, false otherwise.
162 native bool:IsClientAuthorized(client);
165 * Returns if a certain player is a fake client.
167 * @param client Player index.
168 * @return True if player is a fake client, false otherwise.
170 native bool:IsFakeClient(client);
173 * Retrieves values from client replicated keys.
175 * @param client Player's index.
176 * @param key Key string.
177 * @param value Buffer to store value.
178 * @param maxlen Maximum length of valve (UTF-8 safe).
179 * @return True on success, false otherwise.
180 * @error Invalid client index, or client not connected.
182 native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
185 * Retrieves a client's team index.
187 * @param client Player's index.
188 * @return Team index the client is on (mod specific).
189 * @error Invalid client index, client not in game, or no mod support.
191 native GetClientTeam(client);
194 * Sets a client's AdminId.
196 * @param client Player's index.
197 * @param id AdminId to set. INVALID_ADMIN_ID removes admin permissions.
198 * @param temp True if the id should be freed on disconnect.
200 * @error Invalid client index, client not connected, or bogus AdminId.
202 native SetUserAdmin(client, AdminId:id, bool:temp=false);
205 * Retrieves a client's AdminId.
207 * @param client Player's index.
208 * @return AdminId of the client, or INVALID_ADMIN_ID if none.
209 * @error Invalid client index, or client not connected.
211 native AdminId:GetUserAdmin(client);
214 * Sets access flags on a client. If the client is not an admin,
215 * a temporary, anonymous AdminId is given.
217 * @param client Player's index.
218 * @param ... Flags to set on the client.
220 * @error Invalid client index, or client not connected.
222 native AddUserFlags(client, AdminFlag:...);
225 * Removes flags from a client. If the client is not an admin,
226 * this has no effect.
228 * @param client Player's index.
229 * @param ... Flags to remove from the client.
231 * @error Invalid client index, or client not connected.
233 native RemoveUserFlags(client, AdminFlag:...);
236 * Sets access flags on a client using bits instead of flags. If the
237 * client is not an admin, and flags not 0, a temporary, anonymous AdminId is given.
239 * @param client Player's index.
240 * @param flags Bitstring of flags to set on client.
243 native SetUserFlagBits(client, flags);
246 * Returns client access flags. If the client is not an admin,
247 * the result is always 0.
249 * @param client Player's index.
251 * @error Invalid client index, or client not connected.
253 native GetUserFlagBits(client);
256 * Returns whether a user can target another user.
257 * This is a helper function for CanAdminTarget.
259 * @param client Player's index.
260 * @param target Target player's index.
261 * @return True if target is targettable by the player, false otherwise.
262 * @error Invalid or unconnected player indexers.
264 native bool:CanUserTarget(client, target);
267 * Creates a fake client.
269 * @param name Name to use.
270 * @return Client index on success, 0 otherwise.
272 native CreateFakeClient(const String:name[]);
275 * Sets a convar value on a fake client.
277 * @param client Client index.
278 * @param cvar ConVar name.
279 * @param value ConVar value.
281 * @error Invalid client index, client not connected,
282 * or client not a fake client.
284 native SetFakeClientConVar(client, const String:cvar[], const String:value[]);