diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 0a64a61..cbe416e 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -337,6 +337,10 @@ zr_infect_consecutive_block "1" // Default: "1" zr_infect_weapons_drop "1" +// The maximum allowed distance between a client and an attacker for a successful infection. [0.0 = Disabled] +// Default: "80.0" +zr_infect_max_distance "80.0" + // Effects // Disabling this will disable the fireball, smoke cloud, and sparks in a more efficient way. diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 4939f51..7916593 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -109,6 +109,7 @@ enum CvarsList Handle:CVAR_INFECT_MZOMBIE_MAX, Handle:CVAR_INFECT_MZOMBIE_COUNTDOWN, Handle:CVAR_INFECT_MZOMBIE_RESPAWN, + Handle:CVAR_INFECT_MAX_DISTANCE, Handle:CVAR_INFECT_EXPLOSION, Handle:CVAR_INFECT_FIREBALL, Handle:CVAR_INFECT_SMOKE, @@ -327,6 +328,7 @@ CvarsCreate() g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "Maximum time from the start of the round until picking the mother zombie(s)."); g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "Prevent a player from being chosen as mother zombie two rounds in a row."); g_hCvarsList[CVAR_INFECT_WEAPONS_DROP] = CreateConVar("zr_infect_weapons_drop", "1", "Force player to drop all weapons on infect, disabling this will strip weapons instead."); + g_hCvarsList[CVAR_INFECT_MAX_DISTANCE] = CreateConVar("zr_infect_max_distance", "80.0", "The maximum allowed distance between a client and an attacker for a successful infection. [0.0 = Disabled]"); // Effects g_hCvarsList[CVAR_INFECT_EXPLOSION] = CreateConVar("zr_infect_explosion", "1", "Disabling this will disable the fireball, smoke cloud, and sparks in a more efficient way."); diff --git a/src/zr/damage.inc b/src/zr/damage.inc index 9034aa6..dddba44 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -340,6 +340,25 @@ public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:dama return immunityAction; } + // Check if distance between clients is too high. (Anti lagcompensation / longknife) + new Float:maxDistance = GetConVarFloat(g_hCvarsList[CVAR_INFECT_MAX_DISTANCE]); + if (maxDistance != 0.0) + { + new Float:clientPosition[3]; + new Float:attackerPosition[3]; + + GetClientAbsOrigin(client, clientPosition); + GetClientAbsOrigin(attacker, attackerPosition); + + new Float:distance = GetVectorDistance(clientPosition, attackerPosition); + + // Block infection if distance is higher than allowed. + if (distance > maxDistance) + { + return Plugin_Handled; + } + } + // Client is about to be infected, re-add HP so they aren't killed by // knife. But only do this when immunity mode is disabled. if (ClassGetImmunityMode(client) == Immunity_None)