I am trying to generate a new command. I need to target a player and get their name. How would I get that using the following?

Code:
using System;
using Server;

namespace Server.Commands
{
    public class NewCommand
    {
        public static void Initialize()
        {
            CommandSystem.Register( "NewCommand", AccessLevel.Player, new CommandEventHandler( NewCommand_OnCommand ) );
        }

        private static void NewCommand_OnCommand( CommandEventArgs args )
        {
            args.Mobile.SendGump( new MyGump() );
        }
    }
}
 
Code:
private static void NewCommand_OnCommand( CommandEventArgs args )
        {
        Mobile from = args.Mobile;

        if(from!=null)
    {
        from.SendGump(new MyGump());
    }
                   }
 
C#:
args.Mobile.Target = new NewTarget( args.Mobile );

C#:
public class NewTarget : Target
{
    public Mobile Owner { get; private set; }

    public NewTarget( Mobile owner )
        : base( -1, false, TargetFlags.None )
    {
        Owner = owner;
    }

    protected override void OnTarget( object targeted )
    {
        base.OnTarget( targeted );

        if( targeted is Mobile )
        {
            Owner.SendMessage( "You targeted {0}!", ((Mobile)targeted).Name );
        }
    }
}
 
Back