11using Exiled . API . Features ;
2+ using Exiled . Events . EventArgs . Server ;
23using MEC ;
4+ using System . Collections . Generic ;
35
46namespace 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}
0 commit comments