CODE |
if ( pack != null & (d is Bag) ) |
CODE |
if ( pack != null && bag != null ) |
CODE |
bag = d as Bag; |
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 |
bag.DropItem( SortObjects[i]); |
CODE |
bag.TryDropItem( SortObjects[i]); |
QUOTE |
- Error: Scripts\Custom\Commands\SortCommand.cs: CS1501: (line 70, column 6) No overload for method 'TryDropItem' takes '1' arguments |
CODE |
public virtual bool TryDropItem( Mobile from, Item dropped, bool sendFullMessage ) |
CODE |
///Fafnir - [sortv0.3 31 Mar 2006 ///This command allows a player to move any number of items in their pack ///into a sub pack. ///Version .03 Stackable items now will stack in the destination container ///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.TryDropItem( m, SortObjects[i], false); } m.SendMessage( i.ToString() + " items moved"); } } } } } |
CODE |
///Fafnir - [sortv0.4 4 Apr 2006 ///This command allows a player to move any number of items in their pack ///into a sub pack. ///Version .03 Stackable items now will stack in the destination container ///Version .04 Fixed a bug which was deleting any sorted items already in the destination container. Thanks Weiland for the catch! ///My thanks to Arte Gordon for his patient coding aid to this newbie scripter! using System; using Server; using Server.Items; using Server.Scripts.Commands; using Server.Targeting; 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; bool sendFullMessage; if ( pack != null && bag != null) { int i; Item[] SortObjectsinBag = bag.FindItemsByType( thing.GetType()); //see if any of the item are in bag for ( i=0; i < SortObjectsinBag.Length; ++i ) { pack.TryDropItem( m, SortObjectsinBag[i], false); //move items out of bag and into pack } Item[] SortObjects = pack.FindItemsByType( thing.GetType()); for ( i=0; i < SortObjects.Length; ++i ) { bag.TryDropItem( m, SortObjects[i], false);//move them all back to bag } m.SendMessage( i.ToString() + " items moved"); } } } } } |
QUOTE |
- Warning: Scripts\Custom\Commands\SortCommand.cs: CS0168: (line 62, column 8) The variable 'sendFullMessage' is declared but never used |