This repository was archived by the owner on Jan 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoWarheadCommands.cs
More file actions
60 lines (51 loc) · 2.44 KB
/
Copy pathAutoWarheadCommands.cs
File metadata and controls
60 lines (51 loc) · 2.44 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
using BetterCommands;
using BetterCommands.Permissions;
using PlayerRoles;
using PluginAPI.Core;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace AutoWarhead {
public static class AutoWarheadCommands {
[Command("autowarhead", CommandType.RemoteAdmin, CommandType.GameConsole)]
[CommandAliases("autow")]
[Description("Enable/disable Automatic Alpha Warhead")]
public static string AWtoggle(Player sender) {
AutoWarheadLogic.IsEnabled = !AutoWarheadLogic.IsEnabled;
return AutoWarheadLogic.IsEnabled ?
"Automatic Warhead enabled." :
"Automatic Warhead disabled.";
}
[Command("autowarheadstatus", CommandType.RemoteAdmin, CommandType.GameConsole)]
[CommandAliases("autowstatus", "autows")]
[Description("Show status Automatic Alpha Warhead (in minutes)")]
public static string AWstatus(Player sender) {
var sb = new StringBuilder();
if (AutoWarheadLogic.WarningEnabled) {
string warning = $"Warning time set to {FormatTime(AutoWarheadLogic.WarningTime)}.";
if (AutoWarheadLogic.IsRoundStarted() && AutoWarheadLogic.IsEnabled) {
double time = AutoWarheadLogic.WarningTime - Round.Duration.TotalMinutes;
if (time < 0) warning += " Already announced.";
else warning += $" Remaining {FormatTime(time)}.";
}
sb.AppendLine(warning);
}
string warhead = $"Auto Warhead time set to {FormatTime(AutoWarheadLogic.StartAfter)}.";
if (Warhead.IsDetonated) warhead += " Is detonated.";
else if (AutoWarheadLogic.IsDetonating) warhead += " Is being detonated.";
else if (AutoWarheadLogic.IsRoundStarted() && AutoWarheadLogic.IsEnabled) {
double time = AutoWarheadLogic.StartAfter - Round.Duration.TotalMinutes;
if (time < 0) warhead += " Already detonated.";
else warhead += $" Remaining {FormatTime(time)}.";
}
sb.AppendLine(warhead);
if (!AutoWarheadLogic.IsEnabled) sb.AppendLine($"PLUGIN IS NOT ACTIVE!");
return sb.ToString();
}
private static string FormatTime(double time) {
int seconds = Convert.ToInt32(time * 60);
return $"{seconds / 60}m:{seconds % 60}s";
}
}
}