Skip to content

Commit 8d535c8

Browse files
authored
feat: cvars spray_exploit_fixer_punish_client and spray_exploit_fixer_bantime (#6)
1 parent 61c4703 commit 8d535c8

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

addons/sourcemod/scripting/FixSprayExploit.sp

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

1919

2020

21-
#define PLUGIN_VERSION "2.22"
21+
#define PLUGIN_VERSION "2.23"
2222

2323
/*=======================================================================================
2424
Plugin Info:
@@ -31,8 +31,11 @@
3131
3232
========================================================================================
3333
Change Log:
34+
2.23 (01-Apr-2023)
35+
- Now only TestClient depending cvar
36+
- Now ban lenght can be adjusted via cvar
3437
35-
2.22 (15-Feb-2023)
38+
2.22 (19-Feb-2023)
3639
- Now prevents even more log spamming duplicate entries. Thanks to ".Rushaway" for reporting.
3740
3841
2.21 (22-Jan-2023)
@@ -181,7 +184,7 @@ char g_sDownloads[PLATFORM_MAX_PATH];
181184
char g_sPath1[MAXPLAYERS+1][PLATFORM_MAX_PATH];
182185
char g_sPath2[MAXPLAYERS+1][PLATFORM_MAX_PATH];
183186
float g_fSprayed[MAXPLAYERS+1];
184-
ConVar g_hCvarBan, g_hCvarKick, g_hCvarLog, g_hCvarMsg, g_hCvarPath;
187+
ConVar g_hCvarBan, g_hCvarBanTime, g_hCvarKick, g_hCvarLog, g_hCvarMsg, g_hCvarPath, g_hCvarPunish;
185188
EngineVersion g_iEngine;
186189
StringMap g_smChecked;
187190
StringMap g_smReceive;
@@ -259,11 +262,13 @@ public void OnPluginStart()
259262
}
260263
}
261264

262-
CreateConVar( "spray_exploit_fixer", PLUGIN_VERSION, "Spray Exploit Fixer plugin version.", FCVAR_DONTRECORD);
265+
CreateConVar( "spray_exploit_fixer", PLUGIN_VERSION, "Spray Exploit Fixer plugin version.", FCVAR_DONTRECORD);
266+
g_hCvarPunish = CreateConVar( "spray_exploit_fixer_punish_client", "0", "0=Off. 1=PlayerDecal. 2=FileCheck. 3=Both. Run the TestClient function");
263267
if( g_iEngine != Engine_TF2 )
264268
{
265-
g_hCvarBan = CreateConVar( "spray_exploit_fixer_ban", "0", "0=Off. 1=Ban users who trigger invalid sprays (may still be some false positives).");
266-
g_hCvarKick = CreateConVar( "spray_exploit_fixer_kick", "0", "0=Off. 1=Kick users who trigger invalid sprays (may still be some false positives).");
269+
g_hCvarBan = CreateConVar( "spray_exploit_fixer_ban", "0", "0=Off. 1=Ban users who trigger invalid sprays (may still be some false positives).");
270+
g_hCvarKick = CreateConVar( "spray_exploit_fixer_kick", "0", "0=Off. 1=Kick users who trigger invalid sprays (may still be some false positives).");
271+
g_hCvarBanTime = CreateConVar( "spray_exploit_fixer_bantime", "5", "0=Perm. Ban time (in minutes)");
267272
}
268273
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.");
269274
g_hCvarMsg = CreateConVar( "spray_exploit_fixer_msg", "1", "Print to server console: 0=Off. 1=Missing sprays and invalid sprays. 2=Only invalid sprays.");
@@ -733,9 +738,9 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
733738

734739
if( !val )
735740
{
736-
static char auth[32];
741+
static char auth[64];
737742
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
738-
if( strncmp(auth[6], "ID_", 3) == 0 )
743+
if ( auth[6] == 'I' )
739744
{
740745
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
741746
Format(auth, sizeof(auth), "Unverified: %s", auth);
@@ -750,7 +755,8 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
750755
if( g_hCvarMsg.IntValue ) PrintToServer("[Spray Exploit] Blocked invalid spray: %s from (%N) [%s]", g_sFilename, client, auth);
751756
}
752757

753-
TestClient(client);
758+
if( g_hCvarPunish.IntValue == 1 || g_hCvarPunish.IntValue >= 3)
759+
TestClient(client);
754760
}
755761
else
756762
{
@@ -841,26 +847,23 @@ void TestClient(int client)
841847
{
842848
if( g_hCvarBan.IntValue )
843849
{
850+
int iDuration = g_hCvarBanTime.IntValue;
851+
844852
if( g_bSourceBans )
845-
{
846-
SBPP_BanPlayer(0, client, 0, "Invalid spray");
847-
LogAction(client, -1, "[Spray Exploit] %L Banned for invalid Spray", client);
848-
}
853+
SBPP_BanPlayer(0, client, iDuration, "Invalid spray");
849854
else if( g_bMaterialAdmin )
850-
{
851-
MABanPlayer(0, client, MA_BAN_STEAM, 0, "Invalid spray");
852-
LogAction(client, -1, "[Spray Exploit] %L Banned for invalid Spray", client);
853-
}
855+
MABanPlayer(0, client, MA_BAN_STEAM, iDuration, "Invalid spray");
854856
else
855-
{
856-
BanClient(client, 0, BANFLAG_AUTO, "Invalid spray");
857-
LogAction(client, -1, "[Spray Exploit] %L Banned for invalid Spray", client);
858-
}
857+
BanClient(client, iDuration, BANFLAG_AUTO, "Invalid spray");
858+
859+
LogAction(client, -1, "[Spray Exploit] %L Banned %d minutes for invalid Spray", client, iDuration);
860+
return;
859861
}
860862
else if( g_hCvarKick.IntValue )
861863
{
862-
KickClient(client, "Invalid spray");
863-
LogAction(client, -1, "[Spray Exploit] %L kicked for invalid Spray", client);
864+
KickClient(client, "Invalid spray. Please change it");
865+
LogAction(client, -1, "[Spray Exploit] %L was kicked for invalid Spray.", client);
866+
return;
864867
}
865868
}
866869
}
@@ -903,9 +906,9 @@ public Action OnFileReceive(int client, const char[] sFile)
903906
{
904907
if( client )
905908
{
906-
static char auth[32];
909+
static char auth[64];
907910
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
908-
if( strncmp(auth[6], "ID_", 3) == 0 )
911+
if ( auth[6] == 'I' )
909912
{
910913
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
911914
Format(auth, sizeof(auth), "Unverified: %s", auth);
@@ -969,9 +972,9 @@ void FileCheck()
969972
if( !client ) client = GetClientFromJingle();
970973
if( client )
971974
{
972-
static char auth[32];
975+
static char auth[64];
973976
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth));
974-
if( strncmp(auth[6], "ID_", 3) == 0 )
977+
if ( auth[6] == 'I' )
975978
{
976979
GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth), false);
977980
Format(auth, sizeof(auth), "Unverified: %s", auth);
@@ -984,7 +987,8 @@ void FileCheck()
984987
if( g_hCvarMsg.IntValue ) PrintToServer("[Spray Exploit] Invalid spray: %s: %02d (%02X <> %02X)", g_sFilename, i, iRead[i], g_iVal[i]);
985988
}
986989

987-
TestClient(client);
990+
if( g_hCvarPunish.IntValue >= 2 )
991+
TestClient(client);
988992

989993
g_smChecked.SetValue(g_sFilename, false);
990994
return;

0 commit comments

Comments
 (0)