29
29
#undef REQUIRE_PLUGIN
30
30
#include <sourcebans>
31
31
32
- #define PLUGIN_VERSION " (SB++) 1.5.4.2 "
32
+ #define PLUGIN_VERSION " (SB++) 1.5.4.3 "
33
33
34
34
#define LENGTH_ORIGINAL 1
35
35
#define LENGTH_CUSTOM 2
@@ -53,18 +53,18 @@ new bool:CanUseSourcebans = false;
53
53
54
54
public Plugin :myinfo =
55
55
{
56
- name = " SourceSleuth" ,
57
- author = " ecca, Sarabveer(VEER™)" ,
58
- description = " Useful for TF2 servers. Plugin will check for banned ips and ban the player." ,
59
- version = PLUGIN_VERSION ,
60
- url = " http://sourcemod.net"
56
+ name = " SourceSleuth" ,
57
+ author = " ecca, Sarabveer(VEER™)" ,
58
+ description = " Useful for TF2 servers. Plugin will check for banned ips and ban the player." ,
59
+ version = PLUGIN_VERSION ,
60
+ url = " http://sourcemod.net"
61
61
};
62
62
63
63
public OnPluginStart ()
64
64
{
65
65
LoadTranslations (" sourcesleuth.phrases" );
66
66
67
- CreateConVar (" sm_sourcesleuth_version" , PLUGIN_VERSION , " SourceSleuth plugin version" , FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY | FCVAR_DONTRECORD );
67
+ CreateConVar (" sm_sourcesleuth_version" , PLUGIN_VERSION , " SourceSleuth plugin version" , FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY | FCVAR_DONTRECORD );
68
68
69
69
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 );
70
70
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 );
@@ -76,7 +76,7 @@ public OnPluginStart()
76
76
g_hAllowedArray = CreateArray (256 );
77
77
78
78
AutoExecConfig (true , " Sm_SourceSleuth" );
79
-
79
+
80
80
SQL_TConnect (SQL_OnConnect , " sourcebans" );
81
81
82
82
RegAdminCmd (" sm_sleuth_reloadlist" , ReloadListCallBack , ADMFLAG_ROOT );
@@ -110,10 +110,10 @@ public SQL_OnConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
110
110
if (hndl == INVALID_HANDLE )
111
111
{
112
112
LogError (" SourceSleuth: Database connection error: %s " , error );
113
- }
114
- else
113
+ }
114
+ else
115
115
{
116
- hDatabase = hndl ;
116
+ hDatabase = hndl ;
117
117
}
118
118
}
119
119
@@ -125,7 +125,7 @@ public Action:ReloadListCallBack(client, args)
125
125
126
126
LogMessage (" %L reloaded the whitelist" , client );
127
127
128
- if (client != 0 )
128
+ if (client != 0 )
129
129
{
130
130
PrintToChat (client , " [SourceSleuth] WhiteList has been reloaded!" );
131
131
}
@@ -135,29 +135,29 @@ public Action:ReloadListCallBack(client, args)
135
135
136
136
public OnClientPostAdminCheck (client )
137
137
{
138
- if (CanUseSourcebans && ! IsFakeClient (client ))
138
+ if (CanUseSourcebans && ! IsFakeClient (client ))
139
139
{
140
- decl String :steamid [32 ];
140
+ new String :steamid [32 ];
141
141
GetClientAuthId (client , AuthId_Steam2 , steamid , sizeof (steamid ));
142
142
143
- if (g_cVar_bypass .BoolValue && CheckCommandAccess (client , " sleuth_admin" , ADMFLAG_BAN , false ))
143
+ if (g_cVar_bypass .BoolValue && CheckCommandAccess (client , " sleuth_admin" , ADMFLAG_BAN , false ))
144
144
{
145
145
return ;
146
146
}
147
147
148
- if (FindStringInArray (g_hAllowedArray , steamid ) == - 1 )
148
+ if (FindStringInArray (g_hAllowedArray , steamid ) == - 1 )
149
149
{
150
- decl String :IP [32 ], String :Prefix [64 ];
150
+ new String :IP [32 ], String :Prefix [64 ];
151
151
GetClientIP (client , IP , sizeof (IP ));
152
152
153
153
g_cVar_sbprefix .GetString (Prefix , sizeof (Prefix ));
154
154
155
- decl String :query [1024 ];
156
-
157
- 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 );
155
+ new String :query [1024 ];
158
156
157
+ 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 );
158
+
159
159
new Handle :datapack = CreateDataPack ();
160
-
160
+
161
161
WritePackCell (datapack , GetClientUserId (client ));
162
162
WritePackString (datapack , steamid );
163
163
WritePackString (datapack , IP );
@@ -173,12 +173,12 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
173
173
new client ;
174
174
decl String :steamid [32 ], String :IP [32 ];
175
175
176
- if (datapack != INVALID_HANDLE )
176
+ if (datapack != INVALID_HANDLE )
177
177
{
178
178
client = GetClientOfUserId (ReadPackCell (datapack ));
179
179
ReadPackString (datapack , steamid , sizeof (steamid ));
180
180
ReadPackString (datapack , IP , sizeof (IP ));
181
- CloseHandle (datapack );
181
+ CloseHandle (datapack );
182
182
}
183
183
184
184
if (hndl == INVALID_HANDLE )
@@ -190,14 +190,14 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
190
190
{
191
191
new TotalBans = SQL_GetRowCount (hndl );
192
192
193
- if (TotalBans > g_cVar_bansAllowed .IntValue )
193
+ if (TotalBans > g_cVar_bansAllowed .IntValue )
194
194
{
195
195
switch (g_cVar_actions .IntValue )
196
196
{
197
197
case LENGTH_ORIGINAL :
198
198
{
199
199
new length = SQL_FetchInt (hndl , 6 );
200
- new time = length * 60 ;
200
+ new time = length * 60 ;
201
201
202
202
BanPlayer (client , time );
203
203
}
@@ -209,14 +209,14 @@ public SQL_CheckHim(Handle:owner, Handle:hndl, const String:error[], any:datapac
209
209
case LENGTH_DOUBLE :
210
210
{
211
211
new length = SQL_FetchInt (hndl , 6 );
212
- new time = length / 60 * 2 ;
213
-
212
+ new time = length / 60 * 2 ;
213
+
214
214
BanPlayer (client , time );
215
215
}
216
216
case LENGTH_NOTIFY :
217
217
{
218
218
/* Notify Admins when a client with an ip on the bans list connects */
219
- PrintToAdmins (" [SourceSleuth] %t " , " sourcesleuth_admintext" , client , steamid , IP );
219
+ PrintToAdmins (" [SourceSleuth] %t " , " sourcesleuth_admintext" ,client , steamid , IP );
220
220
}
221
221
}
222
222
}
@@ -232,9 +232,9 @@ stock BanPlayer(client, time)
232
232
233
233
PrintToAdmins (const String :format [], any : ...)
234
234
{
235
- decl String :g_Buffer [256 ];
235
+ new String :g_Buffer [256 ];
236
236
237
- for (new i = 1 ; i <= MaxClients ; i ++ )
237
+ for (new i = 1 ; i <= MaxClients ;i ++ )
238
238
{
239
239
if (CheckCommandAccess (i , " sm_sourcesleuth_printtoadmins" , ADMFLAG_BAN ) && IsClientInGame (i ))
240
240
{
@@ -248,25 +248,17 @@ PrintToAdmins(const String:format[], any:...)
248
248
public LoadWhiteList ()
249
249
{
250
250
decl String :path [PLATFORM_MAX_PATH ], String :line [256 ];
251
-
251
+
252
252
BuildPath (Path_SM , path , PLATFORM_MAX_PATH , " configs/sourcesleuth_whitelist.cfg" );
253
-
253
+
254
254
new Handle :fileHandle = OpenFile (path , " r" );
255
-
256
- if (fileHandle != INVALID_HANDLE )
257
- {
258
- while (! IsEndOfFile (fileHandle ) && ReadFileLine (fileHandle , line , sizeof (line )))
259
- {
260
- ReplaceString (line , sizeof (line ), " \n " , " " , false );
261
-
262
- PushArrayString (g_hAllowedArray , line );
263
- }
264
-
265
- CloseHandle (fileHandle );
266
- }
267
- else
255
+
256
+ while (! IsEndOfFile (fileHandle ) && ReadFileLine (fileHandle , line , sizeof (line )))
268
257
{
269
- LogError (" [SM] Warning File: \" configs/sourcesleuth_whitelist.cfg\" missing or inaccessible." );
270
- LogError (" [SM] Continuing without loading ip address whitelists." );
258
+ ReplaceString (line , sizeof (line ), " \n " , " " , false );
259
+
260
+ PushArrayString (g_hAllowedArray , line );
271
261
}
262
+
263
+ CloseHandle (fileHandle );
272
264
}
0 commit comments