Im trying to change the Escort npc keywords to a custom one;



Code:
 public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);

            EDI dest = GetDestination();

            if (dest != null && !e.Handled && e.Mobile.InRange(this.Location, 3))
            {
                if (e.HasKeyword(0x1D)) // *destination*
                    e.Handled = SayDestinationTo(e.Mobile);
                else if (e.HasKeyword(0x1E)) // *i will take thee*
                    e.Handled = AcceptEscorter(e.Mobile);
            }
        }

This is my baaaaaaaaaaaad attempt:

Code:
          public static void EventSink_Speech(SpeechEventArgs args)
        {
            Mobile from = args.Mobile;

            if (from == null || from.Map == null || !from.Player) return;
           
             EDI dest = GetDestination();
            
             if (dest != null && args.Speech != null && args.Mobile.InRange(this.Location, 3) && args.Speech.ToLower() == "A donde quieres ir")
             args.Speech = SayDestinationTo(args.Mobile);

            else if (dest != null && args.Speech != null && args.Mobile.InRange(this.Location, 3) && args.Speech.ToLower() == "Ire contigo")
             args.Speech = AcceptEscorter(args.Mobile);
         
        }


errors


Errors:
+ Mobiles/Townfolk/BaseEscortable.cs:
CS0120: Line 187: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.GetDestination()'
CS0026: Line 189: Keyword 'this' is not valid in a static property, static m
ethod, or static field initializer
CS0120: Line 190: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.SayDestinationTo(Server.Mobil
e)'
CS0026: Line 192: Keyword 'this' is not valid in a static property, static m
ethod, or static field initializer
CS0120: Line 193: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.AcceptEscorter(Server.Mobile)
 
lol it's always the small things that you miss even after looking at it a hundred times

change: public static void
to: public override void
 
If you change the speech all to lower case, your current check will never be true because of your capital "A". Try this for the first if statement:
Code:
if (dest != null && args.Speech != null && args.Mobile.InRange(this.Location, 3) && args.Speech.ToLower().Contains("a donde quieres ir") )

Use a lower case "a" in "a donde quieres ir". Also, instead of checking to see if the speech is exactly "a donde quieres ir", you can check to see if the speech simply contains those words. That's how e.HasKeyWord works I believe. You may need to change the other if statement too.
 
Thanks to both of you for reply, im getting errors, this is what i have right now;


Code:
public static void EventSink_Speech(SpeechEventArgs args)
        {
            Mobile from = args.Mobile;

		    EDI dest = GetDestination();
		
                if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("destino"))
                    e.Handled = SayDestinationTo(e.Mobile);
                else if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("te llevo"))
                    e.Handled = AcceptEscorter(e.Mobile);
            }


Errors:
+ Mobiles/Townfolk/BaseEscortable.cs:
CS0120: Line 170: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.GetDestination()'
CS0103: Line 173: The name 'e' does not exist in the current context
CS0103: Line 173: The name 'e' does not exist in the current context
CS0103: Line 175: The name 'e' does not exist in the current context
CS0103: Line 175: The name 'e' does not exist in the current context




So trying to fix the errors this is what i currently have:



Code:
      public static void EventSink_Speech(SpeechEventArgs args)
        {
            Mobile from = args.Mobile;

            EDI dest = GetDestination();

                if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("destino"))
                    args.Handled = SayDestinationTo(args.Mobile);
                else if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("te llevo"))
                    args.Handled = AcceptEscorter(args.Mobile);
         
        }

new errors


Errors:
+ Mobiles/Townfolk/BaseEscortable.cs:
CS0120: Line 172: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.GetDestination()'
CS0120: Line 178: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.SayDestinationTo(Server.Mobil
e)'
CS0120: Line 180: An object reference is required for the non-static field,
method, or property 'Server.Mobiles.BaseEscortable.AcceptEscorter(Server.Mobile)


That non-static field always got me confused :confused:

Code:
////////////////////////////EDIT///////////////////////////

FIXED!



Code:
       public override void OnSpeech(SpeechEventArgs args)
        {
            base.OnSpeech(args);
            Mobile from = args.Mobile;

            EDI dest = GetDestination();

                if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("a donde quieres ir"))
                    args.Handled = SayDestinationTo(args.Mobile);
                else if (dest != null && args.Speech != null && args.Mobile.InRange(from.Location, 3) && args.Speech.ToLower().Contains("ire contigo"))
                    args.Handled = AcceptEscorter(args.Mobile);
          
        }

That compiled and worked

Thank u guys once again
 
Last edited:
Back