plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Thu Jan 11 08:46:41 2007 +0000 (2007-01-11)
changeset 285 eeccbf66d620
parent 280 f2a82da2facc
child 298 07f6b2fe8468
permissions -rw-r--r--
filled out info about pausing
     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  * @param pause		True if the plugin is being paused, false otherwise.
    73  * @noreturn
    74  */
    75 forward OnPluginPauseChange(bool:pause);
    76 
    77 /**
    78  * Called on client connection.
    79  *
    80  * @param client		Player index.
    81  * @param rejectmsg		Buffer to store the rejection message when the connection is refused.
    82  * @param maxlen		Maximum number of characters for rejection buffer.
    83  * @return				True to validate client's connection, false to refuse it.
    84  */
    85 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
    86 
    87 /**
    88  * Called when a client is entering to the game.
    89  *
    90  * @param client		Player index.
    91  * @noreturn
    92  */
    93 forward OnClientPutInServer(client);
    94 
    95 /**
    96  * Called when a client is disconnecting from the server.
    97  *
    98  * @param client		Player index.
    99  * @noreturn
   100  */
   101 forward OnClientDisconnect(client);
   102 
   103 /**
   104  * Called when a client is disconnected from the server.
   105  *
   106  * @param client		Player index.
   107  * @noreturn
   108  */
   109 forward OnClientDisconnect_Post(client);
   110 
   111 /**
   112  * Called when a client is sending a command.
   113  *
   114  * @param client		Player index.
   115  * @noreturn
   116  */
   117 forward OnClientCommand(client);
   118 
   119 /**
   120  * Called whenever the client's settings are changed.
   121  *
   122  * @param client		Player index.
   123  * @noreturn
   124  */
   125 forward OnClientSettingsChanged(client);
   126 
   127 /**
   128  * Returns the maximum number of clients allowed on the server.
   129  *
   130  * @return				Maximum number of clients allowed.
   131  */
   132 native GetMaxClients();
   133 
   134 /**
   135  * Returns the client count put in the server.
   136  *
   137  * @param inGameOnly	If false connecting players are also counted.
   138  * @return				Client count in the server.
   139  */
   140 native GetClientCount(bool:inGameOnly=true);
   141 
   142 /**
   143  * Returns the client's name.
   144  *
   145  * @param client		Player index.
   146  * @param name			Buffer to store the client's name.
   147  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   148  * @return			True on success, false otherwise.
   149  * @error			If the client is not connected an error will be thrown.
   150  */
   151 native bool:GetClientName(client, String:name[], maxlen);
   152 
   153 /**
   154  * Retrieves a client's IP address.
   155  *
   156  * @param client		Player index.
   157  * @param name			Buffer to store the client's ip address.
   158  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   159  * @param remport		Remove client's port from the ip string (true by default).
   160  * @return			True on success, false otherwise.
   161  * @error			If the client is not connected an error will be thrown.
   162  */
   163 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
   164 
   165 /**
   166  * Retrieves a client's authentication string (SteamID).
   167  *
   168  * @param client		Player index.
   169  * @param auth			Buffer to store the client's auth string.
   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:GetClientAuthString(client, String:auth[], maxlen);
   175 
   176 /**
   177  * Returns if a certain player is connected.
   178  *
   179  * @param client		Player index.
   180  * @return				True if player is connected to the server, false otherwise.
   181  */
   182 native bool:IsPlayerConnected(client);
   183 
   184 /**
   185  * Returns if a certain player has entered the game.
   186  *
   187  * @param client		Player index.
   188  * @return				True if player has entered the game, false otherwise.
   189  */
   190 native bool:IsPlayerInGame(client);
   191 
   192 /**
   193  * Returns if a certain player has been authenticated.
   194  *
   195  * @param client		Player index.
   196  * @return				True if player has been authenticated, false otherwise.
   197  */
   198 native bool:IsPlayerAuthorized(client);
   199 
   200 /**
   201  * Returns if a certain player is a fake client.
   202  *
   203  * @param client		Player index.
   204  * @return				True if player is a fake client, false otherwise.
   205  */
   206 native bool:IsPlayerFakeClient(client);
   207 
   208 /**
   209  * Sends a message to the server console.
   210  *
   211  * @param format		Formatting rules.
   212  * @param ...			Variable number of format parameters.
   213  * @noreturn
   214  */
   215 native PrintToServer(const String:format[], {Handle,Float,String,_}:...);
   216 
   217 /**
   218  * Sends a message to a client's console.
   219  *
   220  * @param client		Player index.
   221  * @param format		Formatting rules.
   222  * @param ...			Variable number of format parameters.
   223  * @noreturn
   224  * @error			If the client is not connected an error will be thrown.
   225  */
   226 native PrintToConsole(client, const String:format[], {Handle,Float,String,_}:...);