-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventHandler.cs
More file actions
40 lines (32 loc) · 1.08 KB
/
EventHandler.cs
File metadata and controls
40 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections.Generic;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Player;
using PlayerRoles;
namespace Scp3114SpawnControl
{
public class EventHandler
{
private const RoleTypeId scp3114Role = RoleTypeId.Scp3114;
private readonly Dictionary<Player, bool> spectatableCache = new(2);
public void OnWaitingforPlayers()
{
spectatableCache.Clear();
}
public void OnSpawned(SpawnedEventArgs ev)
{
if (!Plugin.Instance.Config.Make3114UnSpectatable)
return;
if (ev.OldRole.Type == scp3114Role && ev.Player.Role.Type != scp3114Role && spectatableCache.TryGetValue(ev.Player, out bool previous))
{
ev.Player.IsSpectatable = previous;
spectatableCache.Remove(ev.Player);
return;
}
if (ev.Player.Role.Type == scp3114Role)
{
spectatableCache[ev.Player] = ev.Player.IsSpectatable;
ev.Player.IsSpectatable = false;
}
}
}
}