CODE |
using System; using System.Collections; using Server; using Server.Items; using Server.Mobiles; using Server.Targeting; using Server.Gumps; using Server.Network; namespace Server.AdminCommands { 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 static void SendSecondCommand( CommandEventArgs e) { Mobile from = e.Mobile; from.Target = new SortDestination(); from.SendMessage("Select the bag to sort to"); } public class SortTarget : Target { public SortTarget() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object o ) { if (o is Item) { from.SendMessage(1150, o.ToString() ); } } } public class SortDestination : Target { public SortDestination() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object d ) { if (d is BaseContainer) { from.SendMessage(1150, d.ToString() ); } } } } } |
QUOTE |
public class SortTarget : Target { public SortTarget() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object o ) { if (o is Item) { from.SendMessage(1150, o.ToString() ); from.Target = new SortDestination(); } } } |
CODE |
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.AdminCommands { 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.SendMessage(1150, o.ToString() ); from.Target = new SortDestination(); from.SendMessage("Select the bag to sort to"); Container pack = from.Backpack; if ( pack != null ) { Item[] SortObjects = pack.FindItemsByType( typeof( o ));//Line 45 int i; for ( i=0; i < SortObjects.Length; ++i ) { SortObjects.parent[i] = new SortDestination();//Line 49 } ++i; //make i = number of sorted items from.SendMessage(1150, i.ToString(), " items sorted" ); } } } } public class SortDestination : Target { public SortDestination() : base( -1, true, TargetFlags.None ) { } protected override void OnTarget( Mobile from, object d ) { if (d is BaseContainer) { from.SendMessage(1150, d.ToString() ); } } } } } |
CODE |
Item[] SortObjects = pack.FindItemsByType(o.GetType());//Line 45 |
CODE |
SortObjects.parent[i] = new SortDestination();//Line 49 |
CODE |
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) { Bag bag = null; from.SendMessage(1150, o.ToString() ); from.Target = new SortDestination( from, o, bag ); from.SendMessage("Select the bag to sort to"); } } } public class SortDestination : Target { Bag bag = null; Mobile m = null; object thing = null; public SortDestination( Mobile m, object o, Bag bag ) : base( -1, true, TargetFlags.None ) { thing = o; m.SendMessage(1150, thing.ToString()); //have it here! } protected void OnTarget( Mobile m, Bag bag ) { Console.WriteLine("OnTarget entry");//not getting here at all m.SendMessage(1150, thing.ToString(), " Destination" );//no message here - second target shows and seems to select bag m.SendMessage(1150, bag.ToString() ); Container pack = m.Backpack; if ( pack != null ) { Item[] SortObjects = pack.FindItemsByType( thing.GetType()); int i; for ( i=0; i < SortObjects.Length; ++i ) { bag.DropItem( SortObjects[i]); } ++i; //make i = number of sorted items m.SendMessage(1150, i.ToString(), " items sorted" ); } } } } } |
CODE |
protected void OnTarget( Mobile m, Bag bag ) |
CODE |
protected override void OnTarget( Mobile from, object o ) |
QUOTE |
public class SortDestination : Target { Bag bag = null; Mobile m = null; object thing = null; public SortDestination( Mobile m, object o, Bag bag ) : base( -1, true, TargetFlags.None ) { thing = o; m.SendMessage(1150, thing.ToString()); //have it here! } |
CODE |
protected void OnTarget( Mobile m, object d ) { Console.WriteLine("OnTarget entry");//not getting here at all m.SendMessage(1150, thing.ToString(), " Destination" );//no message here - second target shows and seems to select bag m.SendMessage(1150, d.ToString() ); Container pack = m.Backpack; if ( pack != null & (d is Bag) ) { Item[] SortObjects = pack.FindItemsByType( thing.GetType()); int i; for ( i=0; i < SortObjects.Length; ++i ) { d.DropItem( SortObjects[i]); } ++i; //make i = number of sorted items m.SendMessage(1150, i.ToString(), " items sorted" ); } } |
CODE |
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.SendMessage(1150, o.ToString() ); from.Target = new SortDestination( from, o ); from.SendMessage("Select the bag to sort to"); } } } public class SortDestination : Target { Bag bag = null; Mobile m = null; object thing = null; public SortDestination( Mobile m, object o ) : base( -1, true, TargetFlags.None ) { thing = o; m.SendMessage(1150, thing.ToString()); //have it here! } protected void OnTarget( Mobile m, object d ) { Console.WriteLine("OnTarget entry");//not getting here at all m.SendMessage(1150, thing.ToString(), " Destination" );//no message here - second target shows and seems to select bag m.SendMessage(1150, d.ToString() ); Container pack = m.Backpack; bag = (Bag) d; if ( pack != null & (d is Bag) ) { Item[] SortObjects = pack.FindItemsByType( thing.GetType()); int i; for ( i=0; i < SortObjects.Length; ++i ) { bag.DropItem( SortObjects[i]); } ++i; //make i = number of sorted items m.SendMessage(1150, i.ToString(), " items sorted" ); } } } } } |
CODE |
protected void OnTarget( Mobile m, object d ) |
CODE |
protected override void OnTarget( Mobile m, object d ) |
CODE |
///Fafnir - [sortv0.1 31 Mar 2006 ///This command allows a player to move (sort) 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 { Bag 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 Bag; if ( pack != null & (d is Bag) ) { 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"); } } } } } |