-
Notifications
You must be signed in to change notification settings - Fork 0
/
DotAccept.cs
57 lines (47 loc) · 1.58 KB
/
DotAccept.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
51
52
53
54
55
56
57
using CommandSystem;
using Exiled.API.Features;
using System;
using System.Collections.Generic;
namespace SCPSwap
{
public class DotAccept : ICommand
{
Player SenderPlayer;
public string Command { get; } = "accept";
public static DotAccept Instance { get; } = new DotAccept();
/// <inheritdoc/>
public string[] Aliases { get; } = new string[] { "yes" };
/// <inheritdoc/>
public string Description { get; } = "Swaps SCPs.";
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
CommandSender cmd_sender = (CommandSender)sender;
SenderPlayer = Player.Get(cmd_sender.SenderId);
if (!Globals.allowed)
{
response = "Too late for changing SCP";
return false;
}
try
{
RoleType old_role = Globals.Requests[SenderPlayer].Role;
Globals.Requests[SenderPlayer].SetRole(SenderPlayer.Role);
SenderPlayer.SetRole(old_role);
response = "Changing roles...";
return true;
}
catch (Exception ex)
{
if (ex is KeyNotFoundException || ex is ArgumentNullException)
{
response = "No request is being sent at this moment to you";
return false;
}
else
{
throw;
}
}
}
}
}