Skip to content

Commit

Permalink
fix: disable teambalancer during halftime
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalle Minkner committed Nov 9, 2024
1 parent 10515c2 commit 175afd7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/TeamBalancer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ public partial class TeamBalancer : BasePlugin
public override string ModuleAuthor => "Jon-Mailes Graeffe <[email protected]> / Kalle <[email protected]>";
public override string ModuleVersion => "0.0.4";

private bool _enabled = true;

public override void Load(bool hotReload)
{
// initialize configuration
LoadConfig();
SaveConfig();
// create listeners
RegisterEventHandler<EventPlayerTeam>(OnPlayerTeam);
RegisterEventHandler<EventStartHalftime>(OnStartHalftime);
// print message if hot reload
if (hotReload)
{
Expand All @@ -30,6 +33,7 @@ public override void Unload(bool hotReload)

public HookResult OnPlayerTeam(EventPlayerTeam @event, GameEventInfo info)
{
if (!_enabled) return HookResult.Continue;
var player = @event.Userid;
if (player == null
|| !player.IsValid
Expand Down Expand Up @@ -91,6 +95,13 @@ public HookResult OnPlayerTeam(EventPlayerTeam @event, GameEventInfo info)
return HookResult.Continue;
}


public HookResult OnStartHalftime(EventStartHalftime @event, GameEventInfo info)
{
_enabled = false;
AddTimer(5f, ()=>{
_enabled = true;
});
return HookResult.Continue;
}
}
}

0 comments on commit 175afd7

Please sign in to comment.