forked from mrtwidget/Livemaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLivemap.cs
More file actions
82 lines (73 loc) · 2.79 KB
/
CommandLivemap.cs
File metadata and controls
82 lines (73 loc) · 2.79 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
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
using System;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using System.Collections.Generic;
namespace NEXIS.Livemap
{
public class CommandLivemap : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get { return AllowedCaller.Player; }
}
public bool AllowFromConsole
{
get { return false; }
}
public string Name
{
get { return "livemap"; }
}
public string Help
{
get { return "Toggle hiding yourself from the website livemap."; }
}
public List<string> Aliases
{
get { return new List<string>() { }; }
}
public string Syntax
{
get { return "/livemap"; }
}
public List<string> Permissions
{
get
{
return new List<string>() { "livemap" };
}
}
public void Execute(IRocketPlayer caller, params string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
// if player hiding is enabled, toggle player hidden
if (Livemap.Instance.Configuration.Instance.PlayerHideEnabled)
{
// is player in PlayersHiddenCooldown dictionary?
if (Livemap.PlayersHiddenCooldown.ContainsKey(player.CSteamID)) {
UnturnedChat.Say(caller, Livemap.Instance.Translations.Instance.Translate("livemap_hidden_cooldown_remaining", (Math.Round((Livemap.Instance.Configuration.Instance.PlayerHideCooldownDuration - (DateTime.Now -(DateTime)Livemap.PlayersHiddenCooldown[player.CSteamID]).TotalSeconds), 0, MidpointRounding.AwayFromZero)) + " seconds"));
return;
}
// is player already hiding?
if (Livemap.PlayersHidden.ContainsKey(player.CSteamID))
{
// hiding; unhide player
Livemap.PlayersHidden.Remove(player.CSteamID);
UnturnedChat.Say(caller, Livemap.Instance.Translations.Instance.Translate("livemap_hidden_false"));
}
else
{
// not hiding; hide player
Livemap.PlayersHidden.Add(player.CSteamID, DateTime.Now);
UnturnedChat.Say(caller, Livemap.Instance.Translations.Instance.Translate("livemap_hidden_true", Livemap.Instance.Configuration.Instance.PlayerHideDuration + " seconds"));
}
}
else
{
// livemap command disabled in config, notify player
UnturnedChat.Say(caller, Livemap.Instance.Translations.Instance.Translate("livemap_hidden_disabled"));
}
}
}
}