Skip to content

Commit

Permalink
Close menu on bomb explosion and defuse. Don't open menu for bots
Browse files Browse the repository at this point in the history
  • Loading branch information
Interesting-exe committed Jun 11, 2024
1 parent 8ecf99d commit 7005a2c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions QuickDefuse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,42 @@ namespace QuickDefuse;
public class QuickDefuse : BasePlugin
{
public override string ModuleName => "QuickDefuse";
public override string ModuleVersion => "1.0.2";
public override string ModuleVersion => "1.0.3";
public override string ModuleAuthor => "Interesting";

public int Wire;
public string[] Colors = { "Red", "Blue", "Green", "Yellow"};
public char[] ChatColorsArray = { ChatColors.Red, ChatColors.Blue, ChatColors.Green, ChatColors.Yellow };
public static IWasdMenuManager? MenuManager;
public static CCSPlayerController? Defuser;

public override void Load(bool hotReload)
{
RegisterEventHandler<EventBombBegindefuse>(OnBombBeginDefuse);
RegisterEventHandler<EventBombAbortdefuse>((@event, info) =>
{
Defuser = null;
var menuManager = GetMenuManager();
menuManager?.CloseMenu(@event.Userid);
return HookResult.Continue;
});
RegisterEventHandler<EventBombDefused>((@event, info) =>
{
Defuser = null;
var menuManager = GetMenuManager();
menuManager?.CloseMenu(@event.Userid);
return HookResult.Continue;
});
RegisterEventHandler<EventBombExploded>((@event, info) =>
{
if (Defuser != null)
{
var menuManager = GetMenuManager();
menuManager?.CloseMenu(Defuser);
Defuser = null;
}
return HookResult.Continue;
});
}

public IWasdMenuManager? GetMenuManager()
Expand Down Expand Up @@ -69,8 +88,9 @@ public override void Load(bool hotReload)

public HookResult OnBombBeginDefuse(EventBombBegindefuse @event, GameEventInfo info)
{
if (@event.Userid == null)
if (@event.Userid == null || @event.Userid.IsBot)
return HookResult.Continue;
Defuser = @event.Userid;
Wire = new Random().Next(0, Int32.MaxValue) % Colors.Length;
GetMenuManager()?.OpenMainMenu(@event.Userid, CreateMenu());
return HookResult.Continue;
Expand Down

0 comments on commit 7005a2c

Please sign in to comment.