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