plugins/include/clients.inc
author David Anderson <dvander@alliedmods.net>
Sat Mar 17 23:03:44 2007 +0000 (2007-03-17)
changeset 644 2a90d4324fc0
parent 634 85108309e453
child 658 b46ff98c249b
permissions -rw-r--r--
added a playerinfo function to kick this off
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     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
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _clients_included
    17  #endinput
    18 #endif
    19 #define _clients_included
    20 
    21 /**
    22  * Called on client connection.
    23  *
    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.
    28  */
    29 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
    30 
    31 /**
    32  * Called when a client is entering to the game.
    33  *
    34  * @param client		Player index.
    35  * @noreturn
    36  */
    37 forward OnClientPutInServer(client);
    38 
    39 /**
    40  * Called when a client is disconnecting from the server.
    41  *
    42  * @param client		Player index.
    43  * @noreturn
    44  */
    45 forward OnClientDisconnect(client);
    46 
    47 /**
    48  * Called when a client is disconnected from the server.
    49  *
    50  * @param client		Player index.
    51  * @noreturn
    52  */
    53 forward OnClientDisconnect_Post(client);
    54 
    55 /**
    56  * Called when a client is sending a command.
    57  *
    58  * @param client		Player index.
    59  * @param args			Number of arguments.
    60  * @noreturn
    61  */
    62 forward Action:OnClientCommand(client, args);
    63 
    64 /**
    65  * Called whenever the client's settings are changed.
    66  *
    67  * @param client		Player index.
    68  * @noreturn
    69  */
    70 forward OnClientSettingsChanged(client);
    71 
    72 /**
    73  * Called when a client receives a Steam ID.
    74  * @note This is called by bots, but the ID will be "BOT"
    75  *
    76  * @param client		Player index.
    77  * @param auth			Player auth string.
    78  */
    79 forward OnClientAuthorized(client, const String:auth[]);
    80 
    81 /**
    82  * Returns the maximum number of clients allowed on the server.
    83  *
    84  * @return				Maximum number of clients allowed.
    85  */
    86 native GetMaxClients();
    87 
    88 /**
    89  * Returns the client count put in the server.
    90  *
    91  * @param inGameOnly	If false connecting players are also counted.
    92  * @return				Client count in the server.
    93  */
    94 native GetClientCount(bool:inGameOnly=true);
    95 
    96 /**
    97  * Returns the client's name.
    98  *
    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.
   104  */
   105 native bool:GetClientName(client, String:name[], maxlen);
   106 
   107 /**
   108  * Retrieves a client's IP address.
   109  *
   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.
   116  */
   117 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
   118 
   119 /**
   120  * Retrieves a client's authentication string (SteamID).
   121  *
   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.
   127  */
   128 native bool:GetClientAuthString(client, String:auth[], maxlen);
   129 
   130 /**
   131  * Retrieves a client's user id, which is an index incremented for every client
   132  * that joins the server.
   133  *
   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.
   137  */
   138 native GetClientUserId(client);
   139 
   140 /**
   141  * Returns if a certain player is connected.
   142  *
   143  * @param client		Player index.
   144  * @return				True if player is connected to the server, false otherwise.
   145  */
   146 native bool:IsClientConnected(client);
   147 
   148 /**
   149  * Returns if a certain player has entered the game.
   150  *
   151  * @param client		Player index.
   152  * @return				True if player has entered the game, false otherwise.
   153  */
   154 native bool:IsPlayerInGame(client);
   155 
   156 /**
   157  * Returns if a certain player has been authenticated.
   158  *
   159  * @param client		Player index.
   160  * @return				True if player has been authenticated, false otherwise.
   161  */
   162 native bool:IsClientAuthorized(client);
   163 
   164 /**
   165  * Returns if a certain player is a fake client.
   166  *
   167  * @param client		Player index.
   168  * @return				True if player is a fake client, false otherwise.
   169  */
   170 native bool:IsFakeClient(client);
   171 
   172 /**
   173  * Retrieves values from client replicated keys.
   174  *
   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.
   181  */
   182 native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
   183 
   184 /**
   185  * Retrieves a client's team index.
   186  *
   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.
   190  */
   191 native GetClientTeam(client);
   192  
   193 /**
   194  * Sets a client's AdminId.  
   195  *
   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.
   199  * @noreturn
   200  * @error				Invalid client index, client not connected, or bogus AdminId.
   201  */
   202 native SetUserAdmin(client, AdminId:id, bool:temp=false);
   203 
   204 /**
   205  * Retrieves a client's AdminId.
   206  *
   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.
   210  */
   211 native AdminId:GetUserAdmin(client);
   212 
   213 /**
   214  * Sets access flags on a client.  If the client is not an admin,
   215  * a temporary, anonymous AdminId is given.
   216  *
   217  * @param client		Player's index.
   218  * @param ...			Flags to set on the client.
   219  * @noreturn
   220  * @error				Invalid client index, or client not connected.
   221  */
   222 native AddUserFlags(client, AdminFlag:...);
   223 
   224 /**
   225  * Removes flags from a client.  If the client is not an admin,
   226  * this has no effect.
   227  *
   228  * @param client		Player's index.
   229  * @param ...			Flags to remove from the client.
   230  * @noreturn
   231  * @error				Invalid client index, or client not connected.
   232  */
   233 native RemoveUserFlags(client, AdminFlag:...);
   234 
   235 /** 
   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.
   238  *
   239  * @param client		Player's index.
   240  * @param flags			Bitstring of flags to set on client.
   241  * @noreturn
   242  */
   243 native SetUserFlagBits(client, flags);
   244 
   245 /**
   246  * Returns client access flags.  If the client is not an admin,
   247  * the result is always 0.
   248  * 
   249  * @param client		Player's index.
   250  * @return				Flags
   251  * @error				Invalid client index, or client not connected.
   252  */
   253 native GetUserFlagBits(client);
   254 
   255 /**
   256  * Returns whether a user can target another user.
   257  * This is a helper function for CanAdminTarget.
   258  *
   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.
   263  */
   264 native bool:CanUserTarget(client, target);
   265 
   266 /** 
   267  * Creates a fake client.
   268  *
   269  * @param name			Name to use.
   270  * @return				Client index on success, 0 otherwise.
   271  */
   272 native CreateFakeClient(const String:name[]);
   273 
   274 /**
   275  * Sets a convar value on a fake client.
   276  *
   277  * @param client		Client index.
   278  * @param cvar			ConVar name.
   279  * @param value			ConVar value.
   280  * @noreturn
   281  * @error				Invalid client index, client not connected,
   282  *						or client not a fake client.
   283  */
   284 native SetFakeClientConVar(client, const String:cvar[], const String:value[]);