-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventHandlers.cs
50 lines (43 loc) · 1.67 KB
/
EventHandlers.cs
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
41
42
43
44
45
46
47
48
49
50
using CommandSystem;
using Exiled.API.Features;
using PlayerRoles;
using System;
using System.Linq;
namespace ScpList
{
[CommandHandler(typeof(ClientCommandHandler))]
public class SCPListCommand : ICommand
{
public string Command => "scplist";
public string[] Aliases => new string[] { };
public string Description => "shows a list of SCPs";
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (sender is CommandSender commandSender && Player.Get(commandSender) is Player player)
{
var scpPlayers = Player.List.Where(p => IsSCPRole(p.Role.Type));
if (!scpPlayers.Any())
{
response = "no SCPs are currently in the game.";
return false;
}
string message = "<color=#4fa831>List of SCPs:</color>\n";
foreach (var scpPlayer in scpPlayers)
{
message += $"<color=#bdb253>{scpPlayer.Role.Type}</color>";
}
response = message;
return true;
}
response = "this command can only be used by PLAYERS";
return false;
}
private bool IsSCPRole(RoleTypeId role)
{
return role == RoleTypeId.Scp049 || role == RoleTypeId.Scp0492 ||
role == RoleTypeId.Scp079 || role == RoleTypeId.Scp096 ||
role == RoleTypeId.Scp106 || role == RoleTypeId.Scp173 ||
role == RoleTypeId.Scp939;
}
}
}