Primo

So ,i've been tinkering this script for a custom string display on a player character, but as so i'm new to this i really dont know whats going on.
Heres the error on the console:
Custom Systems/customname.cs:
CS0246: Line 23: namespace or type 'Target" could not be found.
(its on portuguese)

And this is my code:
C#:
using System;
using System.Collections;
using System.IO;
using System.Text;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Commands;

namespace CustomName
{
    class Program
    {
        public static void Initialize()
        {
            CommandSystem.Register("r", AccessLevel.Player, new CommandEventHandler(CustomName_OnCommand));
        }

        public static void CustomName_OnCommand(CommandEventArgs r)
        {

            SendLocalizedMessage("Which name you with to give :");
            from.Target = new InternalTarget(this);


    }
}
 
Last edited by a moderator:
Okay, now great, my code does work and sends out a message when the player gives the [r command
C#:
using System;
using System.Collections;
using System.IO;
using System.Text;
using Server;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using Server.Commands;
using Server.Targeting;

namespace CustomName
{
    class CallCustomName
    {
        public static void Initialize()
        {
            CommandSystem.Register("r", AccessLevel.Player, new CommandEventHandler(CustomName_OnCommand));
        }
        [Usage("r")]
        [Description("Gives the custom name to a player")]
        public static void CustomName_OnCommand(CommandEventArgs args)
        {
            Mobile m = args.Mobile;          
            m.SendMessage("Choose who you wish to nominate:");
        
        }



        }
    }

But i didnt understand the target scheme. Couldnt call a single target for the player, and didnt quite understand it yet. So i basically need to add a class defining what the target do so i can send it together with the message?
----------------------------------------------------------------------------------
UPDATE
Now i managed to call up the target, the code is like this.
C#:
using System;
using System.Collections;
using System.IO;
using System.Text;
using Server;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
using Server.Commands;
using Server.Targeting;

namespace CustomName
{
    class CallCustomName
    {
        public static void Initialize()
        {
            CommandSystem.Register("r", AccessLevel.Player, new CommandEventHandler(CustomName_OnCommand));
        }
        [Usage("r")]
        [Description("Gives the custom name to a player")]
        public static void CustomName_OnCommand(CommandEventArgs args)
        {
            Mobile m = args.Mobile;
            m.SendMessage("Choose who you wish to nominate:");
            m.Target = new InternalTarget();

        }

        private class InternalTarget : Target
        {
            public InternalTarget()
                : base(8, false, TargetFlags.None)
            {
            }

            protected override void OnTarget(Mobile from, object targeted)
            {
                Mobile target;

                if (from is PlayerMobile && targeted is Mobile)
                {
                    if (targeted is PlayerMobile && ((PlayerMobile)targeted).Player)
                    {
                        from.SendMessage("Write the name you wish to call that person:");
                        return;
                    }


                }
            }
        }
    }
}

But now i need to know how to "read" what the player types and store it in a variable that the code reads, OR make any changes on the set Name X that makes that set name appears only to who set it.
 
Last edited by a moderator:
No problem, that function is built in to the command event structure.
See bolded and italicized below.
public static void CustomName_OnCommand(CommandEventArgs args)
{
Mobile m = args.Mobile;
m.SendMessage("Choose who you wish to nominate:");
string[] input = args.Arguments;
m.Target = new InternalTarget(input);
}

Arguments will return what ever they write after the command, so if its ]r F Scott Fitzgerald your string[] input will contain {"F","Scott","Fitzgerald"}

You'll probably want to do some kind of data validation on their arguments.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back