commit 4706b08c0b2686fad1ce5e805c4d43bc1c5341dd Author: upstream Date: Fri Sep 4 08:36:19 2026 +0200 Upstream Vretu-Dev/UsefulHints state of the touched files before 72056adbdf diff --git a/UsefulHints/EventHandlers/Modules/FFWarning.cs b/UsefulHints/EventHandlers/Modules/FFWarning.cs new file mode 100644 index 0000000..8145e51 --- /dev/null +++ b/UsefulHints/EventHandlers/Modules/FFWarning.cs @@ -0,0 +1,50 @@ +using Exiled.Events.EventArgs.Player; +using PlayerRoles; +using UsefulHints.Extensions; + +namespace UsefulHints.EventHandlers.Modules +{ + public static class FFWarning + { + private static Config Config => UsefulHints.Instance.Config; + + public static void RegisterEvents() + { + Exiled.Events.Handlers.Player.Hurting += OnHurting; + } + + public static void UnregisterEvents() + { + Exiled.Events.Handlers.Player.Hurting -= OnHurting; + } + + private static void OnHurting(HurtingEventArgs ev) + { + if (ev.Attacker == null || ev.Player == null || ev.Attacker.Role == null || ev.Player.Role == null || ev.Attacker.Role.Team == Team.SCPs || ev.Player.Role.Team == Team.SCPs || ev.Attacker == ev.Player) + return; + + if (!ServerSettings.ShouldShowFFWarning(ev.Player) || !ServerSettings.ShouldShowFFWarning(ev.Attacker)) + return; + + if (ev.Attacker.Role.Side == ev.Player.Role.Side) + { + if (ev.Attacker.Role.Team == Team.ClassD && ev.Player.Role.Team == Team.ClassD && Config.ClassDAreTeammates) + { + ev.Attacker.ShowHint(string.Format(Config.FriendlyFireWarning), 1); + ev.Player.ShowHint(string.Format(Config.DamageTakenWarning, ev.Attacker.Nickname), 2); + } + else + { + ev.Attacker.ShowHint(string.Format(Config.FriendlyFireWarning), 1); + ev.Player.ShowHint(string.Format(Config.DamageTakenWarning, ev.Attacker.Nickname), 2); + } + } + + if (Config.EnableCuffedWarning && ev.Player.IsCuffed) + { + ev.Attacker.ShowHint(string.Format(Config.CuffedAttackerWarning), 2); + ev.Player.ShowHint(string.Format(Config.CuffedPlayerWarning, ev.Attacker.Nickname), 2); + } + } + } +} \ No newline at end of file