Here's a replacement that I use on most shards as a standard upgrade.
It exposes new methods such as DupeChildren and fully supports containers.

It also has AccessLevel protection for the [Constructable] attribute, though the attribute is rarely used to limit the creation of items to an AccessLevel, IE: [Constructable(AccessLevel.Administrator)]

(Requires Vita-Nex: Core)

Code:
#region Header
//   Voxpire    _,-'/-'/  Dupe.cs
//   .      __,-; ,'( '/
//    \.    `-.__`-._`:_,-._       _ , . ``
//     `:-._,------' ` _,`--` -: `_ , ` ,' :
//        `---..__,,--'  (C) 2015  ` -'. -'
//        #  Vita-Nex [http://core.vita-nex.com]  #
//  {o)xxx|===============-   #   -===============|xxx(o}
//        #        The MIT License (MIT)          #
#endregion

#region References
using System;
using System.Linq;

using Server.Items;
using Server.Targeting;
#endregion

namespace Server.Commands
{
	public class Dupe
	{
		public static void Initialize()
		{
			CommandSystem.Register("Dupe", AccessLevel.GameMaster, Dupe_OnCommand);
			CommandSystem.Register("DupeInBag", AccessLevel.GameMaster, DupeInBag_OnCommand);
		}

		[Usage("Dupe [amount]")]
		[Description("Dupes a targeted item.")]
		private static void Dupe_OnCommand(CommandEventArgs e)
		{
			var amount = 1;

			if (e.Length > 0)
			{
				amount = e.GetInt32(0);
			}

			e.Mobile.Target = new DupeTarget(false, Math.Max(1, amount));
			e.Mobile.SendMessage("What do you wish to dupe?");
		}

		[Usage("DupeInBag <count>")]
		[Description("Dupes an item at it's current location (count) number of times.")]
		private static void DupeInBag_OnCommand(CommandEventArgs e)
		{
			var amount = 1;

			if (e.Length > 0)
			{
				amount = e.GetInt32(0);
			}

			e.Mobile.Target = new DupeTarget(true, Math.Max(1, amount));
			e.Mobile.SendMessage("What do you wish to dupe?");
		}

		private class DupeTarget : Target
		{
			private readonly bool _InBag;
			private readonly int _Amount;

			public DupeTarget(bool inbag, int amount)
				: base(15, false, TargetFlags.None)
			{
				_InBag = inbag;
				_Amount = amount;
			}

			protected override void OnTarget(Mobile m, object targ)
			{
				var done = false;

				if (!(targ is Item))
				{
					m.SendMessage("You can only dupe items.");
					return;
				}

				CommandLogging.WriteLine(
					m,
					"{0} {1} duping {2} (inBag={3}; amount={4})",
					m.AccessLevel,
					CommandLogging.Format(m),
					CommandLogging.Format(targ),
					_InBag,
					_Amount);

				var item = (Item)targ;

				Container pack;

				if (_InBag)
				{
					if (item.Parent is Container)
					{
						pack = (Container)item.Parent;
					}
					else if (item.Parent is Mobile)
					{
						pack = ((Mobile)item.Parent).Backpack;
					}
					else
					{
						pack = null;
					}
				}
				else
				{
					pack = m.Backpack;
				}

				var t = item.GetType();

				var a = t.GetCustomAttributes<ConstructableAttribute>(false);

				if (a != null && a.Length > 0 && a.Any(ca => ca.AccessLevel > m.AccessLevel))
				{
					return;
				}

				try
				{
					m.SendMessage("Duping {0}...", _Amount);

					var noCtor = false;

					for (var i = 0; i < _Amount; i++)
					{
						var o = t.CreateInstanceSafe<Item>();

						if (o == null)
						{
							noCtor = true;
							break;
						}

						CopyProperties(item, o);

						o.Parent = null;

						item.OnAfterDuped(o);

						if (item is Container && o is Container)
						{
							m.SendMessage("Duping Container Children...");
							DupeChildren(m, (Container)item, (Container)o);
						}

						if (pack != null)
						{
							pack.DropItem(o);
						}
						else
						{
							o.MoveToWorld(m.Location, m.Map);
						}

						o.UpdateTotals();
						o.InvalidateProperties();
						o.Delta(ItemDelta.Update);

						CommandLogging.WriteLine(
							m,
							"{0} {1} duped {2} creating {3}",
							m.AccessLevel,
							CommandLogging.Format(m),
							CommandLogging.Format(item),
							CommandLogging.Format(o));
					}

					if (!noCtor)
					{
						m.SendMessage("Done");
						done = true;
					}
				}
				catch
				{
					m.SendMessage("Error!");
					return;
				}

				if (!done)
				{
					m.SendMessage("Unable to dupe.  Item must have a 0 parameter constructor.");
				}
				else
				{
					item.Delta(ItemDelta.Update);
				}
			}
		}

		public static Item DupeItem(Item item)
		{
			return DupeItem(null, item);
		}

		public static Item DupeItem(Mobile m, Item item)
		{
			try
			{
				var t = item.GetType();

				if (m != null)
				{
					var a = t.GetCustomAttributes<ConstructableAttribute>(false);

					if (a != null && a.Length > 0 && a.Any(ca => ca.AccessLevel > m.AccessLevel))
					{
						return null;
					}
				}

				var o = t.CreateInstanceSafe<Item>();

				if (o == null)
				{
					return null;
				}

				CopyProperties(item, o);

				o.Parent = null;

				item.OnAfterDuped(o);

				if (item is Container && o is Container)
				{
					DupeChildren(m, (Container)item, (Container)o);
				}

				if (m != null)
				{
					o.MoveToWorld(m.Location, m.Map);

					o.UpdateTotals();
					o.InvalidateProperties();
					o.Delta(ItemDelta.Update);

					CommandLogging.WriteLine(m, "{0} {1} duped {2} creating {3}", m.AccessLevel, CommandLogging.Format(m),
											 CommandLogging.Format(item), CommandLogging.Format(o));
				}

				item.Delta(ItemDelta.Update);

				return o;
			}
			catch
			{
				return null;
			}
		}

		public static void DupeChildren(Container src, Container dest)
		{
			DupeChildren(null, src, dest);
		}

		public static void DupeChildren(Mobile m, Container src, Container dest)
		{
			foreach (var item in src.Items)
			{
				try
				{
					var t = item.GetType();

					if (m != null)
					{
						var a = t.GetCustomAttributes<ConstructableAttribute>(false);

						if (a != null && a.Length > 0 && a.Any(ca => ca.AccessLevel > m.AccessLevel))
						{
							continue;
						}
					}

					var o = t.CreateInstanceSafe<Item>();

					if (o == null)
					{
						continue;
					}

					CopyProperties(item, o);

					o.Parent = null;

					item.OnAfterDuped(o);

					if (item is Container && o is Container)
					{
						DupeChildren(m, (Container)item, (Container)o);
					}

					dest.DropItem(o);
					o.Location = item.Location;

					o.UpdateTotals();
					o.InvalidateProperties();
					o.Delta(ItemDelta.Update);

					CommandLogging.WriteLine(
						m,
						"{0} {1} duped {2} creating {3}",
						m.AccessLevel,
						CommandLogging.Format(m),
						CommandLogging.Format(item),
						CommandLogging.Format(o));

					item.Delta(ItemDelta.Update);
				}
				catch
				{ }
			}
		}

		public static void CopyProperties(Item src, Item dest)
		{
			var props = src.GetType().GetProperties();

			foreach (var p in props)
			{
				try
				{
					if (p.CanRead && p.CanWrite)
					{
						p.SetValue(dest, p.GetValue(src, null), null);
					}
				}
				catch
				{ }
			}
		}
	}
}
 
I tried this on a ver 54 server a modified copy of Land of Archon . I replaced the scripts\commands\dupe with this one server still complies but can not dupe a rewards box with items in it . Using Pandora's gift box is not an option as there are 4 version's I would like to give out .

There's only a few friends an family playing but would be nice to have abilities to dupe a chest of items .
 
I tried this on a ver 54 server a modified copy of Land of Archon . I replaced the scripts\commands\dupe with this one server still complies but can not dupe a rewards box with items in it . Using Pandora's gift box is not an option as there are 4 version's I would like to give out .

There's only a few friends an family playing but would be nice to have abilities to dupe a chest of items .

Take Dupe.cs from a later ServUO repository.
The changes were integrated into the main repository a while back.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back