plugins/include/sourcemod.inc
author Borja Ferrer <faluco@alliedmods.net>
Wed Jan 10 23:49:22 2007 +0000 (2007-01-10)
changeset 280 f2a82da2facc
parent 258 2637fcf24c2f
child 285 eeccbf66d620
permissions -rw-r--r--
added some console natives
more consts here and there in the logger
     1 /**
     2  * :TODO: license info
     3  */
     4 
     5 #if defined _sourcemod_included
     6  #endinput
     7 #endif
     8 #define _sourcemod_included
     9 
    10 struct Plugin
    11 {
    12    const String:name[],			/* Plugin Name */
    13    const String:description[],		/* Plugin Description */
    14    const String:author[],		/* Plugin Author */
    15    const String:version[],		/* Plugin Version */
    16    const String:url[],			/* Plugin URL */
    17 };
    18 
    19 #include <float>
    20 #include <handles>
    21 #include <string>
    22 #include <files>
    23 
    24 /**
    25  * Declare this as a struct in your plugin to expose its information.
    26  * Example:
    27  *
    28  * public Plugin:myinfo =
    29  * {
    30  *    name = "My Plugin",
    31  *    //etc
    32  * };
    33  */
    34 public Plugin:myinfo;
    35  
    36 /**
    37  * Called when the plugin is fully initialized and all known external references are resolved.
    38  * This is called even if the plugin type is "private."
    39  * NOTE: Errors in this function will cause the plugin to stop running.
    40  *
    41  * @noreturn
    42  */
    43 forward OnPluginInit(Handle:myself);
    44  
    45 /**
    46  *   Called before OnPluginInit, in case the plugin wants to check for load failure.
    47  * This is called even if the plugin type is "private."  Any natives from modules are 
    48  * not available at this point.  Thus, this forward should only be used for explicit 
    49  * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
    50  * 
    51  * NOTE: It is not safe to call externally resolved natives until OnPluginInit().
    52  * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
    53  *
    54  * @param myself	Handle to the plugin.
    55  * @param late		Whether or not the plugin was loaded "late" (after map load).
    56  * @param error		Error message buffer in case load failed.
    57  * @param err_max	Maximum number of characters for error message buffer.
    58  * @return			True if load success, false otherwise.
    59  */
    60 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
    61 
    62 /**
    63  * Called when the plugin is about to be unloaded.
    64  *
    65  * @noreturn
    66  */
    67 forward OnPluginUnload();
    68 
    69 /**
    70  * Called when the plugin's pause status is changing.
    71  *
    72  * @noreturn
    73  */
    74 forward OnPluginPauseChange(bool:pause);
    75 
    76 /**
    77  * Called on client connection.
    78  *
    79  * @param client		Player index.
    80  * @param rejectmsg		Buffer to store the rejection message when the connection is refused.
    81  * @param maxlen		Maximum number of characters for rejection buffer.
    82  * @return				True to validate client's connection, false to refuse it.
    83  */
    84 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
    85 
    86 /**
    87  * Called when a client is entering to the game.
    88  *
    89  * @param client		Player index.
    90  * @noreturn
    91  */
    92 forward OnClientPutInServer(client);
    93 
    94 /**
    95  * Called when a client is disconnecting from the server.
    96  *
    97  * @param client		Player index.
    98  * @noreturn
    99  */
   100 forward OnClientDisconnect(client);
   101 
   102 /**
   103  * Called when a client is disconnected from the server.
   104  *
   105  * @param client		Player index.
   106  * @noreturn
   107  */
   108 forward OnClientDisconnect_Post(client);
   109 
   110 /**
   111  * Called when a client is sending a command.
   112  *
   113  * @param client		Player index.
   114  * @noreturn
   115  */
   116 forward OnClientCommand(client);
   117 
   118 /**
   119  * Called whenever the client's settings are changed.
   120  *
   121  * @param client		Player index.
   122  * @noreturn
   123  */
   124 forward OnClientSettingsChanged(client);
   125 
   126 /**
   127  * Returns the maximum number of clients allowed on the server.
   128  *
   129  * @return				Maximum number of clients allowed.
   130  */
   131 native GetMaxClients();
   132 
   133 /**
   134  * Returns the client count put in the server.
   135  *
   136  * @param inGameOnly	If false connecting players are also counted.
   137  * @return				Client count in the server.
   138  */
   139 native GetClientCount(bool:inGameOnly=true);
   140 
   141 /**
   142  * Returns the client's name.
   143  *
   144  * @param client		Player index.
   145  * @param name			Buffer to store the client's name.
   146  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   147  * @return			True on success, false otherwise.
   148  * @error			If the client is not connected an error will be thrown.
   149  */
   150 native bool:GetClientName(client, String:name[], maxlen);
   151 
   152 /**
   153  * Retrieves a client's IP address.
   154  *
   155  * @param client		Player index.
   156  * @param name			Buffer to store the client's ip address.
   157  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   158  * @param remport		Remove client's port from the ip string (true by default).
   159  * @return			True on success, false otherwise.
   160  * @error			If the client is not connected an error will be thrown.
   161  */
   162 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
   163 
   164 /**
   165  * Retrieves a client's authentication string (SteamID).
   166  *
   167  * @param client		Player index.
   168  * @param auth			Buffer to store the client's auth string.
   169  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   170  * @return			True on success, false otherwise.
   171  * @error			If the client is not connected an error will be thrown.
   172  */
   173 native bool:GetClientAuthString(client, String:auth[], maxlen);
   174 
   175 /**
   176  * Returns if a certain player is connected.
   177  *
   178  * @param client		Player index.
   179  * @return				True if player is connected to the server, false otherwise.
   180  */
   181 native bool:IsPlayerConnected(client);
   182 
   183 /**
   184  * Returns if a certain player has entered the game.
   185  *
   186  * @param client		Player index.
   187  * @return				True if player has entered the game, false otherwise.
   188  */
   189 native bool:IsPlayerInGame(client);
   190 
   191 /**
   192  * Returns if a certain player has been authenticated.
   193  *
   194  * @param client		Player index.
   195  * @return				True if player has been authenticated, false otherwise.
   196  */
   197 native bool:IsPlayerAuthorized(client);
   198 
   199 /**
   200  * Returns if a certain player is a fake client.
   201  *
   202  * @param client		Player index.
   203  * @return				True if player is a fake client, false otherwise.
   204  */
   205 native bool:IsPlayerFakeClient(client);
   206 
   207 /**
   208  * Sends a message to the server console.
   209  *
   210  * @param format		Formatting rules.
   211  * @param ...			Variable number of format parameters.
   212  * @noreturn
   213  */
   214 native PrintToServer(const String:format[], {Handle,Float,String,_}:...);
   215 
   216 /**
   217  * Sends a message to a client's console.
   218  *
   219  * @param client		Player index.
   220  * @param format		Formatting rules.
   221  * @param ...			Variable number of format parameters.
   222  * @noreturn
   223  * @error			If the client is not connected an error will be thrown.
   224  */
   225 native PrintToConsole(client, const String:format[], {Handle,Float,String,_}:...);