plugins/include/banning.inc
changeset 1423 e73b3563f254
child 1450 a824a8c3a043
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/banning.inc	Fri Sep 14 02:11:10 2007 +0000
     1.3 @@ -0,0 +1,156 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 +
    1.36 +#if defined _banning_included
    1.37 + #endinput
    1.38 +#endif
    1.39 +#define _banning_included
    1.40 +
    1.41 +#define BANFLAG_AUTO		(1<<0)	/**< Auto-detects whether to ban by steamid or IP */
    1.42 +#define BANFLAG_IP			(1<<1)	/**< Always ban by IP address */
    1.43 +#define BANFLAG_AUTHID		(1<<2)	/**< Always ban by authstring (for BanIdentity) if possible */
    1.44 +#define BANFLAG_NOKICK		(1<<3)	/**< Does not kick the client */
    1.45 +
    1.46 +/**
    1.47 + * Called for calls to BanClient() with a non-empty command.
    1.48 + *
    1.49 + * @param client		Client being banned.
    1.50 + * @param time			Time the client is being banned for (0 = permanent).
    1.51 + * @param flags			One if AUTHID or IP will be enabled.  If AUTO is also 
    1.52 + *						enabled, it means Core autodetected which to use.
    1.53 + * @param reason		Reason passed via BanClient().
    1.54 + * @param kick_message	Kick message passed via BanClient().
    1.55 + * @param command		Command string to identify the ban source.
    1.56 + * @param source		Source value passed via BanClient().
    1.57 + * @noreturn
    1.58 + */
    1.59 +forward OnBanClient(client, 
    1.60 +					time, 
    1.61 +					flags, 
    1.62 +					const String:reason[], 
    1.63 +					const String:kick_message[], 
    1.64 +					const String:command[],
    1.65 +					any:source);
    1.66 +
    1.67 +/**
    1.68 + * Called for calls to BanIdentity() with a non-empty command.
    1.69 + *
    1.70 + * @param identity		Identity string being banned (authstring or ip).
    1.71 + * @param time			Time the client is being banned for (0 = permanent).
    1.72 + * @param flags			Ban flags (only IP or AUTHID are valid here).
    1.73 + * @param reason		Reason passed via BanIdentity().
    1.74 + * @param command		Command string to identify the ban source.
    1.75 + * @param source		Source value passed via BanIdentity().
    1.76 + * @noreturn
    1.77 + */
    1.78 +forward OnBanIdentity(const String:identity[],
    1.79 +					  time,
    1.80 +					  flags,
    1.81 +					  const String:reason[],
    1.82 +					  const String:command[],
    1.83 +					  any:source);
    1.84 +
    1.85 +/**
    1.86 + * Called for calls to RemoveBan() with a non-empty command.
    1.87 + *
    1.88 + * @param identity		Identity string being banned (authstring or ip).
    1.89 + * @param flags			Ban flags (only IP or AUTHID are valid here).
    1.90 + * @param command		Command string to identify the ban source.
    1.91 + * @param source		Source value passed via BanIdentity().
    1.92 + * @noreturn
    1.93 + */
    1.94 +forward OnRemoveBan(const String:identity[],
    1.95 +					flags,
    1.96 +					const String:command[],
    1.97 +					any:source);
    1.98 +
    1.99 +/**
   1.100 + * Bans a client.
   1.101 + *
   1.102 + * @param client		Client being banned.
   1.103 + * @param time			Time (in minutes) to ban (0 = permanent).
   1.104 + * @param flags			Flags for controlling the ban mechanism.  If AUTHID 
   1.105 + *						is set and no AUTHID is available, the ban will fail 
   1.106 + *						unless AUTO is also flagged.
   1.107 + * @param reason		Reason to ban the client for.
   1.108 + * @param kick_message	Message to display to the user when kicking.
   1.109 + * @param command		Command string to identify the source.  If this is left 
   1.110 + *						empty, then the OnBanClient forward will not be called.
   1.111 + * @param source		A source value that could be interpreted as a player 
   1.112 + *						index of any sort (not actually checked by Core).
   1.113 + * @return				True on success, false on failure.
   1.114 + * @error				Invalid client index or client not in game.
   1.115 + */
   1.116 +native bool:BanClient(client, 
   1.117 +					  time, 
   1.118 +					  flags, 
   1.119 +					  const String:reason[], 
   1.120 +					  const String:kick_message[]="", 
   1.121 +					  const String:command[]="",
   1.122 +					  any:source=0);
   1.123 +
   1.124 +/**
   1.125 + * Bans an identity (either an IP address or auth string).
   1.126 + *
   1.127 + * @param identity		String to ban (ip or authstring).
   1.128 + * @param time			Time to ban for (0 = permanent).
   1.129 + * @param flags			Flags (only IP and AUTHID are valid flags here).
   1.130 + * @param reason		Ban reason string.
   1.131 + * @param command		Command string to identify the source.  If this is left 
   1.132 + *						empty, then the OnBanIdentity forward will not be called.
   1.133 + * @param source		A source value that could be interpreted as a player
   1.134 + *						index of any sort (not actually checked by Core).
   1.135 + * @return				True on success, false on failure.
   1.136 + */
   1.137 +native bool:BanIdentity(const String:identity[], 
   1.138 +						time, 
   1.139 +						flags, 
   1.140 +						const String:reason[],
   1.141 +						const String:command[]="",
   1.142 +						any:source=0);
   1.143 +
   1.144 +/**
   1.145 + * Removes a ban that was written to the server (either in memory or on disk).
   1.146 + *
   1.147 + * @param identity		String to unban (ip or authstring).
   1.148 + * @param flags			Flags (only IP and AUTHID are valid flags here).
   1.149 + * @param command		Command strnig to identify the source.  If this is left 
   1.150 + *						empty, then OnRemoveBan will not be called.
   1.151 + * @param source		A source value that could be interpreted as a player 
   1.152 + *						index of any sort (not actually checked by Core).
   1.153 + * @return				True on success, false on failure.
   1.154 + */
   1.155 +native bool:RemoveBan(const String:identity[], 
   1.156 +					  flags, 
   1.157 +					  const String:command[]="", 
   1.158 +					  any:source=0);
   1.159 +