forked from Rawrfuls/Uconomy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Uconomy.cs
81 lines (73 loc) · 2.87 KB
/
Uconomy.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
using Rocket;
using Rocket.API.Collections;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Unturned.Events;
using Rocket.Unturned.Player;
using Rocket.Unturned.Plugins;
using SDG;
using Steamworks;
using System;
namespace fr34kyn01535.Uconomy
{
public class Uconomy : RocketPlugin<UconomyConfiguration>
{
public DatabaseManager Database;
public static Uconomy Instance;
protected override void Load()
{
Instance = this;
Database = new DatabaseManager();
U.Events.OnPlayerConnected+=Events_OnPlayerConnected;
}
public delegate void PlayerBalanceUpdate(UnturnedPlayer player, decimal amt);
public event PlayerBalanceUpdate OnBalanceUpdate;
public delegate void PlayerBalanceCheck(UnturnedPlayer player, decimal balance);
public event PlayerBalanceCheck OnBalanceCheck;
public delegate void PlayerPay(UnturnedPlayer sender, string receiver, decimal amt);
public event PlayerPay OnPlayerPay;
public override TranslationList DefaultTranslations
{
get
{
return new TranslationList(){
{"command_balance_show","Your current balance is: {0} {1}"},
{"command_pay_invalid","Invalid arguments"},
{"command_pay_error_pay_self","You cant pay yourself"},
{"command_pay_error_invalid_amount","Invalid amount"},
{"command_pay_error_cant_afford","Your balance does not allow this payment"},
{"command_pay_error_player_not_found","Failed to find player"},
{"command_pay_private","You paid {0} {1} {2}"},
{"command_pay_console","You received a payment of {0} {1} "},
{"command_pay_other_private","You received a payment of {0} {1} from {2}"},
};
}
}
internal void HasBeenPayed(UnturnedPlayer sender, string receiver, decimal amt)
{
if (OnPlayerPay != null)
OnPlayerPay(sender, receiver, amt);
}
internal void BalanceUpdated(string SteamID, decimal amt)
{
if (OnBalanceUpdate != null)
{
UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(SteamID)));
OnBalanceUpdate(player, amt);
}
}
internal void OnBalanceChecked(string SteamID, decimal balance)
{
if (OnBalanceCheck != null)
{
UnturnedPlayer player = UnturnedPlayer.FromCSteamID(new CSteamID(Convert.ToUInt64(SteamID)));
OnBalanceCheck(player, balance);
}
}
private void Events_OnPlayerConnected(UnturnedPlayer player)
{
//setup account
Database.CheckSetupAccount(player.CSteamID);
}
}
}