summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/include/banning.inc
blob: e22f641360542d94060deced1bced8c1a1f09bcb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This file is part of the SourceMod/SourcePawn SDK.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

#if defined _banning_included
 #endinput
#endif
#define _banning_included

#define BANFLAG_AUTO        (1<<0)  /**< Auto-detects whether to ban by steamid or IP */
#define BANFLAG_IP          (1<<1)  /**< Always ban by IP address */
#define BANFLAG_AUTHID      (1<<2)  /**< Always ban by authstring (for BanIdentity) if possible */
#define BANFLAG_NOKICK      (1<<3)  /**< Does not kick the client */

/**
 * Called for calls to BanClient() with a non-empty command.
 *
 * @param client        Client being banned.
 * @param time          Time the client is being banned for (0 = permanent).
 * @param flags         One if AUTHID or IP will be enabled.  If AUTO is also 
 *                      enabled, it means Core autodetected which to use.
 * @param reason        Reason passed via BanClient().
 * @param kick_message  Kick message passed via BanClient().
 * @param command       Command string to identify the ban source.
 * @param source        Source value passed via BanClient().
 * @return              Plugin_Handled to block the actual server banning.
 *                      Kicking will still occur.
 */
forward Action OnBanClient(int client,
						   int time, 
						   int flags, 
						   const char[] reason, 
						   const char[] kick_message, 
						   const char[] command,
						   any source);

/**
 * Called for calls to BanIdentity() with a non-empty command.
 *
 * @param identity      Identity string being banned (authstring or ip).
 * @param time          Time the client is being banned for (0 = permanent).
 * @param flags         Ban flags (only IP or AUTHID are valid here).
 * @param reason        Reason passed via BanIdentity().
 * @param command       Command string to identify the ban source.
 * @param source        Source value passed via BanIdentity().
 * @return              Plugin_Handled to block the actual server banning.
 */
forward Action OnBanIdentity(const char[] identity,
							 int time,
							 int flags,
							 const char[] reason,
							 const char[] command,
							 any source);

/**
 * Called for calls to RemoveBan() with a non-empty command.
 *
 * @param identity      Identity string being banned (authstring or ip).
 * @param flags         Ban flags (only IP or AUTHID are valid here).
 * @param command       Command string to identify the ban source.
 * @param source        Source value passed via BanIdentity().
 * @return              Plugin_Handled to block the actual unbanning.
 */
forward Action OnRemoveBan(const char[] identity,
						   int flags,
						   const char[] command,
						   any source);

/**
 * Bans a client.
 *
 * @param client        Client being banned.
 * @param time          Time (in minutes) to ban (0 = permanent).
 * @param flags         Flags for controlling the ban mechanism.  If AUTHID 
 *                      is set and no AUTHID is available, the ban will fail 
 *                      unless AUTO is also flagged.
 * @param reason        Reason to ban the client for.
 * @param kick_message  Message to display to the user when kicking.
 * @param command       Command string to identify the source.  If this is left 
 *                      empty, then the OnBanClient forward will not be called.
 * @param source        A source value that could be interpreted as a player 
 *                      index of any sort (not actually checked by Core).
 * @return              True on success, false on failure.
 * @error               Invalid client index or client not in game.
 */
native bool BanClient(int client, 
					  int time, 
					  int flags, 
					  const char[] reason, 
					  const char[] kick_message="", 
					  const char[] command="",
					  any source=0);

/**
 * Bans an identity (either an IP address or auth string).
 *
 * @param identity      String to ban (ip or authstring).
 * @param time          Time to ban for (0 = permanent).
 * @param flags         Flags (only IP and AUTHID are valid flags here).
 * @param reason        Ban reason string.
 * @param command       Command string to identify the source.  If this is left 
 *                      empty, then the OnBanIdentity forward will not be called.
 * @param source        A source value that could be interpreted as a player
 *                      index of any sort (not actually checked by Core).
 * @return              True on success, false on failure.
 */
native bool BanIdentity(const char[] identity, 
						int time, 
						int flags, 
						const char[] reason,
						const char[] command="",
						any source=0);

/**
 * Removes a ban that was written to the server (either in memory or on disk).
 *
 * @param identity      String to unban (ip or authstring).
 * @param flags         Flags (only IP and AUTHID are valid flags here).
 * @param command       Command string to identify the source.  If this is left 
 *                      empty, then OnRemoveBan will not be called.
 * @param source        A source value that could be interpreted as a player 
 *                      index of any sort (not actually checked by Core).
 * @return              True on success, false on failure.
 */
native bool RemoveBan(const char[] identity, 
					  int flags, 
					  const char[] command="", 
					  any source=0);