-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCommandCloneItem.cs
85 lines (69 loc) · 2.61 KB
/
CommandCloneItem.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
using Rocket.API;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Items;
using Rocket.Unturned.Player;
using System.Collections.Generic;
using SDG.Unturned;
namespace EasyAmmo
{
class CommandCloneItem : IRocketCommand
{
public List<string> Aliases => new List<string>();
public AllowedCaller AllowedCaller => AllowedCaller.Player;
public void Execute(IRocketPlayer caller, string[] command)
{
ushort amountToSpawn = 0;
ItemAsset currentEquiped;
UnturnedPlayer uPlayer = (UnturnedPlayer)caller;
currentEquiped = uPlayer.Player.equipment.asset;
if (currentEquiped == null)
{
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("nothing_equipped"));
return;
}
if (checkIfBlacklisted(caller, currentEquiped))
{
UnturnedChat.Say(EasyAmmo.Instance.Translate("Clonei_item_blacklisted", currentEquiped.name));
return;
}
var state = uPlayer.Player.equipment.state;
/* for (int count = 0; count <= state.Length - 1; count++)
{
Logger.Log("State " + count.ToString() + " : " + state[count].ToString());
//state[count] = 17;
} */
/*
state[0] is a sight
state[8] is a magazine
state[10] is ammo count
*/
Item newItem = new Item(currentEquiped.id, 100, 100, state);
if (amountToSpawn == 0)
{
amountToSpawn = 1;
}
if (caller.HasPermission("clonei.amount"))
{
for (int ii = 0; ii < amountToSpawn; ii++)
{
uPlayer.GiveItem(newItem);
}
}
else
{
uPlayer.GiveItem(newItem);
}
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("cloned_item",
UnturnedItems.GetItemAssetById(currentEquiped.id).itemName, amountToSpawn.ToString()));
}
public string Help => "Gives you a clone of your current item";
public string Name => "clonei";
public List<string> Permissions => new List<string> { "clonei" };
public string Syntax => "(amount)";
bool checkIfBlacklisted(IRocketPlayer caller, ItemAsset item)
{
if (caller.HasPermission("clonei.bypassblacklist")) return false;
return EasyAmmo.Instance.Configuration.Instance.BannedIds.Contains(item.id);
}
}
}