diff --git a/RaceTimer/scripting/unloze_racetimer_redux.sp b/RaceTimer/scripting/unloze_racetimer_redux.sp index 601a11b2..bb705e0e 100644 --- a/RaceTimer/scripting/unloze_racetimer_redux.sp +++ b/RaceTimer/scripting/unloze_racetimer_redux.sp @@ -1,7 +1,7 @@ #pragma semicolon 1 #define DEBUG #define PLUGIN_AUTHOR "jenz" -#define PLUGIN_VERSION "1.6" +#define PLUGIN_VERSION "1.7" #define g_dLength 400 #define g_dIndex 65 #include @@ -27,6 +27,7 @@ int g_iClientSpeedInterval[MAXPLAYERS + 1]; int g_iClientChecking[MAXPLAYERS + 1]; bool g_bDisplaySpecial; bool g_bHumansAllowedTime[MAXPLAYERS + 1]; +bool g_bhumans_finished[MAXPLAYERS + 1]; bool g_bHideTimer[MAXPLAYERS + 1]; bool g_bEventBool = false; 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) { - 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) { @@ -83,7 +84,7 @@ public void trigger_teleport(const char[] output, int entity_index, int client, resetClientVectors(client); 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) { - if (IsValidEdict(entity_index) && origin_command_check(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client]) - { - if (StrContains(g_cMapname, "surf", false) == -1) - { - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - PrintToChat(client, "Disabled timer due to potential teleport abuse, if this is wrong annoy jenz on discord"); - } - } + if (IsValidEdict(entity_index) && origin_command_check(entity_index) && IsValidClient(client) && g_bHumansAllowedTime[client]) + { + if (StrContains(g_cMapname, "surf", false) == -1) + { + g_bHumansAllowedTime[client] = false; + resetClientVectors(client); + 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++) if (IsValidClient(i) && !IsFakeClient(i)) { - resetClientVectors(i); - if (l_iZoneCount != 1) - g_bHumansAllowedTime[i] = false; - else - { - mysql_get_player_time(i, 0); - g_bHumansAllowedTime[i] = true; - g_fStartTime[i] = GetEngineTime(); - } - } + g_bhumans_finished[i] = false; + resetClientVectors(i); + if (l_iZoneCount != 1) + g_bHumansAllowedTime[i] = false; + else + { + mysql_get_player_time(i, 0); + g_bHumansAllowedTime[i] = true; + g_fStartTime[i] = GetEngineTime(); + } + } } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -309,92 +311,107 @@ public void OnClientDisconnect(int client) //---------------------------------------------------------------------------------------------------- public void resetClient(int client) { - if (0 < client <= MaxClients) - { - g_iClientChecking[client] = 0; - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - player_stage[client] = 0; - Format(g_csTime_record[client], sizeof(g_csTime_record[]), "0.000"); - } + if (0 < client <= MaxClients) + { + g_iClientChecking[client] = 0; + g_bHumansAllowedTime[client] = false; + g_bhumans_finished[client] = false; + resetClientVectors(client); + player_stage[client] = 0; + Format(g_csTime_record[client], sizeof(g_csTime_record[]), "0.000"); + } } //---------------------------------------------------------------------------------------------------- // 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]) { - if (!IsValidClient(client)) + if (!IsValidClient(client) || !g_bHumansAllowedTime[client]) return; + //checks if event is going on if (g_bEventBool) { g_bHumansAllowedTime[client] = false; return; } - if (g_bHumansAllowedTime[client] && (GetClientTeam(client) == CS_TEAM_CT) && IsPlayerAlive(client)) - { - int frameCap = 11; - if (g_iClientFrames[client] >= frameCap) - { - g_iClientFrames[client] = 0; - float clientVectors[3]; - GetClientAbsOrigin(client, clientVectors); - if (checkClientOrigin(g_fClientVectors[client], clientVectors, client)) - { - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - PrintToChat(client, "Disabled timer due to potential teleport abuse"); - return; - } - int speedCheckerCap = 10; - if (g_iClientSpeedInterval[client] > speedCheckerCap) - { - g_iClientSpeedInterval[client] = 0; - bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP); - if (bNoclip) - { - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - PrintToChat(client, "Disabled timer due to Noclip"); - return; - } - float speed = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue"); - if (speed > 1.0) - { - if (StrContains(g_cMapname, "surf", false) == -1) - { - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - PrintToChat(client, "Disabled timer due to modified run speed"); - return; - } - } - float client_gravity = GetEntityGravity(client); - ConVar gravity = FindConVar("sv_gravity"); - float gravityFloat = gravity.FloatValue; - int minimalPermitedGravity = 610; - //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) - { - //PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat); - g_bHumansAllowedTime[client] = false; - resetClientVectors(client); - PrintToChat(client, "Disabled timer due to modified gravity"); - return; - } - } - 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]++; - } + if (GetClientTeam(client) == CS_TEAM_CT && IsPlayerAlive(client)) + { + int frameCap = 11; + if (g_bhumans_finished[client]) + g_iClientFrames[client] = 11; + if (g_iClientFrames[client] >= frameCap) + { + g_iClientFrames[client] = 0; + float clientVectors[3]; + GetClientAbsOrigin(client, clientVectors); + if (checkClientOrigin(g_fClientVectors[client], clientVectors, client)) + { + g_bHumansAllowedTime[client] = false; + g_bhumans_finished[client] = false; + resetClientVectors(client); + PrintToChat(client, "Disabled timer due to potential teleport abuse"); + return; + } + if (g_bhumans_finished[client]) + { + g_bhumans_finished[client] = false; + g_bHumansAllowedTime[client] = false; + FinishedStageRaceZone(client); + return; + } + int speedCheckerCap = 10; + if (g_iClientSpeedInterval[client] > speedCheckerCap) + { + g_iClientSpeedInterval[client] = 0; + bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP); + if (bNoclip) + { + g_bHumansAllowedTime[client] = false; + g_bhumans_finished[client] = false; + resetClientVectors(client); + PrintToChat(client, "Disabled timer due to Noclip"); + return; + } + float speed = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue"); + if (speed > 1.0) + { + if (StrContains(g_cMapname, "surf", false) == -1) + { + g_bHumansAllowedTime[client] = false; + g_bhumans_finished[client] = false; + resetClientVectors(client); + PrintToChat(client, "Disabled timer due to modified run speed"); + return; + } + } + float client_gravity = GetEntityGravity(client); + ConVar gravity = FindConVar("sv_gravity"); + float gravityFloat = gravity.FloatValue; + int minimalPermitedGravity = 610; + //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) + { + //PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat); + g_bHumansAllowedTime[client] = false; + g_bhumans_finished[client] = false; + resetClientVectors(client); + PrintToChat(client, "Disabled timer due to modified gravity"); + return; + } + } + 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; } @@ -446,21 +463,23 @@ public bool checkClientOrigin(float oldVals[3], float newVals[3], int client) //---------------------------------------------------------------------------------------------------- public void unloze_zoneEntry(int client, char[] zone) { - int zoneIndex = RetrieveZoneIndex(zone); - 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 (IsClientAuthorized(client)) - { - if (l_iZoneCount < 2) - player_stage[client] = 0; - if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2) - FinishedStageRaceZone(client); - } - else - PrintToChat(client, "You are not authorized with steam!!"); - g_bHumansAllowedTime[client] = false; - } + int zoneIndex = RetrieveZoneIndex(zone); + int l_iZoneCount = unloze_zoneCount(); + + if (GetClientTeam(client) == CS_TEAM_CT && g_bHumansAllowedTime[client]) + { + if ((StrContains(zone, "ZONE_PREFIX_RACE") > -1) || StrEqual(zone, g_cSpecialMapEnd)) + { + g_bHumansAllowedTime[client] = false; + if (l_iZoneCount < 2) + player_stage[client] = 0; + if (player_stage[client] == (zoneIndex / 2) || l_iZoneCount < 2) + { + g_bHumansAllowedTime[client] = true; + g_bhumans_finished[client] = true; + } + } + } } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -469,18 +488,21 @@ public void unloze_zoneLeave(int client, char[] zone) { //only maps with multiple zones need ZONE_PREFIX_START int l_iZoneCount = unloze_zoneCount(); - if (((GetClientTeam(client) == CS_TEAM_CT) && StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart)) - { - if (!l_iZoneCount) - return; - resetClientVectors(client); - g_fStartTime[client] = GetEngineTime(); - float notRounded = float(RetrieveZoneIndex(zone)); - player_stage[client] = RoundToCeil(notRounded / 2); - mysql_get_player_time(client, player_stage[client]); - g_bHumansAllowedTime[client] = true; - CPrintToChat(client, "Timer started for Course: %i", player_stage[client]); - } + if (GetClientTeam(client) == CS_TEAM_CT) + { + if ((StrContains(zone, "ZONE_PREFIX_START") > -1) || StrEqual(zone, g_cSpecialMapStart)) + { + if (!l_iZoneCount) + return; + resetClientVectors(client); + g_fStartTime[client] = GetEngineTime(); + float notRounded = float(RetrieveZoneIndex(zone)); + player_stage[client] = RoundToCeil(notRounded / 2); + 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)