-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZaupClearInventoryLib.cs
126 lines (119 loc) · 4.71 KB
/
ZaupClearInventoryLib.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
using System;
using Rocket.Core.Logging;
using Rocket.Core.Plugins;
using Rocket.Unturned.Player;
using SDG.Unturned;
namespace ZaupClearInventoryLib
{
public class ZaupClearInventoryLib : RocketPlugin<ZaupClearInventoryLibConfiguration>
{
public static ZaupClearInventoryLib Instance;
protected override void Load()
{
ZaupClearInventoryLib.Instance = this;
if (Configuration.Instance.DeleteInventoryOnDeath)
{
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerDeath += UnturnedPlayerEvents_OnPlayerDeath;
}
}
protected override void Unload()
{
if (Configuration.Instance.DeleteInventoryOnDeath)
{
Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerDeath -= UnturnedPlayerEvents_OnPlayerDeath;
}
}
void UnturnedPlayerEvents_OnPlayerDeath(Rocket.Unturned.Player.UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.Unturned.ELimb limb, Steamworks.CSteamID murderer)
{
ZaupClearInventoryLib.Instance.ClearInv(player);
ZaupClearInventoryLib.Instance.ClearClothes(player);
}
public bool ClearInv(UnturnedPlayer player)
{
bool returnv = false;
try
{
player.Player.equipment.dequip();
for (byte p = 0; p < (PlayerInventory.PAGES -1); p++)
{
byte itemc = player.Player.inventory.getItemCount(p);
if (itemc > 0)
{
for (byte p1 = 0; p1 < itemc; p1++)
{
player.Player.inventory.removeItem(p, 0);
}
}
}
player.Player.channel.send("tellSlot", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
{
(byte)0,
(byte)0,
new byte[0]
});
player.Player.channel.send("tellSlot", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
{
(byte)1,
(byte)0,
new byte[0]
});
returnv = true;
}
catch (Exception e)
{
Logger.Log("There was an error clearing " + player.CharacterName + "'s inventory. Here is the error.");
Console.Write(e);
}
return returnv;
}
public bool ClearClothes(UnturnedPlayer player)
{
bool returnv = false;
try
{
player.Player.clothing.askWearBackpack(0, 0, new byte[0],true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearGlasses(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearHat(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearMask(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearPants(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearShirt(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
player.Player.clothing.askWearVest(0, 0, new byte[0], true);
for (byte p2 = 0; p2 < player.Player.inventory.getItemCount(2); p2++)
{
player.Player.inventory.removeItem(2, 0);
}
returnv = true;
}
catch (Exception e)
{
Logger.Log("There was an error clearing " + player.CharacterName + "'s inventory. Here is the error.");
Console.Write(e);
}
return returnv;
}
}
}