plugins/include/banning.inc
author David Anderson <dvander@alliedmods.net>
Fri Sep 14 02:11:10 2007 +0000 (2007-09-14)
changeset 1423 e73b3563f254
child 1450 a824a8c3a043
permissions -rw-r--r--
- added 3 new natives for banning/unbanning and interception
- moved banning commands into new plugin, basebans
- improved quality and input methods of ban commands
- corrected svn props on a few files
- added an IsLANServer() to IGameHelpers API
- completely deprecated and removed old banning forwards
dvander@1423
     1
/**
dvander@1423
     2
 * vim: set ts=4 :
dvander@1423
     3
 * =============================================================================
dvander@1423
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@1423
     5
 * =============================================================================
dvander@1423
     6
 *
dvander@1423
     7
 * This file is part of the SourceMod/SourcePawn SDK.
dvander@1423
     8
 *
dvander@1423
     9
 * This program is free software; you can redistribute it and/or modify it under
dvander@1423
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
dvander@1423
    11
 * Free Software Foundation.
dvander@1423
    12
 * 
dvander@1423
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@1423
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@1423
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dvander@1423
    16
 * details.
dvander@1423
    17
 *
dvander@1423
    18
 * You should have received a copy of the GNU General Public License along with
dvander@1423
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1423
    20
 *
dvander@1423
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
dvander@1423
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@1423
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@1423
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
dvander@1423
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
dvander@1423
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
dvander@1423
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@1423
    28
 * or <http://www.sourcemod.net/license.php>.
dvander@1423
    29
 *
dvander@1423
    30
 * Version: $Id$
dvander@1423
    31
 */
dvander@1423
    32
dvander@1423
    33
#if defined _banning_included
dvander@1423
    34
 #endinput
dvander@1423
    35
#endif
dvander@1423
    36
#define _banning_included
dvander@1423
    37
dvander@1423
    38
#define BANFLAG_AUTO		(1<<0)	/**< Auto-detects whether to ban by steamid or IP */
dvander@1423
    39
#define BANFLAG_IP			(1<<1)	/**< Always ban by IP address */
dvander@1423
    40
#define BANFLAG_AUTHID		(1<<2)	/**< Always ban by authstring (for BanIdentity) if possible */
dvander@1423
    41
#define BANFLAG_NOKICK		(1<<3)	/**< Does not kick the client */
dvander@1423
    42
dvander@1423
    43
/**
dvander@1423
    44
 * Called for calls to BanClient() with a non-empty command.
dvander@1423
    45
 *
dvander@1423
    46
 * @param client		Client being banned.
dvander@1423
    47
 * @param time			Time the client is being banned for (0 = permanent).
dvander@1423
    48
 * @param flags			One if AUTHID or IP will be enabled.  If AUTO is also 
dvander@1423
    49
 *						enabled, it means Core autodetected which to use.
dvander@1423
    50
 * @param reason		Reason passed via BanClient().
dvander@1423
    51
 * @param kick_message	Kick message passed via BanClient().
dvander@1423
    52
 * @param command		Command string to identify the ban source.
dvander@1423
    53
 * @param source		Source value passed via BanClient().
dvander@1423
    54
 * @noreturn
dvander@1423
    55
 */
dvander@1423
    56
forward OnBanClient(client, 
dvander@1423
    57
					time, 
dvander@1423
    58
					flags, 
dvander@1423
    59
					const String:reason[], 
dvander@1423
    60
					const String:kick_message[], 
dvander@1423
    61
					const String:command[],
dvander@1423
    62
					any:source);
dvander@1423
    63
dvander@1423
    64
/**
dvander@1423
    65
 * Called for calls to BanIdentity() with a non-empty command.
dvander@1423
    66
 *
dvander@1423
    67
 * @param identity		Identity string being banned (authstring or ip).
dvander@1423
    68
 * @param time			Time the client is being banned for (0 = permanent).
dvander@1423
    69
 * @param flags			Ban flags (only IP or AUTHID are valid here).
dvander@1423
    70
 * @param reason		Reason passed via BanIdentity().
dvander@1423
    71
 * @param command		Command string to identify the ban source.
dvander@1423
    72
 * @param source		Source value passed via BanIdentity().
dvander@1423
    73
 * @noreturn
dvander@1423
    74
 */
dvander@1423
    75
forward OnBanIdentity(const String:identity[],
dvander@1423
    76
					  time,
dvander@1423
    77
					  flags,
dvander@1423
    78
					  const String:reason[],
dvander@1423
    79
					  const String:command[],
dvander@1423
    80
					  any:source);
dvander@1423
    81
dvander@1423
    82
/**
dvander@1423
    83
 * Called for calls to RemoveBan() with a non-empty command.
dvander@1423
    84
 *
dvander@1423
    85
 * @param identity		Identity string being banned (authstring or ip).
dvander@1423
    86
 * @param flags			Ban flags (only IP or AUTHID are valid here).
dvander@1423
    87
 * @param command		Command string to identify the ban source.
dvander@1423
    88
 * @param source		Source value passed via BanIdentity().
dvander@1423
    89
 * @noreturn
dvander@1423
    90
 */
dvander@1423
    91
forward OnRemoveBan(const String:identity[],
dvander@1423
    92
					flags,
dvander@1423
    93
					const String:command[],
dvander@1423
    94
					any:source);
dvander@1423
    95
dvander@1423
    96
/**
dvander@1423
    97
 * Bans a client.
dvander@1423
    98
 *
dvander@1423
    99
 * @param client		Client being banned.
dvander@1423
   100
 * @param time			Time (in minutes) to ban (0 = permanent).
dvander@1423
   101
 * @param flags			Flags for controlling the ban mechanism.  If AUTHID 
dvander@1423
   102
 *						is set and no AUTHID is available, the ban will fail 
dvander@1423
   103
 *						unless AUTO is also flagged.
dvander@1423
   104
 * @param reason		Reason to ban the client for.
dvander@1423
   105
 * @param kick_message	Message to display to the user when kicking.
dvander@1423
   106
 * @param command		Command string to identify the source.  If this is left 
dvander@1423
   107
 *						empty, then the OnBanClient forward will not be called.
dvander@1423
   108
 * @param source		A source value that could be interpreted as a player 
dvander@1423
   109
 *						index of any sort (not actually checked by Core).
dvander@1423
   110
 * @return				True on success, false on failure.
dvander@1423
   111
 * @error				Invalid client index or client not in game.
dvander@1423
   112
 */
dvander@1423
   113
native bool:BanClient(client, 
dvander@1423
   114
					  time, 
dvander@1423
   115
					  flags, 
dvander@1423
   116
					  const String:reason[], 
dvander@1423
   117
					  const String:kick_message[]="", 
dvander@1423
   118
					  const String:command[]="",
dvander@1423
   119
					  any:source=0);
dvander@1423
   120
dvander@1423
   121
/**
dvander@1423
   122
 * Bans an identity (either an IP address or auth string).
dvander@1423
   123
 *
dvander@1423
   124
 * @param identity		String to ban (ip or authstring).
dvander@1423
   125
 * @param time			Time to ban for (0 = permanent).
dvander@1423
   126
 * @param flags			Flags (only IP and AUTHID are valid flags here).
dvander@1423
   127
 * @param reason		Ban reason string.
dvander@1423
   128
 * @param command		Command string to identify the source.  If this is left 
dvander@1423
   129
 *						empty, then the OnBanIdentity forward will not be called.
dvander@1423
   130
 * @param source		A source value that could be interpreted as a player
dvander@1423
   131
 *						index of any sort (not actually checked by Core).
dvander@1423
   132
 * @return				True on success, false on failure.
dvander@1423
   133
 */
dvander@1423
   134
native bool:BanIdentity(const String:identity[], 
dvander@1423
   135
						time, 
dvander@1423
   136
						flags, 
dvander@1423
   137
						const String:reason[],
dvander@1423
   138
						const String:command[]="",
dvander@1423
   139
						any:source=0);
dvander@1423
   140
dvander@1423
   141
/**
dvander@1423
   142
 * Removes a ban that was written to the server (either in memory or on disk).
dvander@1423
   143
 *
dvander@1423
   144
 * @param identity		String to unban (ip or authstring).
dvander@1423
   145
 * @param flags			Flags (only IP and AUTHID are valid flags here).
dvander@1423
   146
 * @param command		Command strnig to identify the source.  If this is left 
dvander@1423
   147
 *						empty, then OnRemoveBan will not be called.
dvander@1423
   148
 * @param source		A source value that could be interpreted as a player 
dvander@1423
   149
 *						index of any sort (not actually checked by Core).
dvander@1423
   150
 * @return				True on success, false on failure.
dvander@1423
   151
 */
dvander@1423
   152
native bool:RemoveBan(const String:identity[], 
dvander@1423
   153
					  flags, 
dvander@1423
   154
					  const String:command[]="", 
dvander@1423
   155
					  any:source=0);
dvander@1423
   156