From 3943af229d42e030e3d2be1b587ce49c716b6942 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sat, 3 Aug 2024 22:50:49 -0500 Subject: [PATCH] fix --- Modules/AntiCheat.cs | 13 +++++++++++-- Modules/BetterHostManager.cs | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 9aecb9f..d520d55 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -234,14 +234,23 @@ class AntiCheat if (callId is (byte)RpcCalls.MurderPlayer) { + bool condition = false; + + if (ExtendedPlayerInfo.TimeSinceKill.TryGetValue(player, out var value)) + { + if (value < GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown) + { + condition = true; + } + } + if (reader.BytesRemaining > 0) { PlayerControl target = reader.ReadNetObject(); if (target != null) { - if (!player.IsImpostorTeam() || !player.IsAlive() || player.IsInVanish() || !target.IsAlive() || target.IsImpostorTeam() - || ExtendedPlayerInfo.TimeSinceKill.TryGetValue(player, out var value) && value < (float)GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown) + if (!player.IsImpostorTeam() || !player.IsAlive() || player.IsInVanish() || !target.IsAlive() || target.IsImpostorTeam() || condition) { BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}"); } diff --git a/Modules/BetterHostManager.cs b/Modules/BetterHostManager.cs index f85e797..07cbbaf 100644 --- a/Modules/BetterHostManager.cs +++ b/Modules/BetterHostManager.cs @@ -65,7 +65,7 @@ class BetterHostManager public static bool CheckRPCAsHost(PlayerControl player, byte callId, MessageReader reader, ref bool canceled) { - if (player == null) return true; + if (player == null || !GameStates.IsHost) return true; bool shouldReturn = false; @@ -97,6 +97,16 @@ class BetterHostManager { PlayerControl target = reader.ReadNetObject(); + bool condition = false; + + if (ExtendedPlayerInfo.TimeSinceKill.TryGetValue(player, out var value)) + { + if (value >= GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown) + { + condition = true; + } + } + if (target != null) { if (player.IsAlive() @@ -107,7 +117,7 @@ class BetterHostManager && !player.shapeshifting && !player.onLadder && !player.MyPhysics.Animations.IsPlayingAnyLadderAnimation() - && ExtendedPlayerInfo.TimeSinceKill.TryGetValue(player, out var value) && value >= (float)GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown + && condition && CheckRange(player.GetCustomPosition(), target.GetCustomPosition(), 3f)) { if (target.IsAlive()