Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;

namespace Server.Mobiles
{
	public class EggNogg : BaseCreature
	{
		Mobile mobile;
		
		public override bool CanTeach{ get{ return false; } }
		
		private static int GetRandomHue()
		{
			switch ( Utility.Random( 6 ) )
			{
				default:
				case 0: return 0;
				case 1: return Utility.RandomBlueHue();
				case 2: return Utility.RandomGreenHue();
				case 3: return Utility.RandomRedHue();
				case 4: return Utility.RandomYellowHue();
				case 5: return Utility.RandomNeutralHue();
			}
		}
		
		[Constructable]
		public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
		{
			InitStats( 31, 41, 51 );
			SpeechHue = Utility.RandomDyedHue();
			Hue = Utility.RandomSkinHue();
			
			if ( this.Female = Utility.RandomBool() )
			{
				this.Body = 0x191;
				this.Name = NameList.RandomName( "female" );
				Title = "EggNogg the Mage";
				SetSkill( SkillName.EvalInt, 65, 88 );
				SetSkill( SkillName.MagicResist, 65, 88 );
				SetSkill( SkillName.Magery, 65, 88 );
				SetSkill( SkillName.Wrestling, 60, 83 );
				SetSkill( SkillName.Meditation, 65, 88 );
			}
    		else
			{
				this.Body = 0x190;
				this.Name = NameList.RandomName( "male" );
				Title = "EggNogg the Mage";
				SetSkill( SkillName.EvalInt, 65, 88 );
				SetSkill( SkillName.Inscribe, 50, 65 );
				SetSkill( SkillName.MagicResist, 65, 88 );
				SetSkill( SkillName.Magery, 65, 88 );
				SetSkill( SkillName.Wrestling, 60, 83 );
				SetSkill( SkillName.Meditation, 65, 88 );
				
			}
			
			AddItem( new Server.Items.Robe( GetRandomHue() ) );
			AddItem( new Server.Items.Boots( GetRandomHue () ) );
                        this.AddItem(new Server.Items.GnarledStaff());
                        this.AddItem(new Cloak(0x597));


			Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
			
			hair.Hue = Utility.RandomNondyedHue();
			hair.Layer = Layer.Hair;
			hair.Movable = false;
			
			AddItem( hair );
			
			Container pack = new Backpack();
			
			pack.DropItem( new Gold( 250, 300 ) );
			
			pack.Movable = false;
			
			AddItem( pack );
		}
		public override bool ClickTitle{ get{ return false; } }
		
		public EggNogg( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			
			writer.Write( (int) 0 ); // version
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			
			int version = reader.ReadInt();
		}

		private Timer m_Timer;

		public class EggNoggTimer : Timer
		{
			private Moongate m_Gate;
			
			public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
			{
				m_Gate = gate;
				Priority = TimerPriority.OneSecond;
			}
			protected override void OnTick()
			{
				m_Gate.Delete();
				this.Stop();
			}
		}
		
		public override void OnSpeech( SpeechEventArgs m )
		{
			mobile = m.Mobile;
			PlayerMobile pm = (PlayerMobile)m.Mobile;
                        if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );
                      {
			if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
			{
				this.Direction =  GetDirectionTo( m.Mobile.Location );
				this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
				Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
				gate.MoveToWorld( mobile.Location, mobile.Map );
				
				if ( m_Timer != null )
					m_Timer.Stop();
				else
					m_Timer = new EggNoggTimer( gate );
				m_Timer.Start();
			}
			else
			{
                             
                              if ( pm != null && !pm.Young ); // if the player is a playermobile (sanity check) AND the player is not young AND the player isn't a staff member
                                {
				Container bank = m.Mobile.BankBox;
				if ( m.Speech.ToLower() == "gateme" )
				{
					this.Direction =  GetDirectionTo( m.Mobile.Location );
					this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
					if ( m.Speech.ToLower() == "yes" )
					{
						if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
						{
							this.Say( String.Format( "Very well. Here is the gate." ) );
							
							Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
							gate.MoveToWorld( mobile.Location, mobile.Map );
							
							if ( m_Timer != null )
								m_Timer.Stop();
							else
								m_Timer = new EggNoggTimer( gate );
							m_Timer.Start();
						}
						else
						{
							this.Say( String.Format( "You lack the funds for this gate." ) );
						}
					}
				}
				else if ( m.Speech.ToLower() == "no" )
				{
					this.Say( String.Format( "Very well." ) );
				}
}
}}}}
}
 
Hello,

I have been working with this script from which I do not know where it came from. What I am trying to accomplish here would be to enable the NPC to summon a travel gate to anyone. I'm almost certain the area i need to focus on is on line 132, if anyone could point me in the right direction would be helpful.





Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;

namespace Server.Mobiles
{
	public class EggNogg : BaseCreature
	{
		Mobile mobile;
		
		public override bool CanTeach{ get{ return false; } }
		
		private static int GetRandomHue()
		{
			switch ( Utility.Random( 6 ) )
			{
				default:
				case 0: return 0;
				case 1: return Utility.RandomBlueHue();
				case 2: return Utility.RandomGreenHue();
				case 3: return Utility.RandomRedHue();
				case 4: return Utility.RandomYellowHue();
				case 5: return Utility.RandomNeutralHue();
			}
		}
		
		[Constructable]
		public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
		{
			InitStats( 31, 41, 51 );
			SpeechHue = Utility.RandomDyedHue();
			Hue = Utility.RandomSkinHue();
			
			if ( this.Female = Utility.RandomBool() )
			{
				this.Body = 0x191;
				this.Name = NameList.RandomName( "female" );
				Title = "EggNogg the Mage";
				SetSkill( SkillName.EvalInt, 65, 88 );
				SetSkill( SkillName.MagicResist, 65, 88 );
				SetSkill( SkillName.Magery, 65, 88 );
				SetSkill( SkillName.Wrestling, 60, 83 );
				SetSkill( SkillName.Meditation, 65, 88 );
			}
    		else
			{
				this.Body = 0x190;
				this.Name = NameList.RandomName( "male" );
				Title = "EggNogg the Mage";
				SetSkill( SkillName.EvalInt, 65, 88 );
				SetSkill( SkillName.Inscribe, 50, 65 );
				SetSkill( SkillName.MagicResist, 65, 88 );
				SetSkill( SkillName.Magery, 65, 88 );
				SetSkill( SkillName.Wrestling, 60, 83 );
				SetSkill( SkillName.Meditation, 65, 88 );
				
			}
			
			AddItem( new Server.Items.Robe( GetRandomHue() ) );
			AddItem( new Server.Items.Boots( GetRandomHue () ) );
                        this.AddItem(new Server.Items.GnarledStaff());
                        this.AddItem(new Cloak(0x597));


			Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
			
			hair.Hue = Utility.RandomNondyedHue();
			hair.Layer = Layer.Hair;
			hair.Movable = false;
			
			AddItem( hair );
			
			Container pack = new Backpack();
			
			pack.DropItem( new Gold( 250, 300 ) );
			
			pack.Movable = false;
			
			AddItem( pack );
		}
		public override bool ClickTitle{ get{ return false; } }
		
		public EggNogg( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			
			writer.Write( (int) 0 ); // version
		}
		
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			
			int version = reader.ReadInt();
		}

		private Timer m_Timer;

		public class EggNoggTimer : Timer
		{
			private Moongate m_Gate;
			
			public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
			{
				m_Gate = gate;
				Priority = TimerPriority.OneSecond;
			}
			protected override void OnTick()
			{
				m_Gate.Delete();
				this.Stop();
			}
		}
		
		public override void OnSpeech( SpeechEventArgs m )
		{
			mobile = m.Mobile;
			PlayerMobile pm = (PlayerMobile)m.Mobile;
                        if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );
                      {
			if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
			{
				this.Direction =  GetDirectionTo( m.Mobile.Location );
				this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
				Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
				gate.MoveToWorld( mobile.Location, mobile.Map );
				
				if ( m_Timer != null )
					m_Timer.Stop();
				else
					m_Timer = new EggNoggTimer( gate );
				m_Timer.Start();
			}
			else
			{
                            
                              if ( pm != null && !pm.Young ); // if the player is a playermobile (sanity check) AND the player is not young AND the player isn't a staff member
                                {
				Container bank = m.Mobile.BankBox;
				if ( m.Speech.ToLower() == "gateme" )
				{
					this.Direction =  GetDirectionTo( m.Mobile.Location );
					this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
					if ( m.Speech.ToLower() == "yes" )
					{
						if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
						{
							this.Say( String.Format( "Very well. Here is the gate." ) );
							
							Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
							gate.MoveToWorld( mobile.Location, mobile.Map );
							
							if ( m_Timer != null )
								m_Timer.Stop();
							else
								m_Timer = new EggNoggTimer( gate );
							m_Timer.Start();
						}
						else
						{
							this.Say( String.Format( "You lack the funds for this gate." ) );
						}
					}
				}
				else if ( m.Speech.ToLower() == "no" )
				{
					this.Say( String.Format( "Very well." ) );
				}
}
}}}}
}
 
if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );

You've got a second check for young status above as well. You'll probably want to get rid of the profession checks too.
 
You've got a second check for young status above as well. You'll probably want to get rid of the profession checks too.

When I do remove these checks, causes many errors. I'm still trying to learn this though.
 
Last edited:
judging by the bundle of...braces?...on line 183 I was guessing there was a missing/misplaced one somewhere.

not sure what you're using to code, but I like Notepad++ which will highlight the brace that's connected to the one you highlight. makes for finding that stray really easy.

try this
*note: posted copy of file below if you don't want to copy/paste


C#:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;
namespace Server.Mobiles
{
  public class EggNogg : BaseCreature
  {
  Mobile mobile;
  
  public override bool CanTeach{ get{ return false; } }
  
  private static int GetRandomHue()
  {
  switch ( Utility.Random( 6 ) )
  {
  default:
  case 0: return 0;
  case 1: return Utility.RandomBlueHue();
  case 2: return Utility.RandomGreenHue();
  case 3: return Utility.RandomRedHue();
  case 4: return Utility.RandomYellowHue();
  case 5: return Utility.RandomNeutralHue();
  }
  }
  
  [Constructable]
  public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
  {
  InitStats( 31, 41, 51 );
  SpeechHue = Utility.RandomDyedHue();
  Hue = Utility.RandomSkinHue();
  
  if ( this.Female = Utility.RandomBool() )
  {
  this.Body = 0x191;
  this.Name = NameList.RandomName( "female" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  }
  else
  {
  this.Body = 0x190;
  this.Name = NameList.RandomName( "male" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.Inscribe, 50, 65 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  
  }
  
  AddItem( new Server.Items.Robe( GetRandomHue() ) );
  AddItem( new Server.Items.Boots( GetRandomHue () ) );
  AddItem(new Server.Items.GnarledStaff());
  AddItem(new Cloak());
  Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
  
  hair.Hue = Utility.RandomNondyedHue();
  hair.Layer = Layer.Hair;
  hair.Movable = false;
  
  AddItem( hair );
  
  Container pack = new Backpack();
  
  pack.DropItem( new Gold( 250, 300 ) );
  
  pack.Movable = false;
  
  AddItem( pack );
  }
    
  public override bool ClickTitle{ get{ return false; } }
  
  public EggNogg( Serial serial ) : base( serial )
  {
  }
  
  public override void Serialize( GenericWriter writer )
  {
  base.Serialize( writer );
  
  writer.Write( (int) 0 ); // version
  }
  
  public override void Deserialize( GenericReader reader )
  {
  base.Deserialize( reader );
  
  int version = reader.ReadInt();
  }
  private Timer m_Timer;
  public class EggNoggTimer : Timer
  {
  private Moongate m_Gate;
  
  public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
  {
  m_Gate = gate;
  Priority = TimerPriority.OneSecond;
  }
  protected override void OnTick()
  {
  m_Gate.Delete();
  this.Stop();
  }
  }
  
  public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
      
      
  if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );
  {
         if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
         {
           this.Direction =  GetDirectionTo( m.Mobile.Location );
           this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
           Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
           gate.MoveToWorld( mobile.Location, mobile.Map );
          
           if ( m_Timer != null )
             m_Timer.Stop();
           else
             m_Timer = new EggNoggTimer( gate );
           m_Timer.Start();
         }
       }
  else
  {
  
         if ( pm != null && !pm.Young ); // if the player is a playermobile (sanity check) AND the player is not young AND the player isn't a staff member
         {
             Container bank = m.Mobile.BankBox;
             if ( m.Speech.ToLower() == "gateme" )
             {
               this.Direction =  GetDirectionTo( m.Mobile.Location );
               this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
               if ( m.Speech.ToLower() == "yes" )
               {
                 if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
                 {
                   this.Say( String.Format( "Very well. Here is the gate." ) );
                  
                   Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
                   gate.MoveToWorld( mobile.Location, mobile.Map );
                  
                   if ( m_Timer != null )
                     m_Timer.Stop();
                   else
                     m_Timer = new EggNoggTimer( gate );
                   m_Timer.Start();
                 }
                 else
                 {
                   this.Say( String.Format( "You lack the funds for this gate." ) );
                 }
               }
             }
             else if ( m.Speech.ToLower() == "no" )
             {
               this.Say( String.Format( "Very well." ) );
             }
         }
       }
     }
   }
}
 

Attachments

  • eggnog for lemperor.cs
    6 KB · Views: 3
judging by the bundle of...braces?...on line 183 I was guessing there was a missing/misplaced one somewhere.

not sure what you're using to code, but I like Notepad++ which will highlight the brace that's connected to the one you highlight. makes for finding that stray really easy.

try this
*note: posted copy of file below if you don't want to copy/paste


C#:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;
namespace Server.Mobiles
{
  public class EggNogg : BaseCreature
  {
  Mobile mobile;
 
  public override bool CanTeach{ get{ return false; } }
 
  private static int GetRandomHue()
  {
  switch ( Utility.Random( 6 ) )
  {
  default:
  case 0: return 0;
  case 1: return Utility.RandomBlueHue();
  case 2: return Utility.RandomGreenHue();
  case 3: return Utility.RandomRedHue();
  case 4: return Utility.RandomYellowHue();
  case 5: return Utility.RandomNeutralHue();
  }
  }
 
  [Constructable]
  public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
  {
  InitStats( 31, 41, 51 );
  SpeechHue = Utility.RandomDyedHue();
  Hue = Utility.RandomSkinHue();
 
  if ( this.Female = Utility.RandomBool() )
  {
  this.Body = 0x191;
  this.Name = NameList.RandomName( "female" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  }
  else
  {
  this.Body = 0x190;
  this.Name = NameList.RandomName( "male" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.Inscribe, 50, 65 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
 
  }
 
  AddItem( new Server.Items.Robe( GetRandomHue() ) );
  AddItem( new Server.Items.Boots( GetRandomHue () ) );
  AddItem(new Server.Items.GnarledStaff());
  AddItem(new Cloak());
  Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
 
  hair.Hue = Utility.RandomNondyedHue();
  hair.Layer = Layer.Hair;
  hair.Movable = false;
 
  AddItem( hair );
 
  Container pack = new Backpack();
 
  pack.DropItem( new Gold( 250, 300 ) );
 
  pack.Movable = false;
 
  AddItem( pack );
  }
   
  public override bool ClickTitle{ get{ return false; } }
 
  public EggNogg( Serial serial ) : base( serial )
  {
  }
 
  public override void Serialize( GenericWriter writer )
  {
  base.Serialize( writer );
 
  writer.Write( (int) 0 ); // version
  }
 
  public override void Deserialize( GenericReader reader )
  {
  base.Deserialize( reader );
 
  int version = reader.ReadInt();
  }
  private Timer m_Timer;
  public class EggNoggTimer : Timer
  {
  private Moongate m_Gate;
 
  public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
  {
  m_Gate = gate;
  Priority = TimerPriority.OneSecond;
  }
  protected override void OnTick()
  {
  m_Gate.Delete();
  this.Stop();
  }
  }
 
  public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
     
     
  if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );
  {
         if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
         {
           this.Direction =  GetDirectionTo( m.Mobile.Location );
           this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
           Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
           gate.MoveToWorld( mobile.Location, mobile.Map );
         
           if ( m_Timer != null )
             m_Timer.Stop();
           else
             m_Timer = new EggNoggTimer( gate );
           m_Timer.Start();
         }
       }
  else
  {
 
         if ( pm != null && !pm.Young ); // if the player is a playermobile (sanity check) AND the player is not young AND the player isn't a staff member
         {
             Container bank = m.Mobile.BankBox;
             if ( m.Speech.ToLower() == "gateme" )
             {
               this.Direction =  GetDirectionTo( m.Mobile.Location );
               this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
               if ( m.Speech.ToLower() == "yes" )
               {
                 if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
                 {
                   this.Say( String.Format( "Very well. Here is the gate." ) );
                 
                   Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
                   gate.MoveToWorld( mobile.Location, mobile.Map );
                 
                   if ( m_Timer != null )
                     m_Timer.Stop();
                   else
                     m_Timer = new EggNoggTimer( gate );
                   m_Timer.Start();
                 }
                 else
                 {
                   this.Say( String.Format( "You lack the funds for this gate." ) );
                 }
               }
             }
             else if ( m.Speech.ToLower() == "no" )
             {
               this.Say( String.Format( "Very well." ) );
             }
         }
       }
     }
   }
}

I did try to compile the updated code you reposted for download with no success. Here is the error from the console in debug mode:

CS1525: Line 150: Invalid expression term 'else'
CS1002: Line 150: ; expected

Haven't seen this error before but willing to figure this out.
 
I haven't actually tested this but it shouldn't give you any errors now if it does please post the new errors and i will try and fix those for you..


Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;
namespace Server.Mobiles
{
    public class EggNogg : BaseCreature
    {
        Mobile mobile;
     
        public override bool CanTeach{ get{ return false; } }
     
        private static int GetRandomHue()
        {
            switch ( Utility.Random( 6 ) )
            {
                default:
                case 0: return 0;
                case 1: return Utility.RandomBlueHue();
                case 2: return Utility.RandomGreenHue();
                case 3: return Utility.RandomRedHue();
                case 4: return Utility.RandomYellowHue();
                case 5: return Utility.RandomNeutralHue();
            }
        }
     
        [Constructable]
        public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
        {
            InitStats( 31, 41, 51 );
            SpeechHue = Utility.RandomDyedHue();
            Hue = Utility.RandomSkinHue();
         
            if ( this.Female = Utility.RandomBool() )
            {
                this.Body = 0x191;
                this.Name = NameList.RandomName( "female" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
            }
            else
            {
                this.Body = 0x190;
                this.Name = NameList.RandomName( "male" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.Inscribe, 50, 65 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
             
            }
         
            AddItem( new Server.Items.Robe( GetRandomHue() ) );
            AddItem( new Server.Items.Boots( GetRandomHue () ) );
            AddItem(new Server.Items.GnarledStaff());
            AddItem(new Cloak());
            Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
         
            hair.Hue = Utility.RandomNondyedHue();
            hair.Layer = Layer.Hair;
            hair.Movable = false;
         
            AddItem( hair );
         
            Container pack = new Backpack();
         
            pack.DropItem( new Gold( 250, 300 ) );
         
            pack.Movable = false;
         
            AddItem( pack );
        }
		
        public override bool ClickTitle{ get{ return false; } }
     
        public EggNogg( Serial serial ) : base( serial )
        {
        }
     
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
         
            writer.Write( (int) 0 ); // version
        }
     
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
         
            int version = reader.ReadInt();
        }
        private Timer m_Timer;
        public class EggNoggTimer : Timer
        {
            private Moongate m_Gate;
         
            public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
            {
                m_Gate = gate;
                Priority = TimerPriority.OneSecond;
            }
            protected override void OnTick()
            {
                m_Gate.Delete();
                this.Stop();
            }
        }
     
        public override void OnSpeech( SpeechEventArgs m )
        {
            mobile = m.Mobile;
            PlayerMobile pm = (PlayerMobile)m.Mobile;
			
			
            if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
            {
				if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
				{
					this.Direction =  GetDirectionTo( m.Mobile.Location );
					this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
					Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
					gate.MoveToWorld( mobile.Location, mobile.Map );
				 
					if ( m_Timer != null )
						m_Timer.Stop();
					else
						m_Timer = new EggNoggTimer( gate );
					m_Timer.Start();
				}
			}
         
            {
                           
				if ( pm != null && !pm.Young )
				{
						Container bank = m.Mobile.BankBox;
						if ( m.Speech.ToLower() == "gateme" )
						{
							this.Direction =  GetDirectionTo( m.Mobile.Location );
							this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
							if ( m.Speech.ToLower() == "yes" )
							{
								if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
								{
									this.Say( String.Format( "Very well. Here is the gate." ) );
								 
									Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
									gate.MoveToWorld( mobile.Location, mobile.Map );
								 
									if ( m_Timer != null )
										m_Timer.Stop();
									else
										m_Timer = new EggNoggTimer( gate );
									m_Timer.Start();
								}
								else
								{
									this.Say( String.Format( "You lack the funds for this gate." ) );
								}
							}
						}
						else if ( m.Speech.ToLower() == "no" )
						{
							this.Say( String.Format( "Very well." ) );
						}
				}
			}
		}
	}
}
 
I haven't actually tested this but it shouldn't give you any errors now if it does please post the new errors and i will try and fix those for you..


Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;
namespace Server.Mobiles
{
    public class EggNogg : BaseCreature
    {
        Mobile mobile;
    
        public override bool CanTeach{ get{ return false; } }
    
        private static int GetRandomHue()
        {
            switch ( Utility.Random( 6 ) )
            {
                default:
                case 0: return 0;
                case 1: return Utility.RandomBlueHue();
                case 2: return Utility.RandomGreenHue();
                case 3: return Utility.RandomRedHue();
                case 4: return Utility.RandomYellowHue();
                case 5: return Utility.RandomNeutralHue();
            }
        }
    
        [Constructable]
        public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
        {
            InitStats( 31, 41, 51 );
            SpeechHue = Utility.RandomDyedHue();
            Hue = Utility.RandomSkinHue();
        
            if ( this.Female = Utility.RandomBool() )
            {
                this.Body = 0x191;
                this.Name = NameList.RandomName( "female" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
            }
            else
            {
                this.Body = 0x190;
                this.Name = NameList.RandomName( "male" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.Inscribe, 50, 65 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
            
            }
        
            AddItem( new Server.Items.Robe( GetRandomHue() ) );
            AddItem( new Server.Items.Boots( GetRandomHue () ) );
            AddItem(new Server.Items.GnarledStaff());
            AddItem(new Cloak());
            Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
        
            hair.Hue = Utility.RandomNondyedHue();
            hair.Layer = Layer.Hair;
            hair.Movable = false;
        
            AddItem( hair );
        
            Container pack = new Backpack();
        
            pack.DropItem( new Gold( 250, 300 ) );
        
            pack.Movable = false;
        
            AddItem( pack );
        }
		
        public override bool ClickTitle{ get{ return false; } }
    
        public EggNogg( Serial serial ) : base( serial )
        {
        }
    
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
        
            writer.Write( (int) 0 ); // version
        }
    
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
        
            int version = reader.ReadInt();
        }
        private Timer m_Timer;
        public class EggNoggTimer : Timer
        {
            private Moongate m_Gate;
        
            public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
            {
                m_Gate = gate;
                Priority = TimerPriority.OneSecond;
            }
            protected override void OnTick()
            {
                m_Gate.Delete();
                this.Stop();
            }
        }
    
        public override void OnSpeech( SpeechEventArgs m )
        {
            mobile = m.Mobile;
            PlayerMobile pm = (PlayerMobile)m.Mobile;
			
			
            if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
            {
				if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
				{
					this.Direction =  GetDirectionTo( m.Mobile.Location );
					this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
					Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
					gate.MoveToWorld( mobile.Location, mobile.Map );
				
					if ( m_Timer != null )
						m_Timer.Stop();
					else
						m_Timer = new EggNoggTimer( gate );
					m_Timer.Start();
				}
			}
        
            {
                          
				if ( pm != null && !pm.Young )
				{
						Container bank = m.Mobile.BankBox;
						if ( m.Speech.ToLower() == "gateme" )
						{
							this.Direction =  GetDirectionTo( m.Mobile.Location );
							this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
							if ( m.Speech.ToLower() == "yes" )
							{
								if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
								{
									this.Say( String.Format( "Very well. Here is the gate." ) );
								
									Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
									gate.MoveToWorld( mobile.Location, mobile.Map );
								
									if ( m_Timer != null )
										m_Timer.Stop();
									else
										m_Timer = new EggNoggTimer( gate );
									m_Timer.Start();
								}
								else
								{
									this.Say( String.Format( "You lack the funds for this gate." ) );
								}
							}
						}
						else if ( m.Speech.ToLower() == "no" )
						{
							this.Say( String.Format( "Very well." ) );
						}
				}
			}
		}
	}
}

Yes it compiles, I thank you. But, i'm back to the original problem. The NPC still won't send a gate to young players, I would like to remove the young status check and prefessions altogether. I'm slowly learning this.
 
You've got a second check for young status above as well. You'll probably want to get rid of the profession checks too.

Code:
if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 );

Code:
if(pm.IsPlayer())
 
I would like to remove the young status check and prefessions altogether.

Enroq gave you the two lines you need to remove, BUT, you can't just remove those two lines, because then you end up with two different options, one where the NPC charges gold to gate, and one where he doesn't.

I've blocked out the lines that have been removed, so you can see what I've changed
* putting a " // " before a line will block it out, meaning the line won't be used/compile
**note: do not use this code

C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
   
   
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
   
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  //}
   
  // {
   
  // if ( pm != null && !pm.Young )
  // {
  Container bank = m.Mobile.BankBox;
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
  if ( m.Speech.ToLower() == "yes" )
  {
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
   
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
   
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
  else if ( m.Speech.ToLower() == "no" )
  {
  this.Say( String.Format( "Very well." ) );
  }
  // }
  // }
  }

So, you want to have the gate be free, you'd change this section to


C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
   
   
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
   
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
     }

or if you want to charge
*I added in same lines to explain what's happening on certain lines. I love things like that when I'm learning code.


C#:
public override void OnSpeech( SpeechEventArgs m )
     {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
         
  Container bank = m.Mobile.BankBox;
             
             // player says gateme
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
               
               // npc says, i'll charge you, are you sure?
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
               
               // player agrees to charge
  if ( m.Speech.ToLower() == "yes" )
  {
                 // typeof( Gold ), 400 ) ) 400 is the amount of gold charged
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
   
                   // new Point3D( 5335, 1276, 47 ),Map.Trammel); the location that the gate is going to
                   // Point3D( X, Y, Z ),Map.Name);
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
   
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
                   // player doesn't have enough gold
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
             // player says no, i don't want you to charge me
  else if ( m.Speech.ToLower() == "no" )
  {
               // npc say, ok
  this.Say( String.Format( "Very well." ) );
  }
  }
 
Enroq gave you the two lines you need to remove, BUT, you can't just remove those two lines, because then you end up with two different options, one where the NPC charges gold to gate, and one where he doesn't.

I've blocked out the lines that have been removed, so you can see what I've changed
* putting a " // " before a line will block it out, meaning the line won't be used/compile
**note: do not use this code

C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
  
  
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
  
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  //}
  
  // {
  
  // if ( pm != null && !pm.Young )
  // {
  Container bank = m.Mobile.BankBox;
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
  if ( m.Speech.ToLower() == "yes" )
  {
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
  
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
  
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
  else if ( m.Speech.ToLower() == "no" )
  {
  this.Say( String.Format( "Very well." ) );
  }
  // }
  // }
  }

So, you want to have the gate be free, you'd change this section to


C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
  
  
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
  
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
     }

or if you want to charge
*I added in same lines to explain what's happening on certain lines. I love things like that when I'm learning code.


C#:
public override void OnSpeech( SpeechEventArgs m )
     {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
        
  Container bank = m.Mobile.BankBox;
            
             // player says gateme
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
              
               // npc says, i'll charge you, are you sure?
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
              
               // player agrees to charge
  if ( m.Speech.ToLower() == "yes" )
  {
                 // typeof( Gold ), 400 ) ) 400 is the amount of gold charged
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
  
                   // new Point3D( 5335, 1276, 47 ),Map.Trammel); the location that the gate is going to
                   // Point3D( X, Y, Z ),Map.Name);
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
  
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
                   // player doesn't have enough gold
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
             // player says no, i don't want you to charge me
  else if ( m.Speech.ToLower() == "no" )
  {
               // npc say, ok
  this.Say( String.Format( "Very well." ) );
  }
  }


I would like to thank Zerodowned and Enroq for both pointing me into the right direction with this script. I will dig into this once I get home tonight and update you with my progress. Once again, Thank you.
 
Enroq gave you the two lines you need to remove, BUT, you can't just remove those two lines, because then you end up with two different options, one where the NPC charges gold to gate, and one where he doesn't.

I've blocked out the lines that have been removed, so you can see what I've changed
* putting a " // " before a line will block it out, meaning the line won't be used/compile
**note: do not use this code

C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
 
 
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
 
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  //}
 
  // {
 
  // if ( pm != null && !pm.Young )
  // {
  Container bank = m.Mobile.BankBox;
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
  if ( m.Speech.ToLower() == "yes" )
  {
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
 
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
 
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
  else if ( m.Speech.ToLower() == "no" )
  {
  this.Say( String.Format( "Very well." ) );
  }
  // }
  // }
  }

So, you want to have the gate be free, you'd change this section to


C#:
public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
 
 
  // if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  //  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
 
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
     }

or if you want to charge
*I added in same lines to explain what's happening on certain lines. I love things like that when I'm learning code.


C#:
public override void OnSpeech( SpeechEventArgs m )
     {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
       
  Container bank = m.Mobile.BankBox;
           
             // player says gateme
  if ( m.Speech.ToLower() == "gateme" )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
             
               // npc says, i'll charge you, are you sure?
  this.Say( String.Format( "I can get you there for 400 gold coins. Do you agree to pay?" ) );
             
               // player agrees to charge
  if ( m.Speech.ToLower() == "yes" )
  {
                 // typeof( Gold ), 400 ) ) 400 is the amount of gold charged
  if ( bank != null && bank.ConsumeTotal( typeof( Gold ), 400 ) )
  {
  this.Say( String.Format( "Very well. Here is the gate." ) );
 
                   // new Point3D( 5335, 1276, 47 ),Map.Trammel); the location that the gate is going to
                   // Point3D( X, Y, Z ),Map.Name);
  Moongate gate = new Moongate( new Point3D( 5335, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
 
  if ( m_Timer != null )
  m_Timer.Stop();
  else
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  else
  {
                   // player doesn't have enough gold
  this.Say( String.Format( "You lack the funds for this gate." ) );
  }
  }
  }
             // player says no, i don't want you to charge me
  else if ( m.Speech.ToLower() == "no" )
  {
               // npc say, ok
  this.Say( String.Format( "Very well." ) );
  }
  }

Ok,
I've been working on this script to allow anyone who utters the special words would get a travel gate at no charge. I've read over your examples and came up with a version that compiles however, the npc still ignores regular players and when the npc sends a gate for staff members, it doesn't decay. I am very determined to get this script right, Here is the code.....

C#:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Items;
using Server.Regions;
using Server.Spells.Seventh;
using Server.Mobiles;
namespace Server.Mobiles
{
    public class EggNogg : BaseCreature
    {
        Mobile mobile;
    
        public override bool CanTeach{ get{ return false; } }
    
        private static int GetRandomHue()
        {
            switch ( Utility.Random( 6 ) )
            {
                default:
                case 0: return 0;
                case 1: return Utility.RandomBlueHue();
                case 2: return Utility.RandomGreenHue();
                case 3: return Utility.RandomRedHue();
                case 4: return Utility.RandomYellowHue();
                case 5: return Utility.RandomNeutralHue();
            }
        }
    
        [Constructable]
        public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
        {
            InitStats( 31, 41, 51 );
            SpeechHue = Utility.RandomDyedHue();
            Hue = Utility.RandomSkinHue();
        
            if ( this.Female = Utility.RandomBool() )
            {
                this.Body = 0x191;
                this.Name = NameList.RandomName( "female" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
            }
            else
            {
                this.Body = 0x190;
                this.Name = NameList.RandomName( "male" );
                Title = "EggNogg the Mage";
                SetSkill( SkillName.EvalInt, 65, 88 );
                SetSkill( SkillName.Inscribe, 50, 65 );
                SetSkill( SkillName.MagicResist, 65, 88 );
                SetSkill( SkillName.Magery, 65, 88 );
                SetSkill( SkillName.Wrestling, 60, 83 );
                SetSkill( SkillName.Meditation, 65, 88 );
            
            }
        
            AddItem( new Server.Items.Robe( GetRandomHue() ) );
            AddItem( new Server.Items.Boots( GetRandomHue () ) );
            AddItem(new Server.Items.GnarledStaff());
            AddItem(new Cloak());
            Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
        
            hair.Hue = Utility.RandomNondyedHue();
            hair.Layer = Layer.Hair;
            hair.Movable = false;
        
            AddItem( hair );
        
            Container pack = new Backpack();
        
            pack.DropItem( new Gold( 250, 300 ) );
        
            pack.Movable = false;
        
            AddItem( pack );
        }
      
        public override bool ClickTitle{ get{ return false; } }
    
        public EggNogg( Serial serial ) : base( serial )
        {
        }
    
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
        
            writer.Write( (int) 0 ); // version
        }
    
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
        
            int version = reader.ReadInt();
        }
        private Timer m_Timer;
        public class EggNoggTimer : Timer
        {
            private Moongate m_Gate;
        
            public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
            {
                m_Gate = gate;
                Priority = TimerPriority.OneSecond;
            }
            protected override void OnTick()
            {
                m_Gate.Delete();
                this.Stop();
            }
        }
    
        public override void OnSpeech( SpeechEventArgs m )
        {
            mobile = m.Mobile;
            PlayerMobile pm = (PlayerMobile)m.Mobile;
          
          
          //  if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
          {
                if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
                {
                    this.Direction =  GetDirectionTo( m.Mobile.Location );
                    this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
                    Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
                    gate.MoveToWorld( mobile.Location, mobile.Map );
                
                    if ( m_Timer != null )
                        m_Timer.Stop();
                    else
                        m_Timer = new EggNoggTimer( gate );
                    m_Timer.Start();
                }
           }
        
          
                     
                
                      
              
          
        }
    }
}
 
Ok, so basically what I did is moved the


    • if ( m_Timer != null )
    m_Timer.Stop();

Into it's own method

public override void OnAfterDelete()
{
if ( m_Timer != null )
m_Timer.Stop();

base.OnAfterDelete();
}

Otherwise when the gate is created, the code was saying if the timer ISN'T null, stop the timer. So that's why it wasn't deleting.

As for the staff/player issue, I had no problems with that. So the code you posted above already fixed it.

Here's the result

C#:
  using System;
  using System.Collections;
  using Server;
  using Server.Gumps;
  using Server.Network;
  using Server.Menus;
  using Server.Menus.Questions;
  using Server.Items;
  using Server.Regions;
  using Server.Spells.Seventh;
  using Server.Mobiles;
  namespace Server.Mobiles
  {
  public class EggNogg : BaseCreature
  {
  Mobile mobile;
   
  public override bool CanTeach{ get{ return false; } }
   
  private static int GetRandomHue()
  {
  switch ( Utility.Random( 6 ) )
  {
  default:
  case 0: return 0;
  case 1: return Utility.RandomBlueHue();
  case 2: return Utility.RandomGreenHue();
  case 3: return Utility.RandomRedHue();
  case 4: return Utility.RandomYellowHue();
  case 5: return Utility.RandomNeutralHue();
  }
  }
   
  [Constructable]
  public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
  {
  InitStats( 31, 41, 51 );
  SpeechHue = Utility.RandomDyedHue();
  Hue = Utility.RandomSkinHue();
   
  if ( this.Female = Utility.RandomBool() )
  {
  this.Body = 0x191;
  this.Name = NameList.RandomName( "female" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  }
  else
  {
  this.Body = 0x190;
  this.Name = NameList.RandomName( "male" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.Inscribe, 50, 65 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
   
  }
   
  AddItem( new Server.Items.Robe( GetRandomHue() ) );
  AddItem( new Server.Items.Boots( GetRandomHue () ) );
  AddItem(new Server.Items.GnarledStaff());
  AddItem(new Cloak());
  Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
   
  hair.Hue = Utility.RandomNondyedHue();
  hair.Layer = Layer.Hair;
  hair.Movable = false;
   
  AddItem( hair );
   
  Container pack = new Backpack();
   
  pack.DropItem( new Gold( 250, 300 ) );
   
  pack.Movable = false;
   
  AddItem( pack );
  }
   
  public override bool ClickTitle{ get{ return false; } }
   
  public EggNogg( Serial serial ) : base( serial )
  {
  }
   
  public override void Serialize( GenericWriter writer )
  {
  base.Serialize( writer );
   
  writer.Write( (int) 0 ); // version
  }
   
  public override void Deserialize( GenericReader reader )
  {
  base.Deserialize( reader );
   
  int version = reader.ReadInt();
  }
  private Timer m_Timer;
  public class EggNoggTimer : Timer
  {
  private Moongate m_Gate;
   
  public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
  {
  m_Gate = gate;
  Priority = TimerPriority.OneSecond;
  }
  protected override void OnTick()
  {
  m_Gate.Delete();
   
  }
  }
         
         // This checks the item, if it's deleted, is the timer still running? //If so, stop the timer.
         public override void OnAfterDelete()
         {
           if ( m_Timer != null )
             m_Timer.Stop();

           base.OnAfterDelete();
         }
   
  public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
   
   
  //  if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
   
  // Moved to OnAFterDelete   
               //   if ( m_Timer != null )
               //   m_Timer.Stop();
               
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  }
   
  }
  }
  }





 
Ok, so basically what I did is moved the



Into it's own method



Otherwise when the gate is created, the code was saying if the timer ISN'T null, stop the timer. So that's why it wasn't deleting.

As for the staff/player issue, I had no problems with that. So the code you posted above already fixed it.

Here's the result

C#:
  using System;
  using System.Collections;
  using Server;
  using Server.Gumps;
  using Server.Network;
  using Server.Menus;
  using Server.Menus.Questions;
  using Server.Items;
  using Server.Regions;
  using Server.Spells.Seventh;
  using Server.Mobiles;
  namespace Server.Mobiles
  {
  public class EggNogg : BaseCreature
  {
  Mobile mobile;
  
  public override bool CanTeach{ get{ return false; } }
  
  private static int GetRandomHue()
  {
  switch ( Utility.Random( 6 ) )
  {
  default:
  case 0: return 0;
  case 1: return Utility.RandomBlueHue();
  case 2: return Utility.RandomGreenHue();
  case 3: return Utility.RandomRedHue();
  case 4: return Utility.RandomYellowHue();
  case 5: return Utility.RandomNeutralHue();
  }
  }
  
  [Constructable]
  public EggNogg () : base( AIType.AI_Animal, FightMode.None, 10, 1, 0.2, 0.4 )
  {
  InitStats( 31, 41, 51 );
  SpeechHue = Utility.RandomDyedHue();
  Hue = Utility.RandomSkinHue();
  
  if ( this.Female = Utility.RandomBool() )
  {
  this.Body = 0x191;
  this.Name = NameList.RandomName( "female" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  }
  else
  {
  this.Body = 0x190;
  this.Name = NameList.RandomName( "male" );
  Title = "EggNogg the Mage";
  SetSkill( SkillName.EvalInt, 65, 88 );
  SetSkill( SkillName.Inscribe, 50, 65 );
  SetSkill( SkillName.MagicResist, 65, 88 );
  SetSkill( SkillName.Magery, 65, 88 );
  SetSkill( SkillName.Wrestling, 60, 83 );
  SetSkill( SkillName.Meditation, 65, 88 );
  
  }
  
  AddItem( new Server.Items.Robe( GetRandomHue() ) );
  AddItem( new Server.Items.Boots( GetRandomHue () ) );
  AddItem(new Server.Items.GnarledStaff());
  AddItem(new Cloak());
  Item hair = new Item( Utility.RandomList( 0x203B, 0x2049, 0x2048, 0x204A ) );
  
  hair.Hue = Utility.RandomNondyedHue();
  hair.Layer = Layer.Hair;
  hair.Movable = false;
  
  AddItem( hair );
  
  Container pack = new Backpack();
  
  pack.DropItem( new Gold( 250, 300 ) );
  
  pack.Movable = false;
  
  AddItem( pack );
  }
  
  public override bool ClickTitle{ get{ return false; } }
  
  public EggNogg( Serial serial ) : base( serial )
  {
  }
  
  public override void Serialize( GenericWriter writer )
  {
  base.Serialize( writer );
  
  writer.Write( (int) 0 ); // version
  }
  
  public override void Deserialize( GenericReader reader )
  {
  base.Deserialize( reader );
  
  int version = reader.ReadInt();
  }
  private Timer m_Timer;
  public class EggNoggTimer : Timer
  {
  private Moongate m_Gate;
  
  public EggNoggTimer( Moongate gate ) : base( TimeSpan.FromSeconds( 10.0 ) )
  {
  m_Gate = gate;
  Priority = TimerPriority.OneSecond;
  }
  protected override void OnTick()
  {
  m_Gate.Delete();
  
  }
  }
        
         // This checks the item, if it's deleted, is the timer still running? //If so, stop the timer.
         public override void OnAfterDelete()
         {
           if ( m_Timer != null )
             m_Timer.Stop();

           base.OnAfterDelete();
         }
  
  public override void OnSpeech( SpeechEventArgs m )
  {
  mobile = m.Mobile;
  PlayerMobile pm = (PlayerMobile)m.Mobile;
  
  
  //  if (pm.Young && pm.IsPlayer() && pm.Profession == 4 && pm.Profession == 6 && pm.Profession == 7 )
  {
  if ( m.Speech.ToLower() == "gateme" ) //&& pm.Young )
  {
  this.Direction =  GetDirectionTo( m.Mobile.Location );
  this.Say( String.Format( "Ah, you must be new around here. Here's the gate, free of charge." ) );
  Moongate gate = new Moongate( new Point3D( 5535, 1276, 47 ),Map.Trammel);
  gate.MoveToWorld( mobile.Location, mobile.Map );
  
  // Moved to OnAFterDelete  
               //   if ( m_Timer != null )
               //   m_Timer.Stop();
              
  m_Timer = new EggNoggTimer( gate );
  m_Timer.Start();
  }
  }
  
  }
  }
  }




After further testing, your other method for the gate timer works perfectly!! Although, I am still having the same issue with the npc responding to staff but ignoring new players. Am using the same code you changed earlier.
 
Back