Skip to content

Commit 81f95ac

Browse files
committed
Fix for map broadcast
1 parent aeb98ea commit 81f95ac

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed
Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
11
using Exiled.API.Features;
2+
using Exiled.Events.EventArgs.Server;
23
using MEC;
4+
using System.Collections.Generic;
35

46
namespace UsefulHints.EventHandlers.Modules
57
{
68
public static class Maps
79
{
10+
private static CoroutineHandle broadcastCoroutine;
11+
812
public static void RegisterEvents()
913
{
1014
Exiled.Events.Handlers.Server.RoundStarted += OnRoundStarted;
15+
Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaitingForPlayers;
1116
}
17+
1218
public static void UnregisterEvents()
1319
{
1420
Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStarted;
21+
Exiled.Events.Handlers.Server.WaitingForPlayers -= OnWaitingForPlayers;
1522
}
23+
1624
private static void OnRoundStarted()
1725
{
18-
Timing.CallDelayed(445f, () =>
19-
{
20-
string message = UsefulHints.Instance.Config.BroadcastWarningLcz;
26+
broadcastCoroutine = Timing.RunCoroutine(DelayedBroadcastCoroutine());
27+
}
2128

22-
foreach (var player in Player.List)
29+
private static void OnWaitingForPlayers()
30+
{
31+
Timing.KillCoroutines(broadcastCoroutine);
32+
}
33+
34+
private static IEnumerator<float> DelayedBroadcastCoroutine()
35+
{
36+
yield return Timing.WaitForSeconds(445f);
37+
38+
if (Round.IsEnded)
39+
yield break;
40+
41+
string message = UsefulHints.Instance.Config.BroadcastWarningLcz;
42+
43+
foreach (var player in Player.List)
44+
{
45+
if (player.IsAlive)
2346
{
24-
if (player.IsAlive)
25-
{
26-
player.Broadcast(7, message);
27-
}
47+
player.Broadcast(7, message);
2848
}
29-
});
49+
}
3050
}
3151
}
3252
}

UsefulHints/UsefulHints.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class UsefulHints : Plugin<Config>
99
public override string Name => "Useful Hints";
1010
public override string Author => "Vretu";
1111
public override string Prefix { get; } = "UH";
12-
public override Version Version => new Version(1, 9, 3);
12+
public override Version Version => new Version(1, 9, 4);
1313
public override Version RequiredExiledVersion { get; } = new Version(9, 0, 0);
1414
public override PluginPriority Priority { get; } = PluginPriority.Low;
1515
public static UsefulHints Instance { get; private set; }

0 commit comments

Comments
 (0)