CODE |
///Fafnir - [sortv0.2 31 Mar 2006 ///This command allows a player to move any number of items in their pack ///into a sub pack. /// ///My thanks to Arte Gordon for his patient coding aid to this newbie scripter! using System; using System.Collections; using Server; using Server.Items; using Server.Mobiles; using Server.Targeting; using Server.Misc; using Server.Prompts; using Server.ContextMenus; using Server.Multis; namespace Server.Scripts.Commands { public class Command { public static void Initialize() { Server.Commands.Register( "Sort", AccessLevel.Player, new CommandEventHandler( SendCommand ) ); } [Usage( "Sort" )] public static void SendCommand( CommandEventArgs e ) { Mobile from = e.Mobile; from.Target = new SortTarget(); from.SendMessage("Select the item to Sort"); } public class SortTarget : Target { public SortTarget() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object o ) { if ( o is Item) { from.Target = new SortDestination( from, o ); from.SendMessage("Select the bag to Sort to"); } } } public class SortDestination : Target { Container bag = null; Mobile m = null; object thing = null; public SortDestination( Mobile m, object o ) : base( -1, true, TargetFlags.None ) { thing = o; } protected override void OnTarget( Mobile m, object d ) { Container pack = m.Backpack; bag = d as Container; if ( pack != null && bag != null) { Item[] SortObjects = pack.FindItemsByType( thing.GetType()); int i; for ( i=0; i < SortObjects.Length; ++i ) { bag.DropItem( SortObjects[i]); } m.SendMessage(1150, i.ToString()); m.SendMessage(1150, "items moved"); } } } } } |
CODE |
for ( i=0; i < SortObjects.Length; ++i ) { bag.TryDropItem( m, SortObjects[i], false); } |
CODE |
for ( i=0; i < SortObjects.Length; ++i ) { bag.TryDropItem( m, SortObjects[i], false); public override bool TryDropItem( Mobile from, Item dropped, bool sendFullMessage("Failed to Move object. Please try again.") } |
CODE |
public override bool TryDropItem( Mobile from, Item dropped, bool sendFullMessage("Failed to Move object. Please try again.") |