plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Mon Jan 01 19:50:16 2007 +0000 (2007-01-01)
changeset 252 ce166c465bad
parent 250 57dba176af92
child 257 583a23434070
permissions -rw-r--r--
added usage of the Handle System to begin experimenting
     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 
    23 /**
    24  * Declare this as a struct in your plugin to expose its information.
    25  * Example:
    26  *
    27  * public Plugin:myinfo =
    28  * {
    29  *    name = "My Plugin",
    30  *    //etc
    31  * };
    32  */
    33 public Plugin:myinfo;
    34  
    35 /**
    36  * Called when the plugin is fully initialized and all known external references are resolved.
    37  * This is called even if the plugin type is "private."
    38  * NOTE: Errors in this function will cause the plugin to stop running.
    39  *
    40  * @noreturn
    41  */
    42 forward OnPluginInit(Handle:myself);
    43  
    44 /**
    45  *   Called before OnPluginInit, in case the plugin wants to check for load failure.
    46  * This is called even if the plugin type is "private."  Any natives from modules are 
    47  * not available at this point.  Thus, this forward should only be used for explicit 
    48  * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
    49  * 
    50  * NOTE: It is not safe to call externally resolved natives until OnPluginInit().
    51  * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
    52  *
    53  * @param myself	Handle to the plugin.
    54  * @param late		Whether or not the plugin was loaded "late" (after map load).
    55  * @param error		Error message buffer in case load failed.
    56  * @param err_max	Maximum number of characters for error message buffer.
    57  * @return			True if load success, false otherwise.
    58  */
    59 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
    60 
    61 /**
    62  * Called when the plugin is about to be unloaded.
    63  *
    64  * @noreturn
    65  */
    66 forward OnPluginUnload();
    67 
    68 /**
    69  * Called when the plugin's pause status is changing.
    70  *
    71  * @noreturn
    72  */
    73 forward OnPluginPauseChange(bool:pause);
    74 
    75 /**
    76  * Called on client connection.
    77  *
    78  * @param client		Player index.
    79  * @param rejectmsg		Buffer to store the rejection message when the connection is refused.
    80  * @param maxlen		Maximum number of characters for rejection buffer.
    81  * @return				True to validate client's connection, false to refuse it.
    82  */
    83 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
    84 
    85 /**
    86  * Called when a client is entering to the game.
    87  *
    88  * @param client		Player index.
    89  * @noreturn
    90  */
    91 forward OnClientPutInServer(client);
    92 
    93 /**
    94  * Called when a client is disconnecting from the server.
    95  *
    96  * @param client		Player index.
    97  * @noreturn
    98  */
    99 forward OnClientDisconnect(client);
   100 
   101 /**
   102  * Called when a client is disconnected from the server.
   103  *
   104  * @param client		Player index.
   105  * @noreturn
   106  */
   107 forward OnClientDisconnect_Post(client);
   108 
   109 /**
   110  * Called when a client is sending a command.
   111  *
   112  * @param client		Player index.
   113  * @noreturn
   114  */
   115 forward OnClientCommand(client);
   116 
   117 /**
   118  * Called whenever the client's settings are changed.
   119  *
   120  * @param client		Player index.
   121  * @noreturn
   122  */
   123 forward OnClientSettingsChanged(client);
   124 
   125 /**
   126  * Returns the maximum number of clients allowed on the server.
   127  *
   128  * @return				Maximum number of clients allowed.
   129  */
   130 native GetMaxClients();
   131 
   132 /**
   133  * Returns the client count put in the server.
   134  *
   135  * @param inGameOnly	If false connecting players are also counted.
   136  * @return				Client count in the server.
   137  */
   138 native GetClientCount(bool:inGameOnly=true);
   139 
   140 /**
   141  * Returns the client's name.
   142  *
   143  * @param client		Player index.
   144  * @param name			Buffer to store the client's name.
   145  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   146  * @noreturn
   147  */
   148 native GetClientName(client, String:name[], maxlen);
   149 
   150 /**
   151  * Retrieves a client's IP address.
   152  *
   153  * @param client		Player index.
   154  * @param name			Buffer to store the client's ip address.
   155  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   156  * @noreturn
   157  */
   158 native GetClientIP(client, String:ip[], maxlen);
   159 
   160 /**
   161  * Retrieves a client's authentication string (SteamID).
   162  *
   163  * @param client		Player index.
   164  * @param auth			Buffer to store the client's auth string.
   165  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   166  * @return				Returns 0 on failure, non-zero otherwise.
   167  */
   168 native GetClientAuthString(client, String:auth[], maxlen);
   169 
   170 /**
   171  * Returns if a certain player is connected.
   172  *
   173  * @param client		Player index.
   174  * @return				True if player is connected to the server, false otherwise.
   175  */
   176 native bool:IsPlayerConnected(client);
   177 
   178 /**
   179  * Returns if a certain player has entered the game.
   180  *
   181  * @param client		Player index.
   182  * @return				True if player has entered the game, false otherwise.
   183  */
   184 native bool:IsPlayerInGame(client);
   185 
   186 /**
   187  * Returns if a certain player has been authenticated.
   188  *
   189  * @param client		Player index.
   190  * @return				True if player has been authenticated, false otherwise.
   191  */
   192 native bool:IsPlayerAuthorized(client);
   193 
   194 /**
   195  * Returns if a certain player is a fake client.
   196  *
   197  * @param client		Player index.
   198  * @return				True if player is a fake client, false otherwise.
   199  */
   200 native bool:IsPlayerFakeClient(client);