forked from Plugin4UGit/ForceDrop
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ForceDrop.cs
146 lines (135 loc) · 6.15 KB
/
ForceDrop.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using Rocket.API;
using Rocket.API.Collections;
using Rocket.Core.Commands;
using Rocket.Core.Plugins;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using Logger = Rocket.Core.Logging.Logger;
namespace ForceDrop
{
public class ForceDrop : RocketPlugin<ForceDropConfiguration>
{
private static ForceDrop Instance;
protected override void Load()
{
if (Configuration.Instance.Enabled)
{
Instance = this;
Logger.Log("[Plugin4U] ForceDrop loaded!");
Logger.Log("Make sure to visit our site at www.Plugin4U.cf", ConsoleColor.Magenta);
}
else {
Logger.Log("Configuration.Instance.Enabled == false");
this.Unload();
}
}
public override TranslationList DefaultTranslations
{
get
{
return new TranslationList(){
{"drop_message","Successfully dropped {0} inventory!" },
{"drop_message_id","Successfully dropped {0} from {1} inventory!"},
{"drop_message_public","Successfully dropped all players inventory!" },
{"drop_message_id_public","Successfully dropped {0} from all players inventory!"},
};
}
}
[RocketCommand("ForceDrop", "", "", AllowedCaller.Both)]
[RocketCommandAlias("Fd")]
public void Execute(IRocketPlayer caller, params string[] command)
{
if(command[0].ToLower() == "all")
{
if(command.Length == 1)
{
foreach(var steamplayer in Provider.clients)
{
UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(steamplayer);
for (byte page = 0; page < 8; page++)
{
var count = player.Inventory.getItemCount(page);
for (byte index = 0; index < count; index++)
{
foreach (var number in Configuration.Instance.WhiteListedFromDrop)
{
if (player.Inventory.getItem(page, index).item.id == number)
{ }
else
{
player.Inventory.askDropItem(player.CSteamID, page, player.Inventory.getItem(page, index).x, player.Inventory.getItem(page, index).y);
}
}
}
}
UnturnedChat.Say(caller, Translate("drop_message_public", ushort.Parse(command[1].ToString())));
}
}
if(command.Length == 2)
{
foreach(var steamplayer in Provider.clients)
{
UnturnedPlayer player = UnturnedPlayer.FromSteamPlayer(steamplayer);
for (byte page = 0; page < 8; page++)
{
var count = player.Inventory.getItemCount(page);
for (byte index = 0; index < count; index++)
{
if (player.Inventory.getItem(page, index).item.id == ushort.Parse(command[1].ToString()))
{
player.Inventory.askDropItem(player.CSteamID, page, player.Inventory.getItem(page, index).x, player.Inventory.getItem(page, index).y);
}
}
}
}
UnturnedChat.Say(caller, Translate("drop_message_id_public", ushort.Parse(command[1].ToString())));
}
}
if (command.Length == 1 && command[0].ToLower() != "all")
{
UnturnedPlayer player = UnturnedPlayer.FromName(command[0]);
if (player != null)
{
for (byte page = 0; page < 8; page++)
{
var count = player.Inventory.getItemCount(page);
for (byte index = 0; index < count; index++)
{
foreach (var number in Configuration.Instance.WhiteListedFromDrop)
{
if (player.Inventory.getItem(page, index).item.id == number)
{ }
else
{
player.Inventory.askDropItem(player.CSteamID, page, player.Inventory.getItem(page, index).x, player.Inventory.getItem(page, index).y);
}
}
}
}
UnturnedChat.Say(caller, Translate("drop_message", player.DisplayName));
}
}
if(command.Length == 2 && command[0].ToLower() != "all")
{
UnturnedPlayer player = UnturnedPlayer.FromName(command[0]);
if (player != null)
{
for (byte page = 0; page < 8; page++)
{
var count = player.Inventory.getItemCount(page);
for (byte index = 0; index < count; index++)
{
if (player.Inventory.getItem(page, index).item.id == ushort.Parse(command[1].ToString()))
{
player.Inventory.askDropItem(player.CSteamID, page, player.Inventory.getItem(page, index).x, player.Inventory.getItem(page, index).y);
}
}
}
UnturnedChat.Say(caller, Translate("drop_message_id", ushort.Parse(command[1].ToString()), player.DisplayName));
}
}
}
}
}