Skip to content

Commit

Permalink
Better anti-cheat measures
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch committed Apr 10, 2022
1 parent b2f23b0 commit f05c006
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
22 changes: 18 additions & 4 deletions addons/sourcemod/scripting/prophunt.sp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.3.3"
#define PLUGIN_VERSION "1.3.4"

#define PLUGIN_TAG "[{orange}PropHunt{default}]"

Expand Down Expand Up @@ -110,6 +110,7 @@ bool g_InSetup;
bool g_IsLastPropStanding;
bool g_DisallowPropLocking;
bool g_InHealthKitTouch;
Handle g_AntiCheatTimer;
Handle g_ChatTipTimer;
Handle g_ControlPointBonusTimer;

Expand Down Expand Up @@ -471,11 +472,14 @@ void TogglePlugin(bool enable)
{
Precache();

g_AntiCheatTimer = CreateTimer(0.1, Timer_CheckStaticPropInfo, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);

if (ph_chat_tip_interval.FloatValue > 0)
g_ChatTipTimer = CreateTimer(ph_chat_tip_interval.FloatValue, Timer_PrintChatTip, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
else
{
delete g_AntiCheatTimer;
delete g_ChatTipTimer;
delete g_ControlPointBonusTimer;
}
Expand Down Expand Up @@ -843,12 +847,12 @@ void CheckLastPropStanding(int client)
}
}

public void ConVarQuery_StaticPropInfo(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue)
public void ConVarQuery_StaticPropInfo(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any expectedValue)
{
if (result == ConVarQuery_Okay)
{
int value = StringToInt(cvarValue);
if (value == 0)
int value;
if (StringToIntEx(cvarValue, value) > 0 && value == expectedValue)
return;

KickClient(client, "%t", "PH_ConVarQuery_DisallowedValue", cvarName, cvarValue);
Expand Down Expand Up @@ -970,6 +974,16 @@ public Action Timer_PropPostSpawn(Handle timer, int serial)
return Plugin_Continue;
}

public Action Timer_CheckStaticPropInfo(Handle timer)
{
// Query every client for r_staticpropinfo to prevent cheating
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && !IsFakeClient(client))
QueryClientConVar(client, "r_staticpropinfo", ConVarQuery_StaticPropInfo, 0);
}
}

public Action Timer_PrintChatTip(Handle timer)
{
static int count;
Expand Down
7 changes: 0 additions & 7 deletions addons/sourcemod/scripting/prophunt/events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,4 @@ public void EventHook_ArenaRoundStart(Event event, const char[] name, bool dontB
HookSingleEntityOutput(timer, "OnFinished", EntityOutput_OnFinished, true);
}
}

// Kick cheaters out of the game
for (int client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client) && !IsFakeClient(client))
QueryClientConVar(client, "r_staticpropinfo", ConVarQuery_StaticPropInfo);
}
}

0 comments on commit f05c006

Please sign in to comment.