From d0f3a93a2ecc45195e83d037a1fdd59ed2c60c94 Mon Sep 17 00:00:00 2001 From: Jon-Mailes Graeffe Date: Thu, 7 Nov 2024 15:42:04 +0100 Subject: [PATCH] fixed menu opening on bomb plant after round end --- LuckyDefusePlugin.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/LuckyDefusePlugin.cs b/LuckyDefusePlugin.cs index f2870ae..c3de4cc 100644 --- a/LuckyDefusePlugin.cs +++ b/LuckyDefusePlugin.cs @@ -3,6 +3,7 @@ using System.Text.Json.Serialization; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Capabilities; using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Timers; using CounterStrikeSharp.API.Modules.Utils; @@ -39,7 +40,8 @@ public class LuckyDefusePlugin : BasePlugin, IPluginConfig private readonly WireMenu _planterMenu; private readonly WireMenu _defuserMenu; private int _wire; - private bool _wireChosenManually = false; + private bool _wireChosenManually; + private bool _roundEnded; public LuckyDefusePlugin() { @@ -61,10 +63,17 @@ public void OnConfigParsed(PluginConfig? config) public override void Load(bool hotReload) { + RegisterEventHandler((_, _) => + { + _roundEnded = false; + return HookResult.Continue; + }); + RegisterEventHandler((_, _) => { _planter = null; _wireChosenManually = false; + _roundEnded = true; _defuserMenu.Close(); _planterMenu.Close(); return HookResult.Continue; @@ -72,7 +81,7 @@ public override void Load(bool hotReload) RegisterEventHandler((@event, _) => { - if (@event.Userid == null) return HookResult.Continue; + if (_roundEnded || @event.Userid == null) return HookResult.Continue; _wire = Random.Shared.Next(_colors.Length - 1); _planter = @event.Userid; _planterMenu.Open(@event.Userid);