31
31
#undef REQUIRE_PLUGIN
32
32
#include <sourcebans>
33
33
34
- #define PLUGIN_VERSION " (SB++) 1.5.4.5 "
34
+ #define PLUGIN_VERSION " (SB++) 1.5.4.6 "
35
35
36
36
#define LENGTH_ORIGINAL 1
37
37
#define LENGTH_CUSTOM 2
@@ -53,36 +53,36 @@ ConVar g_cVar_bypass;
53
53
//- Bools -//
54
54
new bool :CanUseSourcebans = false ;
55
55
56
- public Plugin :myinfo =
56
+ public Plugin :myinfo =
57
57
{
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 ,
62
62
url = " https://sarabveer.github.io/SourceBans-Fork/"
63
63
};
64
64
65
65
public OnPluginStart ()
66
66
{
67
67
LoadTranslations (" sourcesleuth.phrases" );
68
-
68
+
69
69
CreateConVar (" sm_sourcesleuth_version" , PLUGIN_VERSION , " SourceSleuth plugin version" , FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY | FCVAR_DONTRECORD );
70
-
70
+
71
71
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 );
72
72
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 );
73
73
g_cVar_sbprefix = CreateConVar (" sm_sleuth_prefix" , " sb" , " Prexfix for sourcebans tables: Default sb" , FCVAR_PLUGIN );
74
74
g_cVar_bansAllowed = CreateConVar (" sm_sleuth_bansallowed" , " 0" , " How many active bans are allowed before we act" , FCVAR_PLUGIN );
75
75
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 );
76
76
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
+
78
78
g_hAllowedArray = CreateArray (256 );
79
-
79
+
80
80
AutoExecConfig (true , " Sm_SourceSleuth" );
81
-
81
+
82
82
SQL_TConnect (SQL_OnConnect , " sourcebans" );
83
-
83
+
84
84
RegAdminCmd (" sm_sleuth_reloadlist" , ReloadListCallBack , ADMFLAG_ROOT );
85
-
85
+
86
86
LoadWhiteList ();
87
87
}
88
88
@@ -122,16 +122,16 @@ public SQL_OnConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
122
122
public Action :ReloadListCallBack (client , args )
123
123
{
124
124
ClearArray (g_hAllowedArray );
125
-
125
+
126
126
LoadWhiteList ();
127
-
127
+
128
128
LogMessage (" %L reloaded the whitelist" , client );
129
-
129
+
130
130
if (client != 0 )
131
131
{
132
132
PrintToChat (client , " [SourceSleuth] WhiteList has been reloaded!" );
133
133
}
134
-
134
+
135
135
return Plugin_Continue ;
136
136
}
137
137
@@ -141,30 +141,30 @@ public OnClientPostAdminCheck(client)
141
141
{
142
142
new String :steamid [32 ];
143
143
GetClientAuthId (client , AuthId_Steam2 , steamid , sizeof (steamid ));
144
-
144
+
145
145
if (g_cVar_bypass .BoolValue && CheckCommandAccess (client , " sleuth_admin" , ADMFLAG_BAN , false ))
146
146
{
147
147
return ;
148
148
}
149
-
149
+
150
150
if (FindStringInArray (g_hAllowedArray , steamid ) == - 1 )
151
151
{
152
152
new String :IP [32 ], String :Prefix [64 ];
153
153
GetClientIP (client , IP , sizeof (IP ));
154
-
154
+
155
155
g_cVar_sbprefix .GetString (Prefix , sizeof (Prefix ));
156
-
156
+
157
157
new String :query [1024 ];
158
-
158
+
159
159
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
+
161
161
new Handle :datapack = CreateDataPack ();
162
-
162
+
163
163
WritePackCell (datapack , GetClientUserId (client ));
164
164
WritePackString (datapack , steamid );
165
165
WritePackString (datapack , IP );
166
166
ResetPack (datapack );
167
-
167
+
168
168
SQL_TQuery (hDatabase , SQL_CheckHim , query , datapack );
169
169
}
170
170
}
@@ -174,25 +174,25 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
174
174
{
175
175
new client ;
176
176
decl String :steamid [32 ], String :IP [32 ];
177
-
177
+
178
178
if (datapack != INVALID_HANDLE )
179
179
{
180
180
client = GetClientOfUserId (ReadPackCell (datapack ));
181
181
ReadPackString (datapack , steamid , sizeof (steamid ));
182
182
ReadPackString (datapack , IP , sizeof (IP ));
183
183
CloseHandle (datapack );
184
184
}
185
-
185
+
186
186
if (hndl == INVALID_HANDLE )
187
187
{
188
188
LogError (" SourceSleuth: Database query error: %s " , error );
189
189
return ;
190
190
}
191
-
191
+
192
192
if (SQL_FetchRow (hndl ))
193
193
{
194
194
new TotalBans = SQL_GetRowCount (hndl );
195
-
195
+
196
196
if (TotalBans > g_cVar_bansAllowed .IntValue )
197
197
{
198
198
switch (g_cVar_actions .IntValue )
@@ -201,7 +201,7 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
201
201
{
202
202
new length = SQL_FetchInt (hndl , 6 );
203
203
new time = length * 60 ;
204
-
204
+
205
205
BanPlayer (client , time );
206
206
}
207
207
case LENGTH_CUSTOM :
@@ -212,14 +212,14 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
212
212
case LENGTH_DOUBLE :
213
213
{
214
214
new length = SQL_FetchInt (hndl , 6 );
215
-
215
+
216
216
new time = 0 ;
217
-
218
- if (length != 0 )
217
+
218
+ if (length != 0 )
219
219
{
220
220
time = length / 60 * 2 ;
221
221
}
222
-
222
+
223
223
BanPlayer (client , time );
224
224
}
225
225
case LENGTH_NOTIFY :
@@ -242,13 +242,13 @@ stock BanPlayer(client, time)
242
242
PrintToAdmins (const String :format [], any : ...)
243
243
{
244
244
new String :g_Buffer [256 ];
245
-
245
+
246
246
for (new i = 1 ; i <= MaxClients ; i ++ )
247
247
{
248
248
if (CheckCommandAccess (i , " sm_sourcesleuth_printtoadmins" , ADMFLAG_BAN ) && IsClientInGame (i ))
249
249
{
250
250
VFormat (g_Buffer , sizeof (g_Buffer ), format , 2 );
251
-
251
+
252
252
PrintToChat (i , " %s " , g_Buffer );
253
253
}
254
254
}
@@ -257,17 +257,17 @@ PrintToAdmins(const String:format[], any:...)
257
257
public LoadWhiteList ()
258
258
{
259
259
decl String :path [PLATFORM_MAX_PATH ], String :line [256 ];
260
-
260
+
261
261
BuildPath (Path_SM , path , PLATFORM_MAX_PATH , " configs/sourcesleuth_whitelist.cfg" );
262
-
262
+
263
263
new Handle :fileHandle = OpenFile (path , " r" );
264
-
264
+
265
265
while (! IsEndOfFile (fileHandle ) && ReadFileLine (fileHandle , line , sizeof (line )))
266
266
{
267
267
ReplaceString (line , sizeof (line ), " \n " , " " , false );
268
-
268
+
269
269
PushArrayString (g_hAllowedArray , line );
270
270
}
271
-
271
+
272
272
CloseHandle (fileHandle );
273
273
}
0 commit comments