Skip to content

Commit d1dd661

Browse files
authored
Merge pull request #48 from sillyscp/azzy/39
2 parents cd3b502 + 069f41c commit d1dd661

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

SillySCP/Commands/Damage.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using CommandSystem;
2+
using Exiled.API.Features;
3+
using SillySCP.API.Features;
4+
5+
namespace SillySCP.Commands
6+
{
7+
[CommandHandler(typeof(ClientCommandHandler))]
8+
public class Damage : ICommand
9+
{
10+
public string Command { get; } = "damage";
11+
public string[] Aliases { get; } = new [] { "d", "dmg" };
12+
public string Description { get; } = "Get the amount of damage you've dealt.";
13+
14+
public bool Execute(
15+
ArraySegment<string> arguments,
16+
ICommandSender sender,
17+
out string response
18+
)
19+
{
20+
Player.TryGet(sender, out Player player);
21+
22+
if (player == null)
23+
{
24+
response = "Only players can use this command!";
25+
return false;
26+
}
27+
28+
if (player.DoNotTrack)
29+
{
30+
response =
31+
"You have do not track enabled, disable it so we can start tracking your damage!";
32+
return false;
33+
}
34+
35+
if (player.IsAlive)
36+
{
37+
response = "You must be dead to run this command!";
38+
return false;
39+
}
40+
41+
PlayerStat playerStat = Plugin.Instance.PlayerStats.Find((p) => p.Player == player);
42+
if (playerStat == null)
43+
{
44+
response = "You have dealt 0 damage!";
45+
return true;
46+
}
47+
48+
response = "You have dealt " + Math.Floor(playerStat.Damage ?? 0) + " damage!";
49+
return true;
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)