Skip to content

Commit d6091d7

Browse files
authored
feat(2.26): API, Refactoring (#17)
1 parent 086510f commit d6091d7

File tree

2 files changed

+85
-13
lines changed

2 files changed

+85
-13
lines changed

addons/sourcemod/scripting/FixSprayExploit.sp

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

1919

2020

21-
#define PLUGIN_VERSION "2.25"
21+
#define PLUGIN_VERSION "2.26"
2222

2323
/*=======================================================================================
2424
Plugin Info:
@@ -32,6 +32,10 @@
3232
========================================================================================
3333
Change Log:
3434
35+
2.26 (21-May-2025)
36+
- Added native "SprayExploitFixer_LogCustom" to log custom messages. Requested by ".Rushaway".
37+
- Added RegPluginLibrary "spray_exploit_fixer".
38+
3539
2.25 (04-Jan-2025)
3640
- Changes to the recent exploit fix. Thanks to "Madness (null138)" for fixing and reporting.
3741
@@ -184,6 +188,7 @@
184188

185189
#include <sourcemod>
186190
#include <sdktools>
191+
#include <spray_exploit>
187192

188193

189194
#define MAX_READ 50
@@ -240,6 +245,10 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
240245
MarkNativeAsOptional("SBPP_BanPlayer");
241246
MarkNativeAsOptional("MABanPlayer");
242247

248+
RegPluginLibrary("spray_exploit_fixer");
249+
250+
CreateNative("SprayExploitFixer_LogCustom", Native_LogCustom);
251+
243252
g_iEngine = GetEngineVersion();
244253
g_bLate = late;
245254

@@ -318,7 +327,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
318327
static char sTemp[PLATFORM_MAX_PATH];
319328
GetPlayerJingleFile(client, sTemp, sizeof(sTemp));
320329

321-
Format(cc, sizeof(cc), "/%c%c/", sTemp[0], sTemp[1]);
330+
FormatEx(cc, sizeof(cc), "/%c%c/", sTemp[0], sTemp[1]);
322331
Format(sTemp, sizeof(sTemp), "%s%s.dat", g_sDownloads, sTemp);
323332
ReplaceString(sTemp, sizeof(sTemp), "/cc/", cc);
324333

@@ -607,7 +616,7 @@ void RecursiveSearchDirs(int client, ArrayList aList, int &count, int &counts, b
607616
pos = FindCharInString(sPath, '/', true);
608617
if( pos != -1 ) sPath[pos] = 0;
609618

610-
Format(sNew, sizeof(sNew), "%s/%s/%s", g_sMoveFiles, PATH_BACKUP, sPath[pos + 1]);
619+
FormatEx(sNew, sizeof(sNew), "%s/%s/%s", g_sMoveFiles, PATH_BACKUP, sPath[pos + 1]);
611620
if( FileExists(sNew, true) ) DeleteFile(sNew, true);
612621

613622
if( pos != -1 ) sPath[pos] = '/';
@@ -761,7 +770,7 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
761770
ReplaceString(g_sFilename, sizeof(g_sFilename), g_sDownloads, "");
762771
ReplaceString(g_sFilename, sizeof(g_sFilename), ".dat", "");
763772

764-
Format(cc, sizeof(cc), "/%c%c/", g_sFilename[0], g_sFilename[1]);
773+
FormatEx(cc, sizeof(cc), "/%c%c/", g_sFilename[0], g_sFilename[1]);
765774
Format(g_sFilename, sizeof(g_sFilename), "%s%s.dat", g_sDownloads, g_sFilename);
766775
ReplaceString(g_sFilename, sizeof(g_sFilename), "/cc/", cc);
767776

@@ -777,9 +786,9 @@ Action PlayerDecal(const char[] te_name, const int[] Players, int numClients, fl
777786
{
778787
static char auth[64];
779788
if ( g_sAuth[client][6] == 'I' )
780-
Format(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
789+
FormatEx(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
781790
else
782-
Format(auth, sizeof(auth), "%s", g_sAuth[client]);
791+
FormatEx(auth, sizeof(auth), "%s", g_sAuth[client]);
783792

784793
if( FileExists(g_sFilename) )
785794
{
@@ -942,9 +951,9 @@ public Action OnFileReceive(int client, const char[] sFile)
942951
{
943952
static char auth[64];
944953
if ( g_sAuth[client][6] == 'I' )
945-
Format(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
954+
FormatEx(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
946955
else
947-
Format(auth, sizeof(auth), "%s", g_sAuth[client]);
956+
FormatEx(auth, sizeof(auth), "%s", g_sAuth[client]);
948957

949958
LogCustom("File received: %s from (%N) [%s]", sFile, client, auth);
950959
}
@@ -1006,9 +1015,9 @@ void FileCheck()
10061015
{
10071016
static char auth[64];
10081017
if ( g_sAuth[client][6] == 'I' )
1009-
Format(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
1018+
FormatEx(auth, sizeof(auth), "Unverified: %s", g_sAuthUnverified[client]);
10101019
else
1011-
Format(auth, sizeof(auth), "%s", g_sAuth[client]);
1020+
FormatEx(auth, sizeof(auth), "%s", g_sAuth[client]);
10121021

10131022
if( g_hCvarLog.IntValue ) LogCustom("Invalid spray: %s from (%N) [%s]", g_sFilename, client, auth);
10141023
if( g_hCvarMsg.IntValue ) PrintToServer("[Spray Exploit] Invalid spray: %s: %02d (%02X <> %02X) from (%N) [%s]", g_sFilename, i, iRead[i], g_iVal[i], client, auth);
@@ -1048,7 +1057,7 @@ int ValFile(int iRead[sizeof(g_iVal)])
10481057
return -1;
10491058
}
10501059

1051-
if( iRead[16] == 80 && iRead[24] > 1 )
1060+
if( iRead[21] == 42 && iRead[24] > 1 || iRead[16] == 80 && iRead[24] > 1)
10521061
{
10531062
return 24;
10541063
}
@@ -1066,13 +1075,13 @@ int ValFile(int iRead[sizeof(g_iVal)])
10661075
case 8: read = iRead[i] <= 5;
10671076
case 16, 18:
10681077
{
1069-
Format(bytes, sizeof(bytes), "%02X%02X", iRead[i+1], iRead[i]);
1078+
FormatEx(bytes, sizeof(bytes), "%02X%02X", iRead[i+1], iRead[i]);
10701079
n = HexToDec(bytes);
10711080
if( n < 0 || n > 8192 ) read = false;
10721081
}
10731082
case 20:
10741083
{
1075-
Format(bytes, sizeof(bytes), "%02X%02X%02X%02X", iRead[i+3], iRead[i+2], iRead[i+1], iRead[i]);
1084+
FormatEx(bytes, sizeof(bytes), "%02X%02X%02X%02X", iRead[i+3], iRead[i+2], iRead[i+1], iRead[i]);
10761085
n = HexToDec(bytes);
10771086
if( n & (0x8000|0x10000|0x800000) ) read = false;
10781087
}
@@ -1132,3 +1141,11 @@ void LogCustom(const char[] format, any ...)
11321141
FlushFile(file);
11331142
delete file;
11341143
}
1144+
1145+
public int Native_LogCustom(Handle plugin, int numParams)
1146+
{
1147+
char sBuffer[2048];
1148+
FormatNativeString(0, 1, 2, sizeof(sBuffer), _, sBuffer);
1149+
LogCustom(sBuffer);
1150+
return 1;
1151+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Spray Exploit Fixer
3+
* Copyright (C) 2025 Silvers
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
#if defined _spray_exploit_included
20+
#endinput
21+
#endif
22+
#define _spray_exploit_included
23+
24+
25+
public SharedPlugin __pl_spray_exploit =
26+
{
27+
name = "spray_exploit_fixer",
28+
file = "spray_exploit_fixer.smx",
29+
#if defined REQUIRE_PLUGIN
30+
required = 1,
31+
#else
32+
required = 0,
33+
#endif
34+
};
35+
36+
37+
38+
/**
39+
* @brief Triggers when a clients spray was detected
40+
*
41+
* @param client client index of the detected player
42+
* @param index position of detection
43+
* @param value value detected
44+
*
45+
* @noreturn
46+
*/
47+
forward void OnSprayExploit(int client, int index, int value);
48+
49+
/**
50+
* Log a message into logs/spray_downloads.log
51+
*
52+
* @param format Message to log
53+
* @noreturn
54+
*/
55+
native void SprayExploitFixer_LogCustom(const char[] format, any ...);

0 commit comments

Comments
 (0)