forked from CryReaper/StatKeeper
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CommandStats.cs
236 lines (223 loc) · 8.68 KB
/
CommandStats.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using System.Collections.Generic;
using Rocket.API;
using Rocket.Unturned.Player;
using UnityEngine;
namespace StatKeeper
{
public class CommandStats : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}
public List<string> Permissions
{
get
{
return new List<string>() {
"statkeeper.stats"
};
}
}
public bool RunFromConsole
{
get { return false; }
}
public string Name
{
get { return "stats"; }
}
public string Syntax
{
get
{
return "<mode/stat node> <player>";
}
}
public string Help
{
get { return "Enter player name to see stats of player or no player name to view your stats."; }
}
public List<string> Aliases
{
get { return new List<string> { "stats" }; }
}
private string showPVP(UnturnedPlayer player,Stats stats)
{
return player.CharacterName + "'s PvP Stats: Total Kills [" + stats.TotalKills + "]"
+ ", Total Deaths [" + stats.TotalDeaths + "]" + ", KD [" + stats.KDRatio + "]" + ", Gun Kills [" + stats.GetKills(SDG.Unturned.EDeathCause.GUN.ToString()) + "]"
+ ", Melee Kills [" + stats.GetKills(SDG.Unturned.EDeathCause.MELEE.ToString()) + "]" + ", Punch Kills [" + stats.GetKills(SDG.Unturned.EDeathCause.PUNCH.ToString()) + "]" + ", Road Kills [" + stats.GetKills(SDG.Unturned.EDeathCause.ROADKILL.ToString()) + "]"
+ ", Gun Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.GUN.ToString()) + "]" + ", Melee Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.MELEE.ToString()) + "]" + ", Punch Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.PUNCH.ToString()) + "]"
+ ", Road Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.ROADKILL.ToString()) + "]" + ", Suicides [" + stats.GetDeaths(SDG.Unturned.EDeathCause.SUICIDE.ToString()) + "]";
}
private string showPVE(UnturnedPlayer player, Stats stats)
{
return player.CharacterName + "'s PvE Stats: Total Deaths [" + stats.TotalDeaths + "]"
+ ", Zombie Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.ZOMBIE.ToString()) + "]" + ", Vehicle Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.VEHICLE.ToString()) + "]" + ", Food Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.FOOD.ToString()) + "]"
+ ", Water Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.WATER.ToString()) + "]" + ", Infection Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.INFECTION.ToString()) + "]" + ", Bleeding Deaths [" + stats.GetDeaths(SDG.Unturned.EDeathCause.BLEEDING.ToString()) + "]";
}
private string showTK(UnturnedPlayer player, Stats stats)
{
return player.CharacterName + "'s Total Kills: [" + stats.TotalKills + "]";
}
private string showTD(UnturnedPlayer player, Stats stats)
{
return player.CharacterName + "'s Total Deaths: PvP[" + stats.TotalDeaths + "]";
}
private string showKD(UnturnedPlayer player, Stats stats)
{
return player.CharacterName + "'s KD: [" + stats.KDRatio + "]";
}
public void Execute(IRocketPlayer caller, string[] command)
{
UnturnedPlayer player = (UnturnedPlayer)caller;
Stats stats = player.GetComponent<StatsPlayerComponent>().Stats.Instance;
if (command.Length < 1)
{
return;
}
if (command[0].ToString().ToLower() == "pvp")
{
if (command.Length == 1)
{
Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVP(player, stats), Color.yellow);
}
if (command.Length == 2)
{
if(player.HasPermission("stats.admin"))
{
UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower());
if (target == null)
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Player does not exist or is offline!", Color.yellow);
}
else
{
Stats targetStats = target.GetComponent<StatsPlayerComponent>().Stats.Instance;
Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVP(target, targetStats), Color.yellow);
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "You do not have permission to use this command!", Color.red);
}
}
}
else if (command[0].ToString().ToLower() == "pve")
{
if (command.Length == 1)
{
Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVE(player, stats), Color.yellow);
}
if (command.Length == 2)
{
if(player.HasPermission("stats.admin"))
{
UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower());
if (target == null)
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Player does not exist or is offline!", Color.yellow);
}
else
{
Stats targetStats = target.GetComponent<StatsPlayerComponent>().Stats.Instance;
Rocket.Unturned.Chat.UnturnedChat.Say(player, showPVE(target, targetStats), Color.yellow);
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "You do not have permission to use this command!", Color.red);
}
}
}
else if (command[0].ToString().ToLower() == "tk")
{
if (command.Length == 1)
{
Rocket.Unturned.Chat.UnturnedChat.Say(player, showTK(player, stats), Color.yellow);
}
else if (command.Length == 2)
{
if(player.HasPermission("stats.admin"))
{
UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower());
if (target == null)
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Player does not exist or is offline!", Color.yellow);
}
else
{
Stats targetStats = target.GetComponent<StatsPlayerComponent>().Stats.Instance;
Rocket.Unturned.Chat.UnturnedChat.Say(player, showTK(target, targetStats), Color.yellow);
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "You do not have permission to use this command!", Color.red);
}
}
}
else if (command[0].ToString().ToLower() == "td")
{
if (command.Length == 1)
{
Rocket.Unturned.Chat.UnturnedChat.Say(player, showTD(player, stats), Color.yellow);
}
else if (command.Length == 2)
{
if(player.HasPermission("stats.admin"))
{
UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower());
if (target == null)
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Player does not exist or is offline!", Color.yellow);
}
else
{
Stats targetStats = target.GetComponent<StatsPlayerComponent>().Stats.Instance;
Rocket.Unturned.Chat.UnturnedChat.Say(player, showTD(target, targetStats), Color.yellow);
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "You do not have permission to use this command!", Color.red);
}
}
}
else if (command[0].ToString().ToLower() == "kd")
{
if (command.Length == 1)
{
Rocket.Unturned.Chat.UnturnedChat.Say(player, showKD(player, stats), Color.yellow);
}
else if (command.Length == 2)
{
if(player.HasPermission("stats.admin"))
{
UnturnedPlayer target = UnturnedPlayer.FromName(command[1].ToString().ToLower());
if (target == null)
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Player does not exist or is offline!", Color.yellow);
}
else
{
Stats targetStats = target.GetComponent<StatsPlayerComponent>().Stats.Instance;
Rocket.Unturned.Chat.UnturnedChat.Say(player, showKD(target, targetStats), Color.yellow);
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "You do not have permission to use this command!", Color.red);
}
}
}
else
{
Rocket.Unturned.Chat.UnturnedChat.Say (player, "Not a valid mode or stat node! Select mode: pvp or pve, or a stat node: tk, td, or kd.", Color.yellow);
}
}
}
}