Skip to content

Commit

Permalink
Merge branch 'pull/4'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CommandAmmo.cs
#	CommandCloneItem.cs
#	CommandDropAmmo.cs
#	EasyAmmo.cs
#	EasyAmmo.csproj
#	EasyAmmo.sln
#	LICENSE
#	lib/Assembly-CSharp-firstpass.dll
#	lib/Assembly-CSharp.dll
#	lib/UnityEngine.CoreModule.dll
#	lib/UnityEngine.dll
  • Loading branch information
sharkbound committed Jan 15, 2020
2 parents b1cf276 + 6f7fe33 commit f5903db
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 245 deletions.
199 changes: 98 additions & 101 deletions CommandAmmo.cs

Large diffs are not rendered by default.

97 changes: 58 additions & 39 deletions CommandCloneItem.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
using System.Collections.Generic;
using Rocket.API;
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Items;
using Rocket.Unturned.Player;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using fr34kyn01535.Uconomy;
using SDG.Unturned;

namespace EasyAmmo
namespace EasyAmmoRocketMod
{
class CommandCloneItem : IRocketCommand
{
public List<string> Aliases => new List<string>();
public List<string> Aliases
{
get { return new List<string> { }; }
}

public AllowedCaller AllowedCaller => AllowedCaller.Player;
public AllowedCaller AllowedCaller
{
get { return Rocket.API.AllowedCaller.Player; }
}

public void Execute(IRocketPlayer caller, string[] command)
{
ushort amountToSpawn = 0;
var uplayer = (UnturnedPlayer) caller;
ushort AmountToSpawn = (ushort)0;
SDG.Unturned.ItemAsset currentEquiped;
UnturnedPlayer Uplayer = (UnturnedPlayer)caller;

if (command.Length == 1)
{
ushort.TryParse(command[0], out amountToSpawn);
}

var currentEquiped = uplayer.Player.equipment.asset;
currentEquiped = Uplayer.Player.equipment.asset;
if (currentEquiped == null)
{
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("nothing_equipped"));
Expand All @@ -32,59 +39,71 @@ public void Execute(IRocketPlayer caller, string[] command)

if (checkIfBlacklisted(caller, currentEquiped))
{
UnturnedChat.Say(caller,
EasyAmmo.Instance.Translate("Clonei_item_blacklisted", currentEquiped.itemName));
UnturnedChat.Say(EasyAmmo.Instance.Translate("Clonei_item_blacklisted", currentEquiped.name));
return;
}

var state = uplayer.Player.equipment.state;
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;
} */
/* 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
*/

SDG.Unturned.Item newItem = new SDG.Unturned.Item(currentEquiped.id, 100, 100, state);

var newItem = new Item(currentEquiped.id, 100, 100, state);

if (amountToSpawn == 0)
if (AmountToSpawn == 0)
{
amountToSpawn = 1;
AmountToSpawn = 1;
}

if (caller.HasPermission("clonei.amount"))
{
for (int ii = 0; ii < amountToSpawn; ii++)
for (int ii = 0; ii < AmountToSpawn; ii++)
{
uplayer.GiveItem(newItem);
}
Uplayer.GiveItem(newItem);
}
}
else
{
uplayer.GiveItem(newItem);
Uplayer.GiveItem(newItem);
}

UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("cloned_item",
UnturnedItems.GetItemAssetById(currentEquiped.id).itemName, amountToSpawn.ToString()));
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("cloned_item",
UnturnedItems.GetItemAssetById(currentEquiped.id).itemName, AmountToSpawn.ToString()));
return;
}

public string Help => "Gives you a clone of your current item";
public string Help
{
get { return "Gives you a clone of your current item"; }
}

public string Name => "clonei";
public string Name
{
get { return "clonei"; }
}

public List<string> Permissions => new List<string> {"clonei"};
public List<string> Permissions
{
get { return new List<string> { "clonei" }; }
}

public string Syntax => "(amount)";
public string Syntax
{
get { return "(amount)"; }
}

bool checkIfBlacklisted(IRocketPlayer caller, ItemAsset item)
{
return !caller.HasPermission("clonei.bypassblacklist") &&
EasyAmmo.Instance.Configuration.Instance.BannedIds.Contains(item.id);
if (caller.HasPermission("clonei.bypassblacklist")) return false;
return EasyAmmo.Instance.Configuration.Instance.BannedIds.Contains(item.id);
}
}
}
}
117 changes: 65 additions & 52 deletions CommandDropAmmo.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
using System.Collections.Generic;
using Rocket.API;
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Items;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EasyAmmo
namespace EasyAmmoRocketMod
{
class CommandDropAmmo : IRocketCommand
{
public List<string> Aliases => new List<string> {"dammo", "da", "dropa"};
public List<string> Aliases
{
get { return new List<string> { "dammo", "da", "dropa" }; }
}

public AllowedCaller AllowedCaller => AllowedCaller.Player;
public AllowedCaller AllowedCaller
{
get { return Rocket.API.AllowedCaller.Player; }
}

public void Execute(IRocketPlayer caller, string[] command)
{
ushort ammoAmountToSpawn = 0;
var enteredAmount = false;
var uplayer = (UnturnedPlayer) caller;
ushort ammoAmountToSpawn = (ushort)0;
bool EnteredAmount = false;
SDG.Unturned.ItemGunAsset currentWeapon;
SDG.Unturned.ItemAsset currentEquiped;
UnturnedPlayer Uplayer = (UnturnedPlayer)caller;

if (command.Length >= 1)
{
if (ushort.TryParse(command[0], out ammoAmountToSpawn))
{
enteredAmount = true;
EnteredAmount = true;
}
}

var currentEquiped = uplayer.Player.equipment.asset;
currentEquiped = Uplayer.Player.equipment.asset;
if (currentEquiped == null)
{
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("nothing_equipped"));
return;
}

if (currentEquiped.type != EItemType.GUN)
if (currentEquiped.type != SDG.Unturned.EItemType.GUN)
{
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("no_gun_equipped"));
return;
Expand All @@ -43,91 +54,93 @@ public void Execute(IRocketPlayer caller, string[] command)
//UnturnedChat.Say(caller, " your current equipped item is \" id: " + currentEquiped + " / " + "name: " + currentEquiped.name);
//UnturnedChat.Say(caller, "item type: " + item.GetType().ToString());

var currentWeapon = (ItemGunAsset) currentEquiped;
currentWeapon = (SDG.Unturned.ItemGunAsset)currentEquiped;
if (currentWeapon == null)
{
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("gun_asset_not_found"));
return;
}

if (EasyAmmo.CheckIfBlacklisted(caller, currentWeapon))
{
return;
}

if (enteredAmount && caller.HasPermission("dropammo.amount"))
if (EnteredAmount && caller.HasPermission("dropammo.amount"))
{
if (EasyAmmo.Instance.Configuration.Instance.ClipLimitEnabled)
{
DropMagsWithLimit(ammoAmountToSpawn, caller, currentWeapon, uplayer, command);
DropMagsWithLimit(ammoAmountToSpawn, caller, currentWeapon, Uplayer, command);
}
else
{
DropMags(ammoAmountToSpawn, caller, currentWeapon, uplayer, command);
DropMags(ammoAmountToSpawn, caller, currentWeapon, Uplayer, command);
}
}
else
{
DropMags(1, caller, currentWeapon, uplayer, command);
DropMags((ushort)1, caller, currentWeapon, Uplayer, command);
}
}

public string Help => "drops the specified number of clips for your currently equipped weapon.";
public string Help
{
get { return "drops the specified number of clips for your currently equipped weapon."; }
}

public string Name => "dropammo";
public string Name
{
get { return "dropammo"; }
}

public List<string> Permissions => new List<string> {"dropammo"};
public List<string> Permissions
{
get { return new List<string> { "dropammo" }; }
}

public string Syntax => "(amount of ammo)";
public string Syntax
{
get { return "(amount of ammo)"; }
}

public void DropMags(ushort ammoAmountToSpawn, IRocketPlayer caller, ItemGunAsset currentWeapon,
UnturnedPlayer uplayer, string[] command)
public void DropMags(ushort ammoAmountToSpawn, IRocketPlayer caller, SDG.Unturned.ItemGunAsset currentWeapon, UnturnedPlayer Uplayer, string[] command)
{
UnturnedChat.Say(caller,
EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(),
UnturnedItems.GetItemAssetById(GetMagId(uplayer, currentWeapon, command)).itemName,
GetMagId(uplayer, currentWeapon, command).ToString()));
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(), UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));

for (int ii = 0; ii < (int) ammoAmountToSpawn; ii++)
for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
{
ItemManager.dropItem(new Item(GetMagId(uplayer, currentWeapon, command), true), uplayer.Position, true,
true, true);
ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position, true, true, true);
}
}

public void DropMagsWithLimit(ushort ammoAmountToSpawn, IRocketPlayer caller, ItemGunAsset currentWeapon,
UnturnedPlayer Uplayer, string[] command)
public void DropMagsWithLimit(ushort ammoAmountToSpawn, IRocketPlayer caller, SDG.Unturned.ItemGunAsset currentWeapon, UnturnedPlayer Uplayer, string[] command)
{
if (ammoAmountToSpawn <= (ushort) EasyAmmo.Instance.Configuration.Instance.ClipLimit ||
caller.HasPermission("easyammo.bypasslimit"))
if (ammoAmountToSpawn <= (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit || caller.HasPermission("easyammo.bypasslimit"))
{
UnturnedChat.Say(caller,
EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(),
UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).itemName,
GetMagId(Uplayer, currentWeapon, command).ToString()));
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("dropping_mags", ammoAmountToSpawn.ToString(), UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));

for (int ii = 0; ii < (int) ammoAmountToSpawn; ii++)
for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
{
ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position,
true, true, true);
ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position, true, true, true);
}
}
else
{
UnturnedItems.GetItemAssetById(1);
ushort amountoverlimit = ammoAmountToSpawn;
ammoAmountToSpawn = (ushort) EasyAmmo.Instance.Configuration.Instance.ClipLimit;
ammoAmountToSpawn = (ushort)EasyAmmo.Instance.Configuration.Instance.ClipLimit;

UnturnedChat.Say(caller,
EasyAmmo.Instance.Translate("over_clip_spawn_limit_dropping", amountoverlimit.ToString(),
EasyAmmo.Instance.Configuration.Instance.ClipLimit,
UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).itemName,
GetMagId(Uplayer, currentWeapon, command).ToString()));
UnturnedChat.Say(caller, EasyAmmo.Instance.Translate("over_clip_spawn_limit_dropping", amountoverlimit.ToString(), EasyAmmo.Instance.Configuration.Instance.ClipLimit, UnturnedItems.GetItemAssetById(GetMagId(Uplayer, currentWeapon, command)).name, GetMagId(Uplayer, currentWeapon, command).ToString()));

for (int ii = 0; ii < (int) ammoAmountToSpawn; ii++)
for (int ii = 0; ii < (int)ammoAmountToSpawn; ii++)
{
ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position,
true, true, true);
ItemManager.dropItem(new Item(GetMagId(Uplayer, currentWeapon, command), true), Uplayer.Position, true, true, true);
}

}
}

public ushort GetMagId(UnturnedPlayer player, ItemGunAsset gun, string[] command)
public ushort GetMagId(UnturnedPlayer player, SDG.Unturned.ItemGunAsset gun, string[] command)
{
ushort magId = 0;

Expand Down Expand Up @@ -157,4 +170,4 @@ public ushort GetMagId(UnturnedPlayer player, ItemGunAsset gun, string[] command
return magId;
}
}
}
}
Loading

0 comments on commit f5903db

Please sign in to comment.