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