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