-
Notifications
You must be signed in to change notification settings - Fork 5
/
CommandApay.cs
103 lines (99 loc) · 3.34 KB
/
CommandApay.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
using System;
using System.Collections.Generic;
using Rocket.API;
using Rocket.Unturned;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Commands;
using Rocket.Unturned.Player;
using fr34kyn01535.Uconomy;
using SDG.Unturned;
using Steamworks;
namespace Uconomy_Essentials
{
public class CommandApay : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get
{
return AllowedCaller.Player;
}
}
public string Name
{
get
{
return "apay";
}
}
public string Help
{
get
{
return "Allows an allowed person to pay someone else not using their own currency.";
}
}
public string Syntax
{
get
{
return "<player name or id> <amt>";
}
}
public List<string> Aliases
{
get { return new List<string>(); }
}
public List<string> Permissions
{
get { return new List<string>(); }
}
public void Execute(IRocketPlayer caller, string[] msg)
{
UnturnedPlayer playerid = (UnturnedPlayer)caller;
string message;
if (msg.Length == 0)
{
message = Uconomy_Essentials.Instance.Translate("apay_usage_msg", new object[] {});
// We are going to print how to use
UnturnedChat.Say(playerid, message);
return;
}
if (msg.Length != 2)
{
message = Uconomy_Essentials.Instance.Translate("apay_usage_msg", new object[] { });
// Print how to use
UnturnedChat.Say(playerid, message);
return;
}
UnturnedPlayer rp = UnturnedPlayer.FromName(msg[0]);
if (rp == null)
{
ulong id;
ulong.TryParse(msg[0], out id);
if (!((CSteamID)id).IsValid())
{
message = Uconomy_Essentials.Instance.Translate("not_valid_player_msg", new object[] {msg[0]});
UnturnedChat.Say(playerid, message);
return;
}
else
{
rp = UnturnedPlayer.FromCSteamID((CSteamID)id);
}
}
uint amt;
uint.TryParse(msg[1], out amt);
if (amt <= 0)
{
message = Uconomy_Essentials.Instance.Translate("not_valid_amount", new object[] { msg[1] });
UnturnedChat.Say(playerid, message);
return;
}
decimal newbal = Uconomy.Instance.Database.IncreaseBalance(rp.CSteamID.ToString(), amt);
UnturnedChat.Say(rp.CSteamID, Uconomy_Essentials.Instance.Translate("apaid_msg", new object[] {playerid.CharacterName, amt, Uconomy.Instance.Configuration.Instance.MoneyName, newbal, Uconomy.Instance.Configuration.Instance.MoneyName}));
UnturnedChat.Say(playerid, Uconomy_Essentials.Instance.Translate("apay_msg", new object[] {rp.CharacterName, amt, Uconomy.Instance.Configuration.Instance.MoneyName}));
Uconomy_Essentials.HandleEvent(rp, amt, "paid");
}
}
}