added check to prevent teleport abuse

This commit is contained in:
jenz 2022-08-02 14:27:20 +02:00
parent 63703675e1
commit d29f3fa2f1

View File

@ -1,7 +1,7 @@
#pragma semicolon 1 #pragma semicolon 1
#define DEBUG #define DEBUG
#define PLUGIN_AUTHOR "jenz" #define PLUGIN_AUTHOR "jenz"
#define PLUGIN_VERSION "1.6" #define PLUGIN_VERSION "1.7"
#define g_dLength 400 #define g_dLength 400
#define g_dIndex 65 #define g_dIndex 65
#include <sourcemod> #include <sourcemod>
@ -27,6 +27,7 @@ int g_iClientSpeedInterval[MAXPLAYERS + 1];
int g_iClientChecking[MAXPLAYERS + 1]; int g_iClientChecking[MAXPLAYERS + 1];
bool g_bDisplaySpecial; bool g_bDisplaySpecial;
bool g_bHumansAllowedTime[MAXPLAYERS + 1]; bool g_bHumansAllowedTime[MAXPLAYERS + 1];
bool g_bhumans_finished[MAXPLAYERS + 1];
bool g_bHideTimer[MAXPLAYERS + 1]; bool g_bHideTimer[MAXPLAYERS + 1];
bool g_bEventBool = false; bool g_bEventBool = false;
Handle g_hClientCookie = INVALID_HANDLE; Handle g_hClientCookie = INVALID_HANDLE;
@ -75,7 +76,7 @@ public void OnPluginStart()
public void trigger_teleport(const char[] output, int entity_index, int client, float delay) public void trigger_teleport(const char[] output, int entity_index, int client, float delay)
{ {
if (IsValidEdict(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client]) if (IsValidEdict(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client])
{ {
if (StrContains(g_cMapname, "surf", false) == -1) if (StrContains(g_cMapname, "surf", false) == -1)
{ {
@ -83,7 +84,7 @@ public void trigger_teleport(const char[] output, int entity_index, int client,
resetClientVectors(client); resetClientVectors(client);
if (GetClientTeam(client) == 3) if (GetClientTeam(client) == 3)
{ {
PrintToChat(client, "Disabled timer due to potential teleport abuse, if this is wrong annoy jenz on discord"); PrintToChat(client, "Disabled timer due to potential teleport abuse");
} }
} }
} }
@ -91,15 +92,15 @@ public void trigger_teleport(const char[] output, int entity_index, int client,
public void Trigger_Multiple(const char[] output, int entity_index, int client, float delay) public void Trigger_Multiple(const char[] output, int entity_index, int client, float delay)
{ {
if (IsValidEdict(entity_index) && origin_command_check(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client]) if (IsValidEdict(entity_index) && origin_command_check(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client])
{ {
if (StrContains(g_cMapname, "surf", false) == -1) if (StrContains(g_cMapname, "surf", false) == -1)
{ {
g_bHumansAllowedTime[client] = false; g_bHumansAllowedTime[client] = false;
resetClientVectors(client); resetClientVectors(client);
PrintToChat(client, "Disabled timer due to potential teleport abuse, if this is wrong annoy jenz on discord"); PrintToChat(client, "Disabled timer due to potential teleport abuse");
} }
} }
} }
@ -269,16 +270,17 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
for (int i = 1; i <= MaxClients; i++) for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i)) if (IsValidClient(i) && !IsFakeClient(i))
{ {
resetClientVectors(i); g_bhumans_finished[i] = false;
if (l_iZoneCount != 1) resetClientVectors(i);
g_bHumansAllowedTime[i] = false; if (l_iZoneCount != 1)
else g_bHumansAllowedTime[i] = false;
{ else
mysql_get_player_time(i, 0); {
g_bHumansAllowedTime[i] = true; mysql_get_player_time(i, 0);
g_fStartTime[i] = GetEngineTime(); g_bHumansAllowedTime[i] = true;
} g_fStartTime[i] = GetEngineTime();
} }
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -309,92 +311,107 @@ public void OnClientDisconnect(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void resetClient(int client) public void resetClient(int client)
{ {
if (0 < client <= MaxClients) if (0 < client <= MaxClients)
{ {
g_iClientChecking[client] = 0; g_iClientChecking[client] = 0;
g_bHumansAllowedTime[client] = false; g_bHumansAllowedTime[client] = false;
resetClientVectors(client); g_bhumans_finished[client] = false;
player_stage[client] = 0; resetClientVectors(client);
Format(g_csTime_record[client], sizeof(g_csTime_record[]), "0.000"); player_stage[client] = 0;
} Format(g_csTime_record[client], sizeof(g_csTime_record[]), "0.000");
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2]) public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype, int cmdnum, int tickcount, int seed, const int mouse[2])
{ {
if (!IsValidClient(client)) if (!IsValidClient(client) || !g_bHumansAllowedTime[client])
return; return;
//checks if event is going on
if (g_bEventBool) if (g_bEventBool)
{ {
g_bHumansAllowedTime[client] = false; g_bHumansAllowedTime[client] = false;
return; return;
} }
if (g_bHumansAllowedTime[client] && (GetClientTeam(client) == CS_TEAM_CT) && IsPlayerAlive(client)) if (GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client))
{ {
int frameCap = 11; int frameCap = 11;
if (g_iClientFrames[client] >= frameCap) if (g_bhumans_finished[client])
{ g_iClientFrames[client] = 11;
g_iClientFrames[client] = 0; if (g_iClientFrames[client] >= frameCap)
float clientVectors[3]; {
GetClientAbsOrigin(client, clientVectors); g_iClientFrames[client] = 0;
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client)) float clientVectors[3];
{ GetClientAbsOrigin(client, clientVectors);
g_bHumansAllowedTime[client] = false; if (checkClientOrigin(g_fClientVectors[client], clientVectors, client))
resetClientVectors(client); {
PrintToChat(client, "Disabled timer due to potential teleport abuse"); g_bHumansAllowedTime[client] = false;
return; g_bhumans_finished[client] = false;
} resetClientVectors(client);
int speedCheckerCap = 10; PrintToChat(client, "Disabled timer due to potential teleport abuse");
if (g_iClientSpeedInterval[client] > speedCheckerCap) return;
{ }
g_iClientSpeedInterval[client] = 0; if (g_bhumans_finished[client])
bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP); {
if (bNoclip) g_bhumans_finished[client] = false;
{ g_bHumansAllowedTime[client] = false;
g_bHumansAllowedTime[client] = false; FinishedStageRaceZone(client);
resetClientVectors(client); return;
PrintToChat(client, "Disabled timer due to Noclip"); }
return; int speedCheckerCap = 10;
} if (g_iClientSpeedInterval[client] > speedCheckerCap)
float speed = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue"); {
if (speed > 1.0) g_iClientSpeedInterval[client] = 0;
{ bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP);
if (StrContains(g_cMapname, "surf", false) == -1) if (bNoclip)
{ {
g_bHumansAllowedTime[client] = false; g_bHumansAllowedTime[client] = false;
resetClientVectors(client); g_bhumans_finished[client] = false;
PrintToChat(client, "Disabled timer due to modified run speed"); resetClientVectors(client);
return; PrintToChat(client, "Disabled timer due to Noclip");
} return;
} }
float client_gravity = GetEntityGravity(client); float speed = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
ConVar gravity = FindConVar("sv_gravity"); if (speed > 1.0)
float gravityFloat = gravity.FloatValue; {
int minimalPermitedGravity = 610; if (StrContains(g_cMapname, "surf", false) == -1)
//PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat); {
if (((client_gravity > 1.3 || client_gravity < 0.6000) && client_gravity != 0.000000) || gravityFloat < minimalPermitedGravity) g_bHumansAllowedTime[client] = false;
{ g_bhumans_finished[client] = false;
//PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat); resetClientVectors(client);
g_bHumansAllowedTime[client] = false; PrintToChat(client, "Disabled timer due to modified run speed");
resetClientVectors(client); return;
PrintToChat(client, "Disabled timer due to modified gravity"); }
return; }
} float client_gravity = GetEntityGravity(client);
} ConVar gravity = FindConVar("sv_gravity");
g_fClientVectors[client] = clientVectors; float gravityFloat = gravity.FloatValue;
if (hText != INVALID_HANDLE && !g_bHideTimer[client]) int minimalPermitedGravity = 610;
{ //PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat);
SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85); if (((client_gravity > 1.3 || client_gravity < 0.6000) && client_gravity != 0.000000) || gravityFloat < minimalPermitedGravity)
float total_time = client_current_race_time(client); {
char sTime[32]; //PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat);
FormatPlayerTime(total_time, sTime, sizeof(sTime), false, 1); g_bHumansAllowedTime[client] = false;
ShowSyncHudText(client, hText, "%N Time: %s\nRecord: %s\nMap: %s\nCourse: %i", client, sTime, g_csTime_record[client], g_cMapname, player_stage[client]); g_bhumans_finished[client] = false;
} resetClientVectors(client);
g_iClientSpeedInterval[client]++; PrintToChat(client, "Disabled timer due to modified gravity");
} return;
g_iClientFrames[client]++; }
} }
g_fClientVectors[client] = clientVectors;
if (hText != INVALID_HANDLE && !g_bHideTimer[client])
{
SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85);
float total_time = client_current_race_time(client);
char sTime[32];
FormatPlayerTime(total_time, sTime, sizeof(sTime), false, 1);
ShowSyncHudText(client, hText, "%N Time: %s\nRecord: %s\nMap: %s\nCourse: %i", client, sTime, g_csTime_record[client], g_cMapname, player_stage[client]);
}
g_iClientSpeedInterval[client]++;
}
g_iClientFrames[client]++;
}
return; return;
} }
@ -446,21 +463,23 @@ public bool checkClientOrigin(float oldVals[3], float newVals[3], int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void unloze_zoneEntry(int client, char[] zone) public void unloze_zoneEntry(int client, char[] zone)
{ {
int zoneIndex = RetrieveZoneIndex(zone); int zoneIndex = RetrieveZoneIndex(zone);
int l_iZoneCount = unloze_zoneCount(); int l_iZoneCount = unloze_zoneCount();
if (((GetClientTeam(client) == CS_TEAM_CT && g_bHumansAllowedTime[client]) && StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd))
{ if (GetClientTeam(client) == CS_TEAM_CT && g_bHumansAllowedTime[client])
if (IsClientAuthorized(client)) {
{ if ((StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd))
if (l_iZoneCount < 2) {
player_stage[client] = 0; g_bHumansAllowedTime[client] = false;
if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2) if (l_iZoneCount < 2)
FinishedStageRaceZone(client); player_stage[client] = 0;
} if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2)
else {
PrintToChat(client, "You are not authorized with steam!!"); g_bHumansAllowedTime[client] = true;
g_bHumansAllowedTime[client] = false; g_bhumans_finished[client] = true;
} }
}
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -469,18 +488,21 @@ public void unloze_zoneLeave(int client, char[] zone)
{ {
//only maps with multiple zones need ZONE_PREFIX_START //only maps with multiple zones need ZONE_PREFIX_START
int l_iZoneCount = unloze_zoneCount(); int l_iZoneCount = unloze_zoneCount();
if (((GetClientTeam(client) == CS_TEAM_CT) && StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart)) if (GetClientTeam(client) == CS_TEAM_CT)
{ {
if (!l_iZoneCount) if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart))
return; {
resetClientVectors(client); if (!l_iZoneCount)
g_fStartTime[client] = GetEngineTime(); return;
float notRounded = float(RetrieveZoneIndex(zone)); resetClientVectors(client);
player_stage[client] = RoundToCeil(notRounded / 2); g_fStartTime[client] = GetEngineTime();
mysql_get_player_time(client, player_stage[client]); float notRounded = float(RetrieveZoneIndex(zone));
g_bHumansAllowedTime[client] = true; player_stage[client] = RoundToCeil(notRounded / 2);
CPrintToChat(client, "Timer started for Course: %i", player_stage[client]); mysql_get_player_time(client, player_stage[client]);
} g_bHumansAllowedTime[client] = true;
CPrintToChat(client, "Timer started for Course: %i", player_stage[client]);
}
}
} }
stock void FormatPlayerTime(float Time, char[] result, int maxlength, bool showDash, int precision) stock void FormatPlayerTime(float Time, char[] result, int maxlength, bool showDash, int precision)