This repository has been archived by the owner on Feb 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cs
72 lines (61 loc) · 3.5 KB
/
Main.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
using Rocket.Core.Logging;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Unturned.Events;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using fr34kyn01535.Uconomy;
namespace F.ExperienceUI
{
public class Main : RocketPlugin<Config>
{
public static Main Instance;
protected override void Load()
{
Main.Instance = this;
Logger.Log("####################################################", ConsoleColor.Red);
Logger.Log("# F.Economy/ExperienceUI Loaded #", ConsoleColor.Red);
Logger.Log("# Plugin By: Feli #", ConsoleColor.Red);
Logger.Log("# Discord Support:https://discord.gg/6zQVJ9p #", ConsoleColor.Red);
Logger.Log("# Plugin Ver: 3.0.0 #", ConsoleColor.Red);
Logger.Log("####################################################", ConsoleColor.Red);
U.Events.OnPlayerConnected += Events_OnPlayerConnected;
U.Events.OnPlayerDisconnected += Events_OnPlayerDisconnected;
if (this.Configuration.Instance.UconomyMode == true)
{
Uconomy.Instance.OnBalanceUpdate += UconomyOnBalanceUpdate;
}
else { UnturnedPlayerEvents.OnPlayerUpdateExperience += Events_OnPlayerUpdateExperience; }
}
private void Events_OnPlayerConnected(UnturnedPlayer player)
{
if (this.Configuration.Instance.UconomyMode == false)
{
EffectManager.sendUIEffect(this.Configuration.Instance.ExperienceUI, (short)32401, player.CSteamID, true, this.Configuration.Instance.EconomySymbol + player.Experience.ToString());
}
else { EffectManager.sendUIEffect(this.Configuration.Instance.ExperienceUI, (short)32401, player.CSteamID, true, this.Configuration.Instance.EconomySymbol + Uconomy.Instance.Database.GetBalance(player.Id).ToString()); }
EffectManager.sendUIEffect(this.Configuration.Instance.ServerNameUI, (short)32403, player.CSteamID, true, this.Configuration.Instance.ServerName.ToString());
}
private void Events_OnPlayerUpdateExperience(UnturnedPlayer player, uint experience)
{
EffectManager.sendUIEffect(this.Configuration.Instance.ExperienceUI, (short)32401, player.CSteamID, true, this.Configuration.Instance.EconomySymbol + player.Experience.ToString());
}
private void UconomyOnBalanceUpdate(UnturnedPlayer player, decimal v)
{
EffectManager.sendUIEffect(this.Configuration.Instance.ExperienceUI, (short)32401, player.CSteamID, true, this.Configuration.Instance.EconomySymbol + Uconomy.Instance.Database.GetBalance(player.Id).ToString());
}
private void Events_OnPlayerDisconnected(UnturnedPlayer player)
{
EffectManager.askEffectClearByID(this.Configuration.Instance.ExperienceUI, player.CSteamID);
EffectManager.askEffectClearByID(this.Configuration.Instance.ServerNameUI, player.CSteamID);
}
protected override void Unload()
{
U.Events.OnPlayerConnected -= Events_OnPlayerConnected;
U.Events.OnPlayerDisconnected -= Events_OnPlayerDisconnected;
UnturnedPlayerEvents.OnPlayerUpdateExperience -= Events_OnPlayerUpdateExperience;
Uconomy.Instance.OnBalanceUpdate -= UconomyOnBalanceUpdate;
}
}
}