-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCommandTPS.cs
More file actions
67 lines (58 loc) · 1.95 KB
/
Copy pathCommandTPS.cs
File metadata and controls
67 lines (58 loc) · 1.95 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
//Rocket Mod TPS command used as a template for this command.
using System;
using System.Collections.Generic;
using Rocket.API;
using Rocket.Unturned.Chat;
using Steamworks;
using UnityEngine;
namespace FPSCap
{
public class CommandTPS : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get { return AllowedCaller.Both; }
}
public string Name
{
get { return "tps"; }
}
public string Help
{
get { return "Shows the server's current TPS."; }
}
public string Syntax
{
get { return ""; }
}
public List<string> Aliases
{
get { return new List<string>(); }
}
public List<string> Permissions
{
get { return new List<string>() { "FPSCap.tps" }; }
}
public void Execute(IRocketPlayer caller, string[] command)
{
int timeLeft = (int)((DateTime.UtcNow - FPSCap.Started).TotalSeconds);
string runningTimeFormat = "";
// Format days, hours minutes and seconds since the server was started.
if (timeLeft >= (60 * 60 * 24))
{
runningTimeFormat = ((int)(timeLeft / (60 * 60 * 24))).ToString() + "d ";
}
if (timeLeft >= (60 * 60))
{
runningTimeFormat += ((int)((timeLeft / (60 * 60)) % 24)).ToString() + "h ";
}
if (timeLeft >= 60)
{
runningTimeFormat += ((int)((timeLeft / 60) % 60)).ToString() + "m ";
}
runningTimeFormat += ((int)(timeLeft % 60)).ToString() + "s";
UnturnedChat.Say(caller, FPSCap.Instance.Translations.Instance.Translate("tps_tps", FPSCap.TPS));
UnturnedChat.Say(caller, FPSCap.Instance.Translations.Instance.Translate("tps_running_since", FPSCap.Started.ToString(), runningTimeFormat));
}
}
}