-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommandPermit.cs
101 lines (95 loc) · 2.95 KB
/
CommandPermit.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Commands;
using Rocket.Unturned.Player;
using SDG.Unturned;
using Steamworks;
namespace ZaupWhitelist
{
public class CommandPermit : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Both;
}
}
public string Name
{
get
{
return "permit";
}
}
public string Help
{
get
{
return "Adds a person to the whitelist.";
}
}
public string Syntax
{
get
{
return "<steamid> <name>";
}
}
public List<string> Aliases
{
get { return new List<string>(); }
}
public List<string> Permissions
{
get { return new List<string>() { }; }
}
public void Execute(IRocketPlayer caller, string[] command)
{
bool console = (caller is ConsolePlayer);
UnturnedPlayer playerid = (UnturnedPlayer)caller;
string message = "";
if (command.Length != 2)
{
message = ZaupWhitelist.Instance.Translate("command_generic_invalid_parameter", new object[0]);
this.sendMessage(message, console, playerid);
return;
}
ulong pcsteamid;
if (!ulong.TryParse(command[0], out pcsteamid))
{
message = ZaupWhitelist.Instance.Translate("command_generic_invalid_steamid", new object[] {
command[0]
});
this.sendMessage(message, console, playerid);
return;
}
CSteamID mod = (playerid == null) ? new CSteamID(11111111111111111) : playerid.Player.SteamChannel.SteamPlayer.SteamPlayerID.CSteamID;
if (ZaupWhitelist.Instance.Configuration.Instance.AddtoGameWhitelist)
SteamWhitelist.whitelist((CSteamID)pcsteamid, command[1], mod); // We are using the game whitelist to add to game whitelist.
ZaupWhitelist.Instance.Database.AddWhitelist((CSteamID)pcsteamid, command[1], mod);
message = ZaupWhitelist.Instance.Translate("default_permit_message", new object[] {
pcsteamid.ToString(),
command[1]
});
this.sendMessage(message, console, playerid);
return;
}
private void sendMessage(string message, bool console, UnturnedPlayer caller = null)
{
if (console)
{
Logger.Log(message);
}
else
{
UnturnedChat.Say(caller, message);
}
}
}
}