plugins/include/sourcemod.inc
author David Anderson <dvander@alliedmods.net>
Mon Jan 29 22:33:57 2007 +0000 (2007-01-29)
changeset 410 e6885cfd8aec
parent 374 39ab08027d9e
child 426 d2b0862c974e
permissions -rw-r--r--
Fixed a bug where decl was essentially broken when using arrays
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     7  * or modified under the Terms and Conditions of its License Agreement, which is found 
     8  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
     9  * may change at any time.  To view the latest information, see:
    10  *   http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #if defined _sourcemod_included
    16  #endinput
    17 #endif
    18 #define _sourcemod_included
    19 
    20 struct Plugin
    21 {
    22    const String:name[],			/* Plugin Name */
    23    const String:description[],		/* Plugin Description */
    24    const String:author[],		/* Plugin Author */
    25    const String:version[],		/* Plugin Version */
    26    const String:url[],			/* Plugin URL */
    27 };
    28 
    29 #include <core>
    30 #include <float>
    31 #include <handles>
    32 #include <string>
    33 #include <admin>
    34 #include <files>
    35 
    36 /**
    37  * Declare this as a struct in your plugin to expose its information.
    38  * Example:
    39  *
    40  * public Plugin:myinfo =
    41  * {
    42  *    name = "My Plugin",
    43  *    //etc
    44  * };
    45  */
    46 public Plugin:myinfo;
    47  
    48 /**
    49  * Called when the plugin is fully initialized and all known external references are resolved.
    50  * This is called even if the plugin type is "private."
    51  * NOTE: Errors in this function will cause the plugin to stop running.
    52  *
    53  * @noreturn
    54  */
    55 forward OnPluginStart(Handle:myself);
    56  
    57 /**
    58  *   Called before OnPluginInit, in case the plugin wants to check for load failure.
    59  * This is called even if the plugin type is "private."  Any natives from modules are 
    60  * not available at this point.  Thus, this forward should only be used for explicit 
    61  * pre-emptive things, such as adding dynamic natives, or setting certain types of load filters.
    62  * 
    63  * NOTE: It is not safe to call externally resolved natives until OnPluginInit().
    64  * NOTE: Any sort of RTE in this function will cause the plugin to fail loading.
    65  *
    66  * @param myself	Handle to the plugin.
    67  * @param late		Whether or not the plugin was loaded "late" (after map load).
    68  * @param error		Error message buffer in case load failed.
    69  * @param err_max	Maximum number of characters for error message buffer.
    70  * @return			True if load success, false otherwise.
    71  */
    72 forward bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max);
    73 
    74 /**
    75  * Called when the plugin is about to be unloaded.
    76  *
    77  * @noreturn
    78  */
    79 forward OnPluginEnd();
    80 
    81 /**
    82  * Called when the plugin's pause status is changing.
    83  *
    84  * @param pause		True if the plugin is being paused, false otherwise.
    85  * @noreturn
    86  */
    87 forward OnPluginPauseChange(bool:pause);
    88 
    89 /**
    90  * Called on client connection.
    91  *
    92  * @param client		Player index.
    93  * @param rejectmsg		Buffer to store the rejection message when the connection is refused.
    94  * @param maxlen		Maximum number of characters for rejection buffer.
    95  * @return				True to validate client's connection, false to refuse it.
    96  */
    97 forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
    98 
    99 /**
   100  * Called when a client is entering to the game.
   101  *
   102  * @param client		Player index.
   103  * @noreturn
   104  */
   105 forward OnClientPutInServer(client);
   106 
   107 /**
   108  * Called when a client is disconnecting from the server.
   109  *
   110  * @param client		Player index.
   111  * @noreturn
   112  */
   113 forward OnClientDisconnect(client);
   114 
   115 /**
   116  * Called when a client is disconnected from the server.
   117  *
   118  * @param client		Player index.
   119  * @noreturn
   120  */
   121 forward OnClientDisconnect_Post(client);
   122 
   123 /**
   124  * Called when a client is sending a command.
   125  *
   126  * @param client		Player index.
   127  * @noreturn
   128  */
   129 forward OnClientCommand(client);
   130 
   131 /**
   132  * Called whenever the client's settings are changed.
   133  *
   134  * @param client		Player index.
   135  * @noreturn
   136  */
   137 forward OnClientSettingsChanged(client);
   138 
   139 /**
   140  * Returns the maximum number of clients allowed on the server.
   141  *
   142  * @return				Maximum number of clients allowed.
   143  */
   144 native GetMaxClients();
   145 
   146 /**
   147  * Returns the client count put in the server.
   148  *
   149  * @param inGameOnly	If false connecting players are also counted.
   150  * @return				Client count in the server.
   151  */
   152 native GetClientCount(bool:inGameOnly=true);
   153 
   154 /**
   155  * Returns the client's name.
   156  *
   157  * @param client		Player index.
   158  * @param name			Buffer to store the client's name.
   159  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   160  * @return			True on success, false otherwise.
   161  * @error			If the client is not connected an error will be thrown.
   162  */
   163 native bool:GetClientName(client, String:name[], maxlen);
   164 
   165 /**
   166  * Retrieves a client's IP address.
   167  *
   168  * @param client		Player index.
   169  * @param name			Buffer to store the client's ip address.
   170  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   171  * @param remport		Remove client's port from the ip string (true by default).
   172  * @return			True on success, false otherwise.
   173  * @error			If the client is not connected an error will be thrown.
   174  */
   175 native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
   176 
   177 /**
   178  * Retrieves a client's authentication string (SteamID).
   179  *
   180  * @param client		Player index.
   181  * @param auth			Buffer to store the client's auth string.
   182  * @param maxlen		Maximum length of string buffer (includes NULL terminator).
   183  * @return			True on success, false otherwise.
   184  * @error			If the client is not connected an error will be thrown.
   185  */
   186 native bool:GetClientAuthString(client, String:auth[], maxlen);
   187 
   188 /**
   189  * Returns if a certain player is connected.
   190  *
   191  * @param client		Player index.
   192  * @return				True if player is connected to the server, false otherwise.
   193  */
   194 native bool:IsPlayerConnected(client);
   195 
   196 /**
   197  * Returns if a certain player has entered the game.
   198  *
   199  * @param client		Player index.
   200  * @return				True if player has entered the game, false otherwise.
   201  */
   202 native bool:IsPlayerInGame(client);
   203 
   204 /**
   205  * Returns if a certain player has been authenticated.
   206  *
   207  * @param client		Player index.
   208  * @return				True if player has been authenticated, false otherwise.
   209  */
   210 native bool:IsPlayerAuthorized(client);
   211 
   212 /**
   213  * Returns if a certain player is a fake client.
   214  *
   215  * @param client		Player index.
   216  * @return				True if player is a fake client, false otherwise.
   217  */
   218 native bool:IsPlayerFakeClient(client);
   219 
   220 /**
   221  * Sends a message to the server console.
   222  *
   223  * @param format		Formatting rules.
   224  * @param ...			Variable number of format parameters.
   225  * @noreturn
   226  */
   227 native PrintToServer(const String:format[], {Handle,Float,String,_}:...);
   228 
   229 /**
   230  * Sends a message to a client's console.
   231  *
   232  * @param client		Player index.
   233  * @param format		Formatting rules.
   234  * @param ...			Variable number of format parameters.
   235  * @noreturn
   236  * @error			If the client is not connected an error will be thrown.
   237  */
   238 native PrintToConsole(client, const String:format[], {Handle,Float,String,_}:...);
   239 
   240 /**
   241  * Logs a generic message to the HL2 logs.
   242  *
   243  * @param format	String format.
   244  * @param ...		Format arguments.
   245  * @noreturn
   246  */
   247 native LogToGame(const String:format[], {Handle,Float,String,_}:...);
   248 
   249 /**
   250  * Logs a plugin message to the SourceMod logs.
   251  *
   252  * @param format	String format.
   253  * @param ...		Format arguments.
   254  * @noreturn
   255  */
   256 native LogMessage(const String:format[], {Handle,Float,String,_}:...);
   257 
   258 /**
   259  * Logs a plugin error message to the SourceMod logs.
   260  *
   261  * @param format	String format.
   262  * @param ...		Format arguments.
   263  * @noreturn
   264  */
   265 native LogError(const String:format[], {Handle,Float,String,_}:...);