-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable teambalancer during halftime
- Loading branch information
Kalle Minkner
committed
Nov 9, 2024
1 parent
10515c2
commit 175afd7
Showing
1 changed file
with
12 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
{ | ||
|
@@ -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 | ||
|
@@ -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; | ||
} | ||
} | ||
} |