1717using ProjectMER . Features . Objects ;
1818#endif
1919
20-
20+ using MapEvent = Exiled . Events . Handlers . Map ;
2121using PlayerEvent = Exiled . Events . Handlers . Player ;
2222using ServerEvent = Exiled . Events . Handlers . Server ;
2323
2424using static ProjectSCRAMBLE . Methods ;
2525using static ProjectSCRAMBLE . ProjectSCRAMBLE ;
26+ using Exiled . Events . EventArgs . Map ;
2627
2728namespace ProjectSCRAMBLE
2829{
2930 public class EventHandlers
3031 {
3132 public HashSet < Player > DirtyPlayers { get ; set ; } = [ ] ;
33+ public HashSet < ushort > DirtyPickupSerials { get ; set ; } = [ ] ;
3234
3335 public void Subscribe ( )
3436 {
@@ -37,6 +39,9 @@ public void Subscribe()
3739 PlayerEvent . Verified += OnVerified ;
3840 PlayerEvent . Spawned += OnChangedRole ;
3941 PlayerEvent . ChangingSpectatedPlayer += OnChangingSpectatedPlayer ;
42+
43+ MapEvent . PickupAdded += OnPickupAdded ;
44+ MapEvent . PickupDestroyed += OnPickupDestroyed ;
4045 }
4146
4247 public void Unsubscribe ( )
@@ -46,12 +51,16 @@ public void Unsubscribe()
4651 PlayerEvent . Verified -= OnVerified ;
4752 PlayerEvent . Spawned -= OnChangedRole ;
4853 PlayerEvent . ChangingSpectatedPlayer -= OnChangingSpectatedPlayer ;
54+
55+ MapEvent . PickupAdded -= OnPickupAdded ;
56+ MapEvent . PickupDestroyed -= OnPickupDestroyed ;
4957 }
5058
5159 private void OnWaitingforPlayers ( )
5260 {
5361 DirtyPlayers . Clear ( ) ;
5462 Scp96Censors . Clear ( ) ;
63+ DirtyPickupSerials . Clear ( ) ;
5564
5665 foreach ( HashSet < CoroutineHandle > handles in Coroutines . Values )
5766 {
@@ -109,5 +118,22 @@ private void OnChangingSpectatedPlayer(ChangingSpectatedPlayerEventArgs ev)
109118 DirtyPlayers . Add ( ev . Player ) ;
110119 }
111120 }
121+
122+ private void OnPickupAdded ( PickupAddedEventArgs ev )
123+ {
124+ if ( ! SCRAMBLE . Check ( ev . Pickup ) )
125+ return ;
126+
127+ if ( DirtyPickupSerials . Contains ( ev . Pickup . Serial ) )
128+ ev . Pickup . Destroy ( ) ;
129+
130+ DirtyPickupSerials . Add ( ev . Pickup . Serial ) ;
131+ }
132+
133+ private void OnPickupDestroyed ( PickupDestroyedEventArgs ev )
134+ {
135+ if ( DirtyPickupSerials . Contains ( ev . Pickup . Serial ) )
136+ DirtyPickupSerials . Remove ( ev . Pickup . Serial ) ;
137+ }
112138 }
113139}
0 commit comments