plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Fri Feb 16 03:47:10 2007 +0000 (2007-02-16)
changeset 501 e209a7296936
parent 500 868e9b19a872
child 505 9fb8a1ccd4ec
permissions -rw-r--r--
removed this potential feature, not useful enough
     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: sourcemod.inc 432 2007-02-02 22:47:14Z damagedsoul $
    14  */
    15 
    16 #if defined _sourcemod_included
    17  #endinput
    18 #endif
    19 #define _sourcemod_included
    20 
    21 struct Plugin
    22 {
    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 */
    28 };
    29 
    30 #include <core>
    31 #include <float>
    32 #include <handles>
    33 #include <string>
    34 #include <admin>
    35 #include <files>
    36 #include <console>
    37 
    38 /**
    39  * Declare this as a struct in your plugin to expose its information.
    40  * Example:
    41  *
    42  * public Plugin:myinfo =
    43  * {
    44  *    name = "My Plugin",
    45  *    //etc
    46  * };
    47  */
    48 public Plugin:myinfo;
    49  
    50 /**
    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.
    54  *
    55  * @noreturn
    56  */
    57 forward OnPluginStart(Handle:myself);
    58  
    59 /**
    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.
    64  * 
    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.
    67  *
    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.
    73  */
    74 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
    75 
    76 /**
    77  * Called when the plugin is about to be unloaded.
    78  *
    79  * @noreturn
    80  */
    81 forward OnPluginEnd();
    82 
    83 /**
    84  * Called when the plugin's pause status is changing.
    85  *
    86  * @param pause			True if the plugin is being paused, false otherwise.
    87  * @noreturn
    88  */
    89 forward OnPluginPauseChange(bool:pause);
    90 
    91 /**
    92  * Called on client connection.
    93  *
    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.
    98  */
    99 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
   100 
   101 /**
   102  * Called when a client is entering to the game.
   103  *
   104  * @param client		Player index.
   105  * @noreturn
   106  */
   107 forward OnClientPutInServer(client);
   108 
   109 /**
   110  * Called when a client is disconnecting from the server.
   111  *
   112  * @param client		Player index.
   113  * @noreturn
   114  */
   115 forward OnClientDisconnect(client);
   116 
   117 /**
   118  * Called when a client is disconnected from the server.
   119  *
   120  * @param client		Player index.
   121  * @noreturn
   122  */
   123 forward OnClientDisconnect_Post(client);
   124 
   125 /**
   126  * Called when a client is sending a command.
   127  *
   128  * @param client		Player index.
   129  * @noreturn
   130  */
   131 forward OnClientCommand(client, argCount);
   132 
   133 /**
   134  * Called whenever the client's settings are changed.
   135  *
   136  * @param client		Player index.
   137  * @noreturn
   138  */
   139 forward OnClientSettingsChanged(client);
   140 
   141 /**
   142  * Called when a client receives a Steam ID.
   143  * @note This is called by bots, but the ID will be "BOT"
   144  *
   145  * @param client		Player index.
   146  * @param auth			Player auth string.
   147  */
   148 forward OnClientAuthorized(client, const String:auth[]);
   149 
   150 /**
   151  * Returns the maximum number of clients allowed on the server.
   152  *
   153  * @return				Maximum number of clients allowed.
   154  */
   155 native GetMaxClients();
   156 
   157 /**
   158  * Returns the client count put in the server.
   159  *
   160  * @param inGameOnly	If false connecting players are also counted.
   161  * @return				Client count in the server.
   162  */
   163 native GetClientCount(bool:inGameOnly=true);
   164 
   165 /**
   166  * Returns the client's name.
   167  *
   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.
   173  */
   174 native bool:GetClientName(client, String:name[], maxlen);
   175 
   176 /**
   177  * Retrieves a client's IP address.
   178  *
   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.
   185  */
   186 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
   187 
   188 /**
   189  * Retrieves a client's authentication string (SteamID).
   190  *
   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.
   196  */
   197 native bool:GetClientAuthString(client, String:auth[], maxlen);
   198 
   199 /**
   200  * Retrieves a client's user id, which is an index incremented for every client
   201  * that joins the server.
   202  *
   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.
   206  */
   207 native GetClientUserId(client);
   208 
   209 /**
   210  * Returns if a certain player is connected.
   211  *
   212  * @param client		Player index.
   213  * @return				True if player is connected to the server, false otherwise.
   214  */
   215 native bool:IsClientConnected(client);
   216 
   217 /**
   218  * Returns if a certain player has entered the game.
   219  *
   220  * @param client		Player index.
   221  * @return				True if player has entered the game, false otherwise.
   222  */
   223 native bool:IsPlayerInGame(client);
   224 
   225 /**
   226  * Returns if a certain player has been authenticated.
   227  *
   228  * @param client		Player index.
   229  * @return				True if player has been authenticated, false otherwise.
   230  */
   231 native bool:IsClientAuthorized(client);
   232 
   233 /**
   234  * Returns if a certain player is a fake client.
   235  *
   236  * @param client		Player index.
   237  * @return				True if player is a fake client, false otherwise.
   238  */
   239 native bool:IsFakeClient(client);
   240 
   241 /**
   242  * Retrieves values from client replicated keys.
   243  *
   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.
   250  */
   251 native bool:GetClientInfo(client, const String:key[], String:value[], maxlen);
   252 
   253 /**
   254  * Sets a client's AdminId.  
   255  *
   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.
   259  * @noreturn
   260  * @error				Invalid client index, client not connected, or bogus AdminId.
   261  */
   262 native SetUserAdmin(client, AdminId:id, bool:temp=false);
   263 
   264 /**
   265  * Retrieves a client's AdminId.
   266  *
   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.
   270  */
   271 native AdminId:GetUserAdmin(client);
   272 
   273 /**
   274  * Sets access flags on a client.  If the client is not an admin,
   275  * a temporary, anonymous AdminId is given.
   276  *
   277  * @param client		Player's index.
   278  * @param ...			Flags to set on the client.
   279  * @noreturn
   280  * @error				Invalid client index, or client not connected.
   281  */
   282 native AddUserFlags(client, {AdminFlag}:...);
   283 
   284 /**
   285  * Removes flags from a client.  If the client is not an admin,
   286  * this has no effect.
   287  *
   288  * @param client		Player's index.
   289  * @param ...			Flags to remove from the client.
   290  * @noreturn
   291  * @error				Invalid client index, or client not connected.
   292  */
   293 native RemoveUserFlags(client, {AdminFlag}:...);
   294 
   295 /** 
   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.
   298  *
   299  * @param client		Player's index.
   300  * @param flags			Bitstring of flags to set on client.
   301  * @noreturn
   302  */
   303 native SetUserFlagBits(client, flags);
   304 
   305 /**
   306  * Returns client access flags.  If the client is not an admin,
   307  * the result is always 0.
   308  * 
   309  * @param client		Player's index.
   310  * @return				Flags
   311  * @error				Invalid client index, or client not connected.
   312  */
   313 native GetUserFlagBits(client);
   314 
   315 /**
   316  * Logs a generic message to the HL2 logs.
   317  *
   318  * @param format		String format.
   319  * @param ...			Format arguments.
   320  * @noreturn
   321  */
   322 native LogToGame(const String:format[], {Handle,Float,String,_}:...);
   323 
   324 /**
   325  * Logs a plugin message to the SourceMod logs.
   326  *
   327  * @param format		String format.
   328  * @param ...			Format arguments.
   329  * @noreturn
   330  */
   331 native LogMessage(const String:format[], {Handle,Float,String,_}:...);
   332 
   333 /**
   334  * Logs a plugin error message to the SourceMod logs.
   335  *
   336  * @param format		String format.
   337  * @param ...			Format arguments.
   338  * @noreturn
   339  */
   340 native LogError(const String:format[], {Handle,Float,String,_}:...);
   341 
   342 #include <helpers>