Skip to content

Commit 780db16

Browse files
committed
Merge pull request #148 from shavitush/patch-2
Fix SourceSleuth not functioning for Perm Bans
2 parents 3608cfe + 2453503 commit 780db16

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

game_upload/addons/sourcemod/scripting/SourceSleuth.sp

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
// This file is part of SourceBans++.
33
//
44
// Copyright (C) 2014-2016 Sarabveer Singh <me@sarabveer.me>
5-
//
5+
//
66
// SourceBans++ is free software: you can redistribute it and/or modify
77
// it under the terms of the GNU General Public License as published by
88
// the Free Software Foundation, per version 3 of the License.
9-
//
9+
//
1010
// SourceBans++ is distributed in the hope that it will be useful,
1111
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
// GNU General Public License for more details.
14-
//
14+
//
1515
// You should have received a copy of the GNU General Public License
1616
// along with SourceBans++. If not, see <http://www.gnu.org/licenses/>.
1717
//
18-
// This file is based off work covered by the following copyright(s):
18+
// This file is based off work covered by the following copyright(s):
1919
//
2020
// SourceSleuth 1.3 fix
2121
// Copyright (C) 2013-2015 ecca
@@ -53,36 +53,36 @@ ConVar g_cVar_bypass;
5353
//- Bools -//
5454
new bool:CanUseSourcebans = false;
5555

56-
public Plugin:myinfo =
56+
public Plugin:myinfo =
5757
{
58-
name = "SourceSleuth",
59-
author = "ecca, Sarabveer(VEER™)",
60-
description = "Useful for TF2 servers. Plugin will check for banned ips and ban the player.",
61-
version = PLUGIN_VERSION,
58+
name = "SourceSleuth",
59+
author = "ecca, Sarabveer(VEER™)",
60+
description = "Useful for TF2 servers. Plugin will check for banned ips and ban the player.",
61+
version = PLUGIN_VERSION,
6262
url = "https://sarabveer.github.io/SourceBans-Fork/"
6363
};
6464

6565
public OnPluginStart()
6666
{
6767
LoadTranslations("sourcesleuth.phrases");
68-
68+
6969
CreateConVar("sm_sourcesleuth_version", PLUGIN_VERSION, "SourceSleuth plugin version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY | FCVAR_DONTRECORD);
70-
70+
7171
g_cVar_actions = CreateConVar("sm_sleuth_actions", "3", "Sleuth Ban Type: 1 - Original Length, 2 - Custom Length, 3 - Double Length, 4 - Notify Admins Only", FCVAR_PLUGIN, true, 1.0, true, 4.0);
7272
g_cVar_banduration = CreateConVar("sm_sleuth_duration", "0", "Required: sm_sleuth_actions 1: Bantime to ban player if we got a match (0 = permanent (defined in minutes) )", FCVAR_PLUGIN);
7373
g_cVar_sbprefix = CreateConVar("sm_sleuth_prefix", "sb", "Prexfix for sourcebans tables: Default sb", FCVAR_PLUGIN);
7474
g_cVar_bansAllowed = CreateConVar("sm_sleuth_bansallowed", "0", "How many active bans are allowed before we act", FCVAR_PLUGIN);
7575
g_cVar_bantype = CreateConVar("sm_sleuth_bantype", "0", "0 - ban all type of lengths, 1 - ban only permanent bans", FCVAR_PLUGIN, true, 0.0, true, 1.0);
7676
g_cVar_bypass = CreateConVar("sm_sleuth_adminbypass", "0", "0 - Inactivated, 1 - Allow all admins with ban flag to pass the check", FCVAR_PLUGIN, true, 0.0, true, 1.0);
77-
77+
7878
g_hAllowedArray = CreateArray(256);
79-
79+
8080
AutoExecConfig(true, "Sm_SourceSleuth");
81-
81+
8282
SQL_TConnect(SQL_OnConnect, "sourcebans");
83-
83+
8484
RegAdminCmd("sm_sleuth_reloadlist", ReloadListCallBack, ADMFLAG_ROOT);
85-
85+
8686
LoadWhiteList();
8787
}
8888

@@ -122,16 +122,16 @@ public SQL_OnConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
122122
public Action:ReloadListCallBack(client, args)
123123
{
124124
ClearArray(g_hAllowedArray);
125-
125+
126126
LoadWhiteList();
127-
127+
128128
LogMessage("%L reloaded the whitelist", client);
129-
129+
130130
if (client != 0)
131131
{
132132
PrintToChat(client, "[SourceSleuth] WhiteList has been reloaded!");
133133
}
134-
134+
135135
return Plugin_Continue;
136136
}
137137

@@ -141,30 +141,30 @@ public OnClientPostAdminCheck(client)
141141
{
142142
new String:steamid[32];
143143
GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
144-
144+
145145
if (g_cVar_bypass.BoolValue && CheckCommandAccess(client, "sleuth_admin", ADMFLAG_BAN, false))
146146
{
147147
return;
148148
}
149-
149+
150150
if (FindStringInArray(g_hAllowedArray, steamid) == -1)
151151
{
152152
new String:IP[32], String:Prefix[64];
153153
GetClientIP(client, IP, sizeof(IP));
154-
154+
155155
g_cVar_sbprefix.GetString(Prefix, sizeof(Prefix));
156-
156+
157157
new String:query[1024];
158-
158+
159159
FormatEx(query, sizeof(query), "SELECT * FROM %s_bans WHERE ip='%s' AND RemoveType IS NULL AND ends > %d", Prefix, IP, g_cVar_bantype.IntValue == 0 ? GetTime() : 0);
160-
160+
161161
new Handle:datapack = CreateDataPack();
162-
162+
163163
WritePackCell(datapack, GetClientUserId(client));
164164
WritePackString(datapack, steamid);
165165
WritePackString(datapack, IP);
166166
ResetPack(datapack);
167-
167+
168168
SQL_TQuery(hDatabase, SQL_CheckHim, query, datapack);
169169
}
170170
}
@@ -174,25 +174,25 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
174174
{
175175
new client;
176176
decl String:steamid[32], String:IP[32];
177-
177+
178178
if (datapack != INVALID_HANDLE)
179179
{
180180
client = GetClientOfUserId(ReadPackCell(datapack));
181181
ReadPackString(datapack, steamid, sizeof(steamid));
182182
ReadPackString(datapack, IP, sizeof(IP));
183183
CloseHandle(datapack);
184184
}
185-
185+
186186
if (hndl == INVALID_HANDLE)
187187
{
188188
LogError("SourceSleuth: Database query error: %s", error);
189189
return;
190190
}
191-
191+
192192
if (SQL_FetchRow(hndl))
193193
{
194194
new TotalBans = SQL_GetRowCount(hndl);
195-
195+
196196
if (TotalBans > g_cVar_bansAllowed.IntValue)
197197
{
198198
switch (g_cVar_actions.IntValue)
@@ -201,7 +201,7 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
201201
{
202202
new length = SQL_FetchInt(hndl, 6);
203203
new time = length * 60;
204-
204+
205205
BanPlayer(client, time);
206206
}
207207
case LENGTH_CUSTOM:
@@ -212,8 +212,14 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
212212
case LENGTH_DOUBLE:
213213
{
214214
new length = SQL_FetchInt(hndl, 6);
215-
new time = length / 60 * 2;
216-
215+
216+
new time = 0;
217+
218+
if(length != 0)
219+
{
220+
time = length / 60 * 2;
221+
}
222+
217223
BanPlayer(client, time);
218224
}
219225
case LENGTH_NOTIFY:
@@ -236,13 +242,13 @@ stock BanPlayer(client, time)
236242
PrintToAdmins(const String:format[], any:...)
237243
{
238244
new String:g_Buffer[256];
239-
245+
240246
for (new i = 1; i <= MaxClients; i++)
241247
{
242248
if (CheckCommandAccess(i, "sm_sourcesleuth_printtoadmins", ADMFLAG_BAN) && IsClientInGame(i))
243249
{
244250
VFormat(g_Buffer, sizeof(g_Buffer), format, 2);
245-
251+
246252
PrintToChat(i, "%s", g_Buffer);
247253
}
248254
}
@@ -251,17 +257,17 @@ PrintToAdmins(const String:format[], any:...)
251257
public LoadWhiteList()
252258
{
253259
decl String:path[PLATFORM_MAX_PATH], String:line[256];
254-
260+
255261
BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "configs/sourcesleuth_whitelist.cfg");
256-
262+
257263
new Handle:fileHandle = OpenFile(path, "r");
258-
264+
259265
while (!IsEndOfFile(fileHandle) && ReadFileLine(fileHandle, line, sizeof(line)))
260266
{
261267
ReplaceString(line, sizeof(line), "\n", "", false);
262-
268+
263269
PushArrayString(g_hAllowedArray, line);
264270
}
265-
271+
266272
CloseHandle(fileHandle);
267273
}

game_upload/addons/sourcemod/scripting/include/sourcebans.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#endif
3030
#define _sourcebans_included
3131

32-
public SharedPlugin:__pl_sourcebans =
32+
public SharedPlugin:__pl_sourcebans =
3333
{
34-
name = "SourceBans",
35-
file = "sourcebans.smx",
34+
name = "sourcebans",
35+
file = "sourcebans.smx",
3636
#if defined REQUIRE_PLUGIN
3737
required = 1
3838
#else
@@ -59,4 +59,4 @@ public __pl_sourcebans_SetNTVOptional()
5959
*********************************************************/
6060
native SBBanPlayer(client, target, time, String:reason[]);
6161

62-
//Yarr!
62+
//Yarr!

0 commit comments

Comments
 (0)