Skip to content

Commit

Permalink
Fix for map broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
Vretu-Dev committed Dec 29, 2024
1 parent aeb98ea commit 81f95ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
38 changes: 29 additions & 9 deletions UsefulHints/EventHandlers/Modules/Maps.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,52 @@
using Exiled.API.Features;
using Exiled.Events.EventArgs.Server;
using MEC;
using System.Collections.Generic;

namespace UsefulHints.EventHandlers.Modules
{
public static class Maps
{
private static CoroutineHandle broadcastCoroutine;

public static void RegisterEvents()
{
Exiled.Events.Handlers.Server.RoundStarted += OnRoundStarted;
Exiled.Events.Handlers.Server.WaitingForPlayers += OnWaitingForPlayers;
}

public static void UnregisterEvents()
{
Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStarted;
Exiled.Events.Handlers.Server.WaitingForPlayers -= OnWaitingForPlayers;
}

private static void OnRoundStarted()
{
Timing.CallDelayed(445f, () =>
{
string message = UsefulHints.Instance.Config.BroadcastWarningLcz;
broadcastCoroutine = Timing.RunCoroutine(DelayedBroadcastCoroutine());
}

foreach (var player in Player.List)
private static void OnWaitingForPlayers()
{
Timing.KillCoroutines(broadcastCoroutine);
}

private static IEnumerator<float> DelayedBroadcastCoroutine()
{
yield return Timing.WaitForSeconds(445f);

if (Round.IsEnded)
yield break;

string message = UsefulHints.Instance.Config.BroadcastWarningLcz;

foreach (var player in Player.List)
{
if (player.IsAlive)
{
if (player.IsAlive)
{
player.Broadcast(7, message);
}
player.Broadcast(7, message);
}
});
}
}
}
}
2 changes: 1 addition & 1 deletion UsefulHints/UsefulHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class UsefulHints : Plugin<Config>
public override string Name => "Useful Hints";
public override string Author => "Vretu";
public override string Prefix { get; } = "UH";
public override Version Version => new Version(1, 9, 3);
public override Version Version => new Version(1, 9, 4);
public override Version RequiredExiledVersion { get; } = new Version(9, 0, 0);
public override PluginPriority Priority { get; } = PluginPriority.Low;
public static UsefulHints Instance { get; private set; }
Expand Down

0 comments on commit 81f95ac

Please sign in to comment.