Implemented IsPlayerAlive native.
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
23 NetFlow_Outgoing = 0, /**< Outgoing traffic */
24 NetFlow_Incoming, /**< Incoming traffic */
25 NetFlow_Both /**< Incoming and outgoing traffic */
28 #define MAXPLAYERS 64 /**< Maximum number of players that can be in server */
31 * Called on client connection.
33 * @param client Player index.
34 * @param rejectmsg Buffer to store the rejection message when the connection is refused.
35 * @param maxlen Maximum number of characters for rejection buffer.
36 * @return True to validate client's connection, false to refuse it.
38 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
41 * Called when a client is entering to the game.
43 * @param client Player index.
46 forward OnClientPutInServer(client);
49 * Called when a client is disconnecting from the server.
51 * @param client Player index.
54 forward OnClientDisconnect(client);
57 * Called when a client is disconnected from the server.
59 * @param client Player index.
62 forward OnClientDisconnect_Post(client);
65 * Called when a client is sending a command.
67 * @param client Player index.
68 * @param args Number of arguments.
71 forward Action:OnClientCommand(client, args);
74 * Called whenever the client's settings are changed.
76 * @param client Player index.
79 forward OnClientSettingsChanged(client);
82 * Called when a client receives a Steam ID.
83 * @note This is called by bots, but the ID will be "BOT"
85 * @param client Player index.
86 * @param auth Player auth string.
88 forward OnClientAuthorized(client, const String:auth[]);
91 * Returns the maximum number of clients allowed on the server.
93 * @return Maximum number of clients allowed.
95 native GetMaxClients();
98 * Returns the client count put in the server.
100 * @param inGameOnly If false connecting players are also counted.
101 * @return Client count in the server.
103 native GetClientCount(bool:inGameOnly=true);
106 * Returns the client's name.
108 * @param client Player index.
109 * @param name Buffer to store the client's name.
110 * @param maxlen Maximum length of string buffer (includes NULL terminator).
111 * @return True on success, false otherwise.
112 * @error If the client is not connected an error will be thrown.
114 native bool:GetClientName(client, String:name[], maxlen);
117 * Retrieves a client's IP address.
119 * @param client Player index.
120 * @param name Buffer to store the client's ip address.
121 * @param maxlen Maximum length of string buffer (includes NULL terminator).
122 * @param remport Remove client's port from the ip string (true by default).
123 * @return True on success, false otherwise.
124 * @error If the client is not connected or the index is invalid.
126 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
129 * Retrieves a client's authentication string (SteamID).
131 * @param client Player index.
132 * @param auth Buffer to store the client's auth string.
133 * @param maxlen Maximum length of string buffer (includes NULL terminator).
134 * @return True on success, false otherwise.
135 * @error If the client is not connected or the index is invalid.
137 native bool:GetClientAuthString(client, String:auth[], maxlen);
140 * Retrieves a client's user id, which is an index incremented for every client
141 * that joins the server.
143 * @param client Player index.
144 * @return User id of the client.
145 * @error If the client is not connected or the index is invalid.
147 native GetClientUserId(client);
150 * Returns if a certain player is connected.
152 * @param client Player index.
153 * @return True if player is connected to the server, false otherwise.
155 native bool:IsClientConnected(client);
158 * Returns if a certain player has entered the game.
160 * @param client Player index.
161 * @return True if player has entered the game, false otherwise.
163 native bool:IsClientInGame(client);
166 * Backwards compatibility stock - use IsClientInGame
167 * @deprecated Renamed to IsClientInGame
169 stock bool:IsPlayerInGame(client)
171 return IsClientInGame(client);
175 * Returns if a certain player has been authenticated.
177 * @param client Player index.
178 * @return True if player has been authenticated, false otherwise.
180 native bool:IsClientAuthorized(client);
183 * Returns if a certain player is a fake client.
185 * @param client Player index.
186 * @return True if player is a fake client, false otherwise.
188 native bool:IsFakeClient(client);
191 * Returns if a certain player is an observer/spectator.
193 * @param client Player index.
194 * @return True if player is an obverser, false otherwise.
196 native bool:IsClientObserver(client);
199 * Retrieves values from client replicated keys.
201 * @param client Player's index.
202 * @param key Key string.
203 * @param value Buffer to store value.
204 * @param maxlen Maximum length of valve (UTF-8 safe).
205 * @return True on success, false otherwise.
206 * @error Invalid client index, or client not connected.
208 native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
211 * Retrieves a client's team index.
213 * @param client Player's index.
214 * @return Team index the client is on (mod specific).
215 * @error Invalid client index, client not in game, or no mod support.
217 native GetClientTeam(client);
220 * Sets a client's AdminId.
222 * @param client Player's index.
223 * @param id AdminId to set. INVALID_ADMIN_ID removes admin permissions.
224 * @param temp True if the id should be freed on disconnect.
226 * @error Invalid client index, client not connected, or bogus AdminId.
228 native SetUserAdmin(client, AdminId:id, bool:temp=false);
231 * Retrieves a client's AdminId.
233 * @param client Player's index.
234 * @return AdminId of the client, or INVALID_ADMIN_ID if none.
235 * @error Invalid client index, or client not connected.
237 native AdminId:GetUserAdmin(client);
240 * Sets access flags on a client. If the client is not an admin,
241 * a temporary, anonymous AdminId is given.
243 * @param client Player's index.
244 * @param ... Flags to set on the client.
246 * @error Invalid client index, or client not connected.
248 native AddUserFlags(client, AdminFlag:...);
251 * Removes flags from a client. If the client is not an admin,
252 * this has no effect.
254 * @param client Player's index.
255 * @param ... Flags to remove from the client.
257 * @error Invalid client index, or client not connected.
259 native RemoveUserFlags(client, AdminFlag:...);
262 * Sets access flags on a client using bits instead of flags. If the
263 * client is not an admin, and flags not 0, a temporary, anonymous AdminId is given.
265 * @param client Player's index.
266 * @param flags Bitstring of flags to set on client.
269 native SetUserFlagBits(client, flags);
272 * Returns client access flags. If the client is not an admin,
273 * the result is always 0.
275 * @param client Player's index.
277 * @error Invalid client index, or client not connected.
279 native GetUserFlagBits(client);
282 * Returns whether a user can target another user.
283 * This is a helper function for CanAdminTarget.
285 * @param client Player's index.
286 * @param target Target player's index.
287 * @return True if target is targettable by the player, false otherwise.
288 * @error Invalid or unconnected player indexers.
290 native bool:CanUserTarget(client, target);
293 * Creates a fake client.
295 * @param name Name to use.
296 * @return Client index on success, 0 otherwise.
298 native CreateFakeClient(const String:name[]);
301 * Sets a convar value on a fake client.
303 * @param client Client index.
304 * @param cvar ConVar name.
305 * @param value ConVar value.
307 * @error Invalid client index, client not connected,
308 * or client not a fake client.
310 native SetFakeClientConVar(client, const String:cvar[], const String:value[]);
313 * Returns the client's health.
315 * @param client Player's index.
316 * @return Health value.
317 * @error Invalid client index, client not in game, or no mod support.
319 native GetClientHealth(client);
322 * Returns the client's model name.
324 * @param client Player's index.
325 * @param model Buffer to store the client's model name.
326 * @param maxlen Maximum length of string buffer (includes NULL terminator).
328 * @error Invalid client index, client not in game, or no mod support.
330 native GetClientModel(client, String:model[], maxlen);
333 * Returns the client's weapon name.
335 * @param client Player's index.
336 * @param weapon Buffer to store the client's weapon name.
337 * @param maxlen Maximum length of string buffer (includes NULL terminator).
339 * @error Invalid client index, client not in game, or no mod support.
341 native GetClientWeapon(client, String:weapon[], maxlen);
344 * Returns the client's max size vector.
346 * @param client Player's index.
347 * @param vec Destination vector to store the client's max size.
349 * @error Invalid client index, client not in game, or no mod support.
351 native GetClientMaxs(client, Float:vec[3]);
354 * Returns the client's min size vector.
356 * @param client Player's index.
357 * @param vec Destination vector to store the client's min size.
359 * @error Invalid client index, client not in game, or no mod support.
361 native GetClientMins(client, Float:vec[3]);
364 * Returns the client's position angle.
366 * @param client Player's index.
367 * @param ang Destination vector to store the client's position angle.
369 * @error Invalid client index, client not in game, or no mod support.
371 native GetClientAbsAngles(client, Float:ang[3]);
374 * Returns the client's origin vector.
376 * @param client Player's index.
377 * @param vec Destination vector to store the client's origin vector.
379 * @error Invalid client index, client not in game, or no mod support.
381 native GetClientAbsOrigin(client, Float:vec[3]);
384 * Returns the client's armor.
386 * @param client Player's index.
387 * @return Armor value.
388 * @error Invalid client index, client not in game, or no mod support.
390 native GetClientArmor(client);
393 * Returns the client's death count.
395 * @param client Player's index.
396 * @return Death count.
397 * @error Invalid client index, client not in game, or no mod support.
399 native GetClientDeaths(client);
402 * Returns the client's frag count.
404 * @param client Player's index.
405 * @return Frag count.
406 * @error Invalid client index, client not in game, or no mod support.
408 native GetClientFrags(client);
411 * Returns the client's send data rate in bytes/sec.
413 * @param client Player's index.
415 * @error Invalid client index, client not in game, or fake client.
417 native GetClientDataRate(client);
420 * Returns if a client is timing out
422 * @param client Player's index.
423 * @return True if client is timing out, false otherwise.
424 * @error Invalid client index, client not in game, or fake client.
426 native bool:IsClientTimingOut(client);
429 * Returns the client's connection time in seconds.
431 * @param client Player's index.
432 * @return Connection time.
433 * @error Invalid client index, client not in game, or fake client.
435 native Float:GetClientTime(client);
438 * Returns the client's current latency (RTT), more accurate than GetAvgLatency but jittering.
440 * @param client Player's index.
441 * @param flow Traffic flowing direction.
443 * @error Invalid client index, client not in game, or fake client.
445 native Float:GetClientLatency(client, NetFlow:flow);
448 * Returns the client's average packet latency in seconds.
450 * @param client Player's index.
451 * @param flow Traffic flowing direction.
452 * @return Average latency.
453 * @error Invalid client index, client not in game, or fake client.
455 native Float:GetClientAvgLatency(client, NetFlow:flow);
458 * Returns the client's average packet loss, values go from 0 to 1 (for percentages).
460 * @param client Player's index.
461 * @param flow Traffic flowing direction.
462 * @return Average packet loss.
463 * @error Invalid client index, client not in game, or fake client.
465 native Float:GetClientAvgLoss(client, NetFlow:flow);
468 * Returns the client's average packet choke, values go from 0 to 1 (for percentages).
470 * @param client Player's index.
471 * @param flow Traffic flowing direction.
472 * @return Average packet choke.
473 * @error Invalid client index, client not in game, or fake client.
475 native Float:GetClientAvgChoke(client, NetFlow:flow);
478 * Returns the client's data flow in bytes/sec.
480 * @param client Player's index.
481 * @param flow Traffic flowing direction.
483 * @error Invalid client index, client not in game, or fake client.
485 native Float:GetClientAvgData(client, NetFlow:flow);
488 * Returns the client's average packet frequency in packets/sec.
490 * @param client Player's index.
491 * @param flow Traffic flowing direction.
492 * @return Packet frequency.
493 * @error Invalid client index, client not in game, or fake client.
495 native Float:GetClientAvgPackets(client, NetFlow:flow);
498 * Translates an userid index to the real player index.
500 * @param userid Userid value.
501 * @return Client value.
502 * @error Returns 0 if invalid userid.
504 native GetClientOfUserId(userid);
507 * Disconnects a client from the server.
509 * @param client Client index.
510 * @param format Optional formatting rules for disconnect reason.
511 * Note that a period is automatically appended to the string by the engine.
512 * @param ... Variable number of format parameters.
514 * @error Invalid client index, or client not connected.
516 native KickClient(client, const String:format[]="", any:...);
519 * Changes a client's team through the mod's generic team changing function.
520 * On CS:S, this will kill the player.
522 * @param client Client index.
523 * @param team Mod-specific team index.
525 * @error Invalid client index, client not connected, or lack of
528 native ChangeClientTeam(client, team);