Skip to content

Commit 3735c8e

Browse files
Rushawaymaxime1907
authored andcommitted
Update to 2.13
1 parent a21988e commit 3735c8e

File tree

1 file changed

+54
-26
lines changed

1 file changed

+54
-26
lines changed

addons/sourcemod/scripting/FixSprayExploit.sp

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020

21-
#define PLUGIN_VERSION "2.10"
21+
#define PLUGIN_VERSION "2.13"
2222

2323
/*=======================================================================================
2424
Plugin Info:
@@ -32,6 +32,16 @@
3232
========================================================================================
3333
Change Log:
3434
35+
2.13 (22-May-2022)
36+
- More detailed "LogAction" when kicking or banning clients.
37+
38+
2.12 (22-May-2022)
39+
- Added some more "LogAction" when kicking or banning clients.
40+
41+
2.11 (22-May-2022)
42+
- Added cvar "spray_exploit_fixer_kick" to kick clients. Ban cvar overrides this. Requested by ".Rushaway".
43+
- Changes to fix not kicking or banning clients under some conditions.
44+
3545
2.10 (23-Apr-2022)
3646
- Fixed the plugin blocking sprays on some servers. Thanks to "SuperConker" for reporting and lots of testing.
3747
@@ -130,7 +140,7 @@
130140
int g_iVal[] = {86,84,70,0,7,0,0,0,42,0,0,0,42,0,0,0,42,42,42,42,42,42,42,42,42,42,42,0,0,0,0,0,0,0,0,0};
131141
char g_sFilename[PLATFORM_MAX_PATH];
132142
char g_sDownloads[PLATFORM_MAX_PATH];
133-
ConVar g_hCvarBan, g_hCvarLog, g_hCvarPath;
143+
ConVar g_hCvarBan, g_hCvarKick, g_hCvarLog, g_hCvarPath;
134144
EngineVersion g_iEngine;
135145
StringMap g_smChecked;
136146
float g_fTime;
@@ -206,7 +216,10 @@ public void OnPluginStart()
206216

207217
CreateConVar( "spray_exploit_fixer", PLUGIN_VERSION, "Spray Exploit Fixer plugin version.", FCVAR_DONTRECORD);
208218
if( g_iEngine != Engine_TF2 )
219+
{
209220
g_hCvarBan = CreateConVar( "spray_exploit_fixer_ban", "0", "0=Off. 1=Ban users who trigger invalid sprays (may still be some false positives).");
221+
g_hCvarKick = CreateConVar( "spray_exploit_fixer_kick", "0", "0=Off. 1=Kick users who trigger invalid sprays (may still be some false positives).");
222+
}
210223
g_hCvarLog = CreateConVar( "spray_exploit_fixer_log", "1", "Logging saved to sourcemod/logs/spray_downloads.log: 0=Off. 1=Log all user uploads. 2=Log invalid sprays only.");
211224
g_hCvarPath = CreateConVar( "spray_exploit_fixer_path", g_sDownloads, "Path to the downloads folder of sprays. Add /cc/ if sprays are stored in individual 2 character folders. Must contain trailing / slash.");
212225
AutoExecConfig(true);
@@ -267,7 +280,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
267280
Format(sTemp, sizeof(sTemp), "%s%s.dat", g_sDownloads, sTemp);
268281
ReplaceString(sTemp, sizeof(sTemp), "/cc/", cc);
269282

270-
int val;
283+
bool val;
271284
if( g_smChecked.GetValue(sTemp, val) )
272285
{
273286
if( !val )
@@ -298,7 +311,7 @@ public Action CmdSprays(int client, int args)
298311
return Plugin_Handled;
299312
}
300313

301-
PrintToServer("[Sprays] checking files, please wait...");
314+
ReplyToCommand(client, "[Sprays] checking files, please wait...");
302315

303316
int count, counts;
304317
g_bProc = true;
@@ -378,7 +391,7 @@ void RecursiveSearchDirs(int client, const char[] sDir, int &count, int &counts,
378391
{
379392
count++;
380393

381-
PrintToServer("Invalid file: %s: %02d (%02X <> %02X)", sPath, i, iRead[i], g_iVal[i]);
394+
PrintToConsole(client, "Invalid file: %s: %02d (%02X <> %02X)", sPath, i, iRead[i], g_iVal[i]);
382395
}
383396
}
384397
}
@@ -408,7 +421,7 @@ void RecursiveSearchDirs(int client, const char[] sDir, int &count, int &counts,
408421
if( level == dirs )
409422
{
410423
g_bProc = false;
411-
ReplyToCommand(client, "Downloads checked. Found %d of %d invalid. Took %0.2f seconds.", count, counts, GetEngineTime() - g_fTime);
424+
ReplyToCommand(client, "[Sprays] downloads checked. Found %d of %d invalid. Took %0.2f seconds.", count, counts, GetEngineTime() - g_fTime);
412425
}
413426
}
414427

@@ -472,6 +485,8 @@ public Action PlayerDecal(const char[] te_name, const int[] Players, int numClie
472485
{
473486
if( g_hCvarLog.IntValue ) LogCustom("Blocked invalid spray: %s from (%N) [%s]", g_sFilename, client, auth);
474487
PrintToServer("Blocked invalid spray: %s from (%N) [%s]", g_sFilename, client, auth);
488+
489+
TestClient(client);
475490
}
476491
else
477492
{
@@ -551,6 +566,36 @@ int GetClientFromJingle()
551566
return 0;
552567
}
553568

569+
void TestClient(int client)
570+
{
571+
if( g_iEngine != Engine_TF2 && client )
572+
{
573+
if( g_hCvarBan.IntValue )
574+
{
575+
if( g_bSourceBans )
576+
{
577+
SBPP_BanPlayer(0, client, 0, "[Spray Exploit] Invalid spray");
578+
LogAction(client, -1, "[Spray Exploit] \"%L\" Banned for invalid Spray.", client);
579+
}
580+
else if( g_bMaterialAdmin )
581+
{
582+
MABanPlayer(0, client, MA_BAN_STEAM, 0, "[Spray Exploit] Invalid spray");
583+
LogAction(client, -1, "[Spray Exploit] \"%L\" Banned for invalid Spray.", client);
584+
}
585+
else
586+
{
587+
BanClient(client, 0, BANFLAG_AUTO, "[Spray Exploit] Invalid spray");
588+
LogAction(client, -1, "[Spray Exploit] \"%L\" Banned for invalid Spray.", client);
589+
}
590+
}
591+
else if( g_hCvarKick.IntValue )
592+
{
593+
KickClient(client, "Invalid spray. Please change it.");
594+
LogAction(client, -1, "[Spray Exploit] \"%L\" kicked for invalid Spray.", client);
595+
}
596+
}
597+
}
598+
554599
public Action OnFileReceive(int client, const char[] sFile)
555600
{
556601
strcopy(g_sFilename, sizeof(g_sFilename), sFile);
@@ -626,24 +671,7 @@ void FileCheck()
626671
PrintToServer("Invalid spray: %s: %02d (%02X <> %02X)", g_sFilename, i, iRead[i], g_iVal[i]);
627672
}
628673

629-
if( g_iEngine != Engine_TF2 )
630-
{
631-
if( client && g_hCvarBan.IntValue )
632-
{
633-
if( g_bSourceBans )
634-
{
635-
SBPP_BanPlayer(0, client, 0, "[Spray Exploit] Invalid spray");
636-
}
637-
else if( g_bMaterialAdmin )
638-
{
639-
MABanPlayer(0, client, MA_BAN_STEAM, 0, "[Spray Exploit] Invalid spray");
640-
}
641-
else
642-
{
643-
BanClient(client, 0, BANFLAG_AUTO, "[Spray Exploit] Invalid spray");
644-
}
645-
}
646-
}
674+
TestClient(client);
647675

648676
ConfigFile(false);
649677
return;
@@ -652,7 +680,7 @@ void FileCheck()
652680
ConfigFile(true);
653681
} else {
654682
if( g_hCvarLog.IntValue ) LogCustom("Missing file: %s", g_sFilename);
655-
PrintToServer("Missing file: %s", g_sFilename);
683+
PrintToServer("[Sprays] Missing file: %s", g_sFilename);
656684
}
657685
}
658686
}
@@ -759,4 +787,4 @@ void LogCustom(const char[] format, any ...)
759787
file.WriteLine("%s: %s", sTime, buffer);
760788
FlushFile(file);
761789
delete file;
762-
}
790+
}

0 commit comments

Comments
 (0)