-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class1.cs
125 lines (110 loc) · 5.33 KB
/
Class1.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rocket.API;
using Rocket.Unturned;
using Rocket.Core;
using UnityEngine;
using Rocket.Unturned.Plugins;
using SDG;
using Rocket.Core.Plugins;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Events;
using DeathMessages;
using Steamworks;
//Yeha, we are on GitHub
namespace Sadusko.DeathMessages
{
public class PlayerDeath : RocketPlugin<DMC2>
{
public static PlayerDeath Instance;
protected override void Load()
{
Instance = this;
Logger.Log("Sadusko's Death Messages has been loaded!");
#region Event
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerDeath += UnturnedPlayerEvents_OnPlayerDeath;
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerUpdateHealth += UnturnedPlayerEvents_OnPlayerUpdateHealth;
#endregion
Logger.LogError("NOTE:");
Logger.LogError("Don't forget to set the permission 'deathmessage' in one of the groups.");
}
private void UnturnedPlayerEvents_OnPlayerDeath(Rocket.Unturned.Player.UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.Unturned.ELimb limb, Steamworks.CSteamID murderer)
{
if (player.HasPermission("deathmessage"))
{
if (cause.ToString() == "ZOMBIE")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.zombie + " ", Color.red);
}
else if (cause.ToString() == "GUN")
{
UnturnedChat.Say(Rocket.Unturned.Player.UnturnedPlayer.FromCSteamID(murderer).CharacterName + " " + this.Configuration.Instance.gun + " " + player.CharacterName + "!", Color.red);
}
else if (cause.ToString() == "MELEE")
{
UnturnedChat.Say(Rocket.Unturned.Player.UnturnedPlayer.FromCSteamID(murderer).CharacterName + " " + this.Configuration.Instance.melee + " " + player.CharacterName + " " + this.Configuration.Instance.melee2, Color.red);
}
else if (cause.ToString() == "PUNCH")
{
UnturnedChat.Say(Rocket.Unturned.Player.UnturnedPlayer.FromCSteamID(murderer).CharacterName + " " + this.Configuration.Instance.punch + " " + player.CharacterName + " " + this.Configuration.Instance.punch2, Color.red);
}
else if (cause.ToString() == "ROADKILL")
{
UnturnedChat.Say(Rocket.Unturned.Player.UnturnedPlayer.FromCSteamID(murderer).CharacterName + " " + this.Configuration.Instance.roadkill + " " + player.CharacterName + "!", Color.red);
}
else if (cause.ToString() == "VEHICLE")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.vehicle, Color.red);
}
else if (cause.ToString() == "FOOD")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.food, Color.red);
}
else if (cause.ToString() == "WATER")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.water, Color.red);
}
else if (cause.ToString() == "INFECTION")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.infection, Color.red);
}
else if (cause.ToString() == "BLEEDING")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.bleeding, Color.red);
}
else if (cause.ToString() == "LANDMINE")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.landmine, Color.red);
}
else if (cause.ToString() == "BREATH")
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.breath, Color.red);
}
else if (cause.ToString() == "SUICIDE" && this.Configuration.Instance.suicidemsg)
{
UnturnedChat.Say(player.CharacterName + " " + this.Configuration.Instance.suicide, Color.red);
}
}
}
protected override void Unload()
{
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerDeath -= UnturnedPlayerEvents_OnPlayerDeath;
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerUpdateHealth -= UnturnedPlayerEvents_OnPlayerUpdateHealth;
}
void UnturnedPlayerEvents_OnPlayerUpdateHealth(Rocket.Unturned.Player.UnturnedPlayer player, byte health)
{
if (this.Configuration.Instance.warningmsg)
{
if (health == 25)
{
UnturnedChat.Say(player, this.Configuration.Instance.warning1, Color.yellow);
UnturnedChat.Say(player, this.Configuration.Instance.warning2, Color.yellow);
}
}
}
}
}