From 9d5fc03e64323c3e8818a20c4e5bc6d06b992d19 Mon Sep 17 00:00:00 2001 From: jithatsonei Date: Wed, 27 Mar 2024 01:44:37 +0000 Subject: [PATCH] add real player checking, add warden passed sound --- .../Commands/WardenCommandsBehavior.cs | 10 +++++++++- mod/Jailbreak.Warden/Global/WardenBehavior.cs | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs index 64bc63ad..13401766 100644 --- a/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs @@ -17,10 +17,12 @@ public class WardenCommandsBehavior : IPluginBehavior private readonly IWardenNotifications _notifications; private readonly IWardenSelectionService _queue; private readonly IWardenService _warden; + private readonly WardenConfig _config; public WardenCommandsBehavior(IWardenSelectionService queue, IWardenService warden, - IWardenNotifications notifications) + IWardenNotifications notifications, WardenConfig config) { + _config = config; _queue = queue; _warden = warden; _notifications = notifications; @@ -46,6 +48,12 @@ public void Command_Pass(CCSPlayerController? player, CommandInfo command) .ToAllChat() .ToAllCenter(); + foreach (CCSPlayerController clients in Utilities.GetPlayers()) { + if (!clients.IsReal()) continue; + clients.ExecuteClientCommand( + $"play sounds/{_config.WardenPassedSoundName}"); + } + _notifications.BECOME_NEXT_WARDEN.ToAllChat(); if (!_warden.TryRemoveWarden()) diff --git a/mod/Jailbreak.Warden/Global/WardenBehavior.cs b/mod/Jailbreak.Warden/Global/WardenBehavior.cs index ffb66c14..cae80afb 100644 --- a/mod/Jailbreak.Warden/Global/WardenBehavior.cs +++ b/mod/Jailbreak.Warden/Global/WardenBehavior.cs @@ -27,7 +27,7 @@ public class WardenBehavior : IPluginBehavior, IWardenService private BasePlugin _parent; private Timer? _unblueTimer; - private WardenConfig _config; + private readonly WardenConfig _config; private bool _hasWarden; private CCSPlayerController? _warden; @@ -86,6 +86,7 @@ public bool TrySetWarden(CCSPlayerController controller) .ToAllCenter(); foreach (CCSPlayerController player in Utilities.GetPlayers()) { + if (!player.IsReal()) continue; player.ExecuteClientCommand( $"play sounds/{_config.WardenNewSoundName}"); } @@ -149,6 +150,7 @@ private void ProcessWardenDeath() .ToAllCenter(); foreach (CCSPlayerController player in Utilities.GetPlayers()) { + if (!player.IsReal()) continue; player.ExecuteClientCommand( $"play sounds/{_config.WardenKilledSoundName}"); } @@ -229,6 +231,7 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect ev, GameEventInfo inf .ToAllCenter(); foreach (CCSPlayerController player in Utilities.GetPlayers()) { + if (!player.IsReal()) continue; player.ExecuteClientCommand( $"play sounds/{_config.WardenPassedSoundName}"); }