This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCommandBounty.cs
128 lines (114 loc) · 4.98 KB
/
CommandBounty.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
using fr34kyn01535.Uconomy;
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using System;
using System.Collections.Generic;
namespace Freenex.FeexHitman
{
public class CommandBounty : IRocketCommand
{
public string Name
{
get { return "bounty"; }
}
public string Help
{
get { return "Add bounty to players"; }
}
public string Syntax
{
get { return "<player> <amount>"; }
}
public List<string> Aliases
{
get { return new List<string>(); }
}
public AllowedCaller AllowedCaller
{
get { return AllowedCaller.Player; }
}
public List<string> Permissions
{
get
{
return new List<string>()
{
"bounty"
};
}
}
public void Execute(IRocketPlayer caller, params string[] command)
{
if (command.Length == 2)
{
UnturnedPlayer otherPlayer = UnturnedPlayer.FromName(command[0]);
if (otherPlayer == null)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found") != "hitman_general_not_found")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_not_found"));
}
return;
}
if (caller.Id == otherPlayer.Id)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self") != "hitman_add_self")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_self"));
}
return;
}
decimal bounty = 0;
if (!Decimal.TryParse(command[1], out bounty) || bounty <= 0)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount") != "hitman_add_amount")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_amount"));
}
return;
}
decimal myBalance = Uconomy.Instance.Database.GetBalance(caller.Id);
if ((myBalance - bounty) < 0)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance") != "hitman_add_balance")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_balance"));
}
return;
}
if (bounty < FeexHitman.Instance.Configuration.Instance.MinimumBounty)
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum") != "hitman_add_minimum")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_add_minimum", FeexHitman.Instance.Configuration.Instance.MinimumBounty));
}
return;
}
if (FeexHitman.Instance.FeexHitmanDatabase.CheckExists(otherPlayer.CSteamID))
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased") != "hitman_general_chat_increased")
{
UnturnedChat.Say(FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_increased", otherPlayer.CharacterName, bounty, Convert.ToDecimal(FeexHitman.Instance.FeexHitmanDatabase.GetBounty(otherPlayer.CSteamID)) + bounty), UnityEngine.Color.yellow);
}
}
else
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created") != "hitman_general_chat_created")
{
UnturnedChat.Say(FeexHitman.Instance.Translations.Instance.Translate("hitman_general_chat_created", otherPlayer.CharacterName, bounty), UnityEngine.Color.yellow);
}
}
Uconomy.Instance.Database.IncreaseBalance(caller.Id.ToString(), -bounty);
FeexHitman.Instance.FeexHitmanDatabase.AddUpdateVictimAccount(otherPlayer.CSteamID, bounty, otherPlayer.CharacterName);
}
else
{
if (FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter") != "hitman_general_invalid_parameter")
{
UnturnedChat.Say(caller, FeexHitman.Instance.Translations.Instance.Translate("hitman_general_invalid_parameter"));
}
}
}
}
}