Skip to content

Commit

Permalink
fixed menu opening on bomb plant after round end
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgraeffe committed Nov 7, 2024
1 parent 211d9e7 commit d0f3a93
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions LuckyDefusePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,7 +40,8 @@ public class LuckyDefusePlugin : BasePlugin, IPluginConfig<PluginConfig>
private readonly WireMenu _planterMenu;
private readonly WireMenu _defuserMenu;
private int _wire;
private bool _wireChosenManually = false;
private bool _wireChosenManually;
private bool _roundEnded;

public LuckyDefusePlugin()
{
Expand All @@ -61,18 +63,25 @@ public void OnConfigParsed(PluginConfig? config)

public override void Load(bool hotReload)
{
RegisterEventHandler<EventRoundStart>((_, _) =>
{
_roundEnded = false;
return HookResult.Continue;
});

RegisterEventHandler<EventRoundEnd>((_, _) =>
{
_planter = null;
_wireChosenManually = false;
_roundEnded = true;
_defuserMenu.Close();
_planterMenu.Close();
return HookResult.Continue;
});

RegisterEventHandler<EventBombPlanted>((@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);
Expand Down

0 comments on commit d0f3a93

Please sign in to comment.