-
Notifications
You must be signed in to change notification settings - Fork 0
/
FrequencyCommand.cs
41 lines (35 loc) · 1.41 KB
/
FrequencyCommand.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
namespace SFrequencyInfo
{
public class FrequencyCommand : IRocketCommand
{
public string Name { get; } = "frequency";
public AllowedCaller AllowedCaller { get; } = AllowedCaller.Both;
public string Help { get; } = "Shows radio frequency of player.";
public string Syntax => $"/{Name} [target]";
public List<string> Aliases { get; } = new() { "freq" };
List<string> permissions;
public List<string> Permissions => permissions ??= Aliases.Prepend(Name).ToList();
public void Execute(IRocketPlayer caller, string[] command)
{
var arg = string.Join(" ", command);
if(string.IsNullOrWhiteSpace(arg))
{
UnturnedChat.Say(caller, Help, Color.yellow);
UnturnedChat.Say(caller, Syntax, Color.yellow);
return;
}
var target = PlayerTool.getPlayer(arg);
if (!target)
{
if (ulong.TryParse(arg, out var steamId))
target = PlayerTool.getPlayer(new CSteamID(steamId));
else
{
UnturnedChat.Say(caller, TranslateNotFound(arg), Color.red);
return;
}
}
UnturnedChat.Say(caller, TranslateFrequency(target.channel.owner.playerID.characterName, target.quests.radioFrequency));
}
}
}