RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Same Parameter Types Error

Krystyl_Rose

Wanderer
correct me if I am wrong.... but this:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
is referring to a null reference? which is not in.... I DID have one in awhile back when I first started this.... but then I wasnt sure it belonged in so I took it out and it compiled fine so I never put it back...
 

Packer898

Knight
I honestly dont know. I just changed it around some more. Check the post above and try that one. It either doesnt like deleting the deed there or the CloseGUmp thing. I dont know which is causing the error though =(
 

Packer898

Knight
I just tried this one on my shard and it works perfectly.
Code:
using System;
using System.Net;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
using Server.Mobiles;
using Server.Prompts;
using Server.Targeting;

namespace Server.Items
{
	public class EtherealMountDeed : Item
	{
		
		[Constructable]
		public EtherealMountDeed() : base ( 0x14F0 )
		{
			Name = "Ethereal Mount Deed";
			Weight = 1.0;
			LootType = LootType.Blessed;
			Hue = 1150;
		}
		public EtherealMountDeed ( Serial serial ) : base ( serial )
		{
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
			else
			{
				from.SendGump( new EtherealMountGump( from ) );
				this.Delete();
			}
		}
		
		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();
		}
	}
	
	public class EtherealMountGump : Gump
	{
		private Mobile m_From;
		private EtherealMountDeed m_Deed;
		
		public EtherealMountGump( Mobile owner ) : base( 30, 20 )
		{
			
			
			AddPage ( 1 );
			
			AddBackground( 0, 0, 300, 400, 5054 );
			AddBackground( 8, 8, 284, 384, 3000 );
			
			AddLabel( 40, 12, 0, "Ethereal List" );
			
			AddLabel( 52, 40, 0, "Ethereal Horse" );
			AddButton( 12, 40, 4005, 4007, 1, GumpButtonType.Reply, 1 );
			AddLabel( 52, 60, 0, "Ethereal Llama" );
			AddButton( 12, 60, 4005, 4007, 2, GumpButtonType.Reply, 2 );
			AddLabel( 52, 80, 0, "Ethereal Ostard" );
			AddButton( 12, 80, 4005, 4007, 3, GumpButtonType.Reply, 3 );
			AddLabel( 52, 100, 0, "Ethereal Ridgeback" );
			AddButton( 12, 100, 4005, 4007, 4, GumpButtonType.Reply, 4 );
			AddLabel( 52, 120, 0, "Ethereal Unicorn" );
			AddButton( 12, 120, 4005, 4007, 5, GumpButtonType.Reply, 5 );
			AddLabel( 52, 140, 0, "Ethereal Beetle" );
			AddButton( 12, 140, 4005, 4007, 6, GumpButtonType.Reply, 6 );
			AddLabel( 52, 160, 0, "Ethereal Ki-Rin" );
			AddButton( 12, 160, 4005, 4007, 7, GumpButtonType.Reply, 7 );
			AddLabel( 52, 180, 0, "Ethereal Swamp Dragon" );
			AddButton( 12, 180, 4005, 4007, 8, GumpButtonType.Reply, 8 );
			AddLabel( 52, 200, 0, "Ethereal Hiryu" );
			AddButton( 12, 200, 4005, 4007, 9, GumpButtonType.Reply, 9 );
			AddLabel( 52, 220, 0, "Close" );
			AddButton( 12, 220, 4005, 4007, 0, GumpButtonType.Reply, 0 );
		}
		
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			
			switch ( info.ButtonID )
			{
				case 0: //Close Gump
					{
						from.AddToBackpack( new EtherealMountDeed() );
						from.SendMessage( "The deed has been replaced in your backpack." );
						break;
					}
				case 1: // Ethereal Horse
					{
						from.AddToBackpack( new EtherealHorse() );
						from.SendMessage( "An Ethereal Horse has been placed into your backpack." );
						break;
					}
				case 2: // Ethereal Llama
					{
						from.AddToBackpack( new EtherealLlama() );
						from.SendMessage( "An Ethereal Llama has been placed into your backpack." );
						break;
					}
				case 3: // Ethereal Ostard
					{
						from.AddToBackpack( new EtherealOstard() );
						from.SendMessage( "An Ethereal Ostard has been placed into your backpack." );
						break;
					}
				case 4: // Ethereal Ridgeback
					{
						from.AddToBackpack( new EtherealRidgeback() );
						from.SendMessage( "An Ethereal Ridgeback has been placed into your backpack." );
						break;
					}
				case 5: // Ethereal Unicorn
					{
						from.AddToBackpack( new EtherealUnicorn() );
						from.SendMessage( "An Ethereal Unicorn has been placed into your backpack." );
						break;
					}
				case 6: //Ethereal Beetle
					{
						from.AddToBackpack( new EtherealBeetle() );
						from.SendMessage( "An Ethereal Beetle has been placed into your backpack." );
						break;
					}
				case 7: //Ethereal Ki-Rin
					{
						from.AddToBackpack( new EtherealKirin() );
						from.SendMessage( "An Ethereal Ki-Rin has been placed into your backpack." );
						break;
					}
				case 8: //Ethereal Swamp Dragon
					{
						from.AddToBackpack( new EtherealSwampDragon() );
						from.SendMessage( "An Ethereal Swamp Dragon has been placed into your backpack." );
						break;
					}
				case 9: //Ethereal Hiryu
					{
						from.AddToBackpack( new EtherealHiryu() );
						from.SendMessage( "An Ethereal Hiryu has been placed into your backpack." );
						break;
					}
			}
		}
	}
}
 

Krystyl_Rose

Wanderer
I have no clue how you did it.... I will have to compare yours to mine now to see what it was but it works..... however... there is ONE small problem and I think I know how to fix it...




when you use the deed, if you click close (maybe couldnt decide on one) it deletes the deed and so you are left with no ethereal and no deed... will this work to fix that?

Code:
switch ( info.ButtonID )
			{
				case 0: //Close Gump
					{
						from.CloseGump( typeof( EtherealMountGump ) );
						from.AddToBackpack( new EtherealMountDeed() );
						break;
					}
				case 1: // Ethereal Horse
 

Packer898

Knight
Huh? The one in 43 works fine. I dont know why the other one wont though =( I had the same problem on mine when I made it. So I moved the Delete function to the deed and it worked, did the same thing here. Still too noob to know why though lol
 

Packer898

Knight
Krystyl_Rose said:
I have no clue how you did it.... I will have to compare yours to mine now to see what it was but it works..... however... there is ONE small problem and I think I know how to fix it...




when you use the deed, if you click close (maybe couldnt decide on one) it deletes the deed and so you are left with no ethereal and no deed... will this work to fix that?

Code:
switch ( info.ButtonID )
			{
				case 0: //Close Gump
					{
						from.CloseGump( typeof( EtherealMountGump ) );
						from.AddToBackpack( new EtherealMountDeed() );
						break;
					}
				case 1: // Ethereal Horse


Code:
				case 0: //Close Gump
					{
						from.AddToBackpack( new EtherealMountDeed() );
						from.SendMessage( "The deed has been replaced in your backpack." );
						break;
					}
 

Packer898

Knight
I could be wrong but I believe that using gump reply buttons you dont have to worry about closing the gump.

Kamo... Now then would you mind helping me figure out why the one below crashes... I dont see a reason why personally.
Code:
using System;
using System.Net;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
using Server.Mobiles;

namespace Server.Items
{
	public class EtherealMountDeed : Item
	{
		
		[Constructable]
		public EtherealMountDeed() : base ( 0x14F0 )
		{
			Name = "Ethereal Mount Deed";
			Weight = 1.0;
			LootType = LootType.Blessed;
			Hue = 1150;
		}
		public EtherealMountDeed ( Serial serial ) : base ( serial )
		{
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			}
			else
			{
				from.SendGump( new EtherealMountGump( from ) );
			}
		}
		
		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();
		}
	}
	
	public class EtherealMountGump : Gump
	{
		private Mobile m_From;
		private EtherealMountDeed m_Deed;
		
		public EtherealMountGump( Mobile owner ) : base( 30, 20 )
		{
			
			
			AddPage ( 1 );
			
			AddBackground( 0, 0, 300, 400, 5054 );
			AddBackground( 8, 8, 284, 384, 3000 );
			
			AddLabel( 40, 12, 0, "Ethereal List" );
			
			AddLabel( 52, 40, 0, "Ethereal Horse" );
			AddButton( 12, 40, 4005, 4007, 1, GumpButtonType.Reply, 1 );
			AddLabel( 52, 60, 0, "Ethereal Llama" );
			AddButton( 12, 60, 4005, 4007, 2, GumpButtonType.Reply, 2 );
			AddLabel( 52, 80, 0, "Ethereal Ostard" );
			AddButton( 12, 80, 4005, 4007, 3, GumpButtonType.Reply, 3 );
			AddLabel( 52, 100, 0, "Ethereal Ridgeback" );
			AddButton( 12, 100, 4005, 4007, 4, GumpButtonType.Reply, 4 );
			AddLabel( 52, 120, 0, "Ethereal Unicorn" );
			AddButton( 12, 120, 4005, 4007, 5, GumpButtonType.Reply, 5 );
			AddLabel( 52, 140, 0, "Ethereal Beetle" );
			AddButton( 12, 140, 4005, 4007, 6, GumpButtonType.Reply, 6 );
			AddLabel( 52, 160, 0, "Ethereal Ki-Rin" );
			AddButton( 12, 160, 4005, 4007, 7, GumpButtonType.Reply, 7 );
			AddLabel( 52, 180, 0, "Ethereal Swamp Dragon" );
			AddButton( 12, 180, 4005, 4007, 8, GumpButtonType.Reply, 8 );
			AddLabel( 52, 200, 0, "Ethereal Hiryu" );
			AddButton( 12, 200, 4005, 4007, 9, GumpButtonType.Reply, 9 );
			AddLabel( 52, 220, 0, "Close" );
			AddButton( 12, 220, 4005, 4007, 0, GumpButtonType.Reply, 0 );
		}
		
		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			
			switch ( info.ButtonID )
			{
				case 0: //Close Gump
					{
						from.CloseGump( typeof( EtherealMountGump ) );
						break;
					}
				case 1: // Ethereal Horse
					{
						from.AddToBackpack( new EtherealHorse() );
						from.SendMessage( "An Ethereal Horse has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 2: // Ethereal Llama
					{
						from.AddToBackpack( new EtherealLlama() );
						from.SendMessage( "An Ethereal Llama has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 3: // Ethereal Ostard
					{
						from.AddToBackpack( new EtherealOstard() );
						from.SendMessage( "An Ethereal Ostard has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 4: // Ethereal Ridgeback
					{
						from.AddToBackpack( new EtherealRidgeback() );
						from.SendMessage( "An Ethereal Ridgeback has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 5: // Ethereal Unicorn
					{
						from.AddToBackpack( new EtherealUnicorn() );
						from.SendMessage( "An Ethereal Unicorn has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 6: //Ethereal Beetle
					{
						from.AddToBackpack( new EtherealBeetle() );
						from.SendMessage( "An Ethereal Beetle has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 7: //Ethereal Ki-Rin
					{
						from.AddToBackpack( new EtherealKirin() );
						from.SendMessage( "An Ethereal Ki-Rin has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 8: //Ethereal Swamp Dragon
					{
						from.AddToBackpack( new EtherealSwampDragon() );
						from.SendMessage( "An Ethereal Swamp Dragon has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
				case 9: //Ethereal Hiryu
					{
						from.AddToBackpack( new EtherealHiryu() );
						from.SendMessage( "An Ethereal Hiryu has been placed into your backpack." );
						from.CloseGump( typeof( EtherealMountGump ) );
						m_Deed.Delete();
						break;
					}
			}
		}
	}
}

Is it the m_Deed.Delete or is it the from.CloseGump part?
 
Now that the problem is solved :p
Code:
using System;
using System.Net;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
using Server.Mobiles;
using Server.Prompts;
using Server.Targeting;

namespace Server.Items
{
	public class EtherealMountDeed : Item
	{
		
		[Constructable]
		public EtherealMountDeed() : base ( 0x14F0 )
		{
			Name = "Ethereal Mount Deed";
			Weight = 1.0;
			LootType = LootType.Blessed;
			Hue = 1150;
		}
		public EtherealMountDeed ( Serial serial ) : base ( serial )
		{
		}
		
		public override void OnDoubleClick( Mobile from )
		{
			if ( !IsChildOf( from.Backpack ) )
				from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
			else
				from.SendGump( new EtherealMountGump( this ) );
		}
		
		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();
		}
	}
	
	public class EtherealMountGump : Gump
	{
		private EtherealMountDeed m_Deed;
		
		public EtherealMountGump( EtherealMountDeed deed ) : base( 30, 20 )
		{
			m_Deed = deed;
			
			AddPage ( 1 );
			
			AddBackground( 0, 0, 300, 400, 5054 );
			AddBackground( 8, 8, 284, 384, 3000 );
			
			AddLabel( 40, 12, 0, "Ethereal List" );
			
			AddLabel( 52, 40, 0, "Ethereal Horse" );
			AddButton( 12, 40, 4005, 4007, 1, GumpButtonType.Reply, 1 );
			AddLabel( 52, 60, 0, "Ethereal Llama" );
			AddButton( 12, 60, 4005, 4007, 2, GumpButtonType.Reply, 2 );
			AddLabel( 52, 80, 0, "Ethereal Ostard" );
			AddButton( 12, 80, 4005, 4007, 3, GumpButtonType.Reply, 3 );
			AddLabel( 52, 100, 0, "Ethereal Ridgeback" );
			AddButton( 12, 100, 4005, 4007, 4, GumpButtonType.Reply, 4 );
			AddLabel( 52, 120, 0, "Ethereal Unicorn" );
			AddButton( 12, 120, 4005, 4007, 5, GumpButtonType.Reply, 5 );
			AddLabel( 52, 140, 0, "Ethereal Beetle" );
			AddButton( 12, 140, 4005, 4007, 6, GumpButtonType.Reply, 6 );
			AddLabel( 52, 160, 0, "Ethereal Ki-Rin" );
			AddButton( 12, 160, 4005, 4007, 7, GumpButtonType.Reply, 7 );
			AddLabel( 52, 180, 0, "Ethereal Swamp Dragon" );
			AddButton( 12, 180, 4005, 4007, 8, GumpButtonType.Reply, 8 );
			AddLabel( 52, 200, 0, "Ethereal Hiryu" );
			AddButton( 12, 200, 4005, 4007, 9, GumpButtonType.Reply, 9 );
			AddLabel( 52, 220, 0, "Close" );
			AddButton( 12, 220, 4005, 4007, 0, GumpButtonType.Reply, 0 );
		}
		
		public override void OnResponse( NetState state, RelayInfo info )
		{
			if ( m_Deed.Deleted )
				return;
			Mobile from = state.Mobile;
			
			switch ( info.ButtonID )
			{
				case 0: //Close Gump
					{
						from.CloseGump( typeof( EtherealMountGump ) );
						break;
					}
				case 1: // Ethereal Horse
					{
						from.AddToBackpack( new EtherealHorse() );
						from.SendMessage( "An Ethereal Horse has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 2: // Ethereal Llama
					{
						from.AddToBackpack( new EtherealLlama() );
						from.SendMessage( "An Ethereal Llama has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 3: // Ethereal Ostard
					{
						from.AddToBackpack( new EtherealOstard() );
						from.SendMessage( "An Ethereal Ostard has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 4: // Ethereal Ridgeback
					{
						from.AddToBackpack( new EtherealRidgeback() );
						from.SendMessage( "An Ethereal Ridgeback has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 5: // Ethereal Unicorn
					{
						from.AddToBackpack( new EtherealUnicorn() );
						from.SendMessage( "An Ethereal Unicorn has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 6: //Ethereal Beetle
					{
						from.AddToBackpack( new EtherealBeetle() );
						from.SendMessage( "An Ethereal Beetle has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 7: //Ethereal Ki-Rin
					{
						from.AddToBackpack( new EtherealKirin() );
						from.SendMessage( "An Ethereal Ki-Rin has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 8: //Ethereal Swamp Dragon
					{
						from.AddToBackpack( new EtherealSwampDragon() );
						from.SendMessage( "An Ethereal Swamp Dragon has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
				case 9: //Ethereal Hiryu
					{
						from.AddToBackpack( new EtherealHiryu() );
						from.SendMessage( "An Ethereal Hiryu has been placed into your backpack." );
						m_Deed.Delete();
						break;
					}
			}
		}
	}
}
There is no need to have the Mobile from delivered to the gump, you don't even use it in there. And in your gump: If the player crashes/quits during gump open... oh well, won't happen soon. *lol*
 

Krystyl_Rose

Wanderer
Thank you SOOOOOOOO much!! the part I posted to fix the disappearing deed DID work so everything is now running smoothly once again.... thanks again I never would have figured that out on my own.... now I need to figure out WHY it works in the deed but not the gump...
 

Packer898

Knight
Hrmm in post #28 I had her comment out the from.CloseGump parts and it still crashed... Unless that got lost intranslation somewhere. That was my initial line of thinking for the crash since the gump closes automatically when you choose. Hrmm... That sucks LMAO

THanks Kamo I just learned some more good stuff =)- wOOt
 
your crashes were due to you deleting m_Deed WITHOUT ever seting it to something in the gump. The private variables don't set themselves you know. :p
 

Packer898

Knight
Kamuflaro said:
your crashes were due to you deleting m_Deed WITHOUT ever seting it to something in the gump. The private variables don't set themselves you know. :p

Yeha I saw that when I combined the two together was set to item or some shit =( lol
 

Packer898

Knight
Other problems as well... the private item m_Deed was also suspect. SHould have been private EtherealMountDeed m_Deed which i changed it to when I combined both gumps...

There was multiple problems and i wasnt smart enough to catch them all at once so thats why it took forever to get it lol
 
Code:
MyClass() : BaseClass
{
private AClass m_Instance;

public void MyMethod( AClass aclass )
{
m_Instance.Delete();
}

}
This above will crash you.
The following won't:
Code:
MyClass() : BaseClass
{
private AClass m_Instance;

public void MyMethod( AClass aclass )
{
if ( aclass == null )
return;
m_Instance = aclass;
m_Instance.Delete();
}

}

P.S. I fail to see, how the closegump could have caused a crash. :)
 

Packer898

Knight
OK.. Let me pick your brain real fast...

Code:
MyClass() : BaseClass
{
private AClass m_Instance;

public void MyMethod( AClass aclass )
{
if ( aclass == null )
return;
m_Instance = aclass;[COLOR="Red"]<--- WOuld you have to declare this again since its declared in the private AClass and again in MyMethod? If so why? I understand checking for null but not this. =)-[/COLOR]
m_Instance.Delete();
}

}
 
I was too lazy to make the method a subclass and in that a method, where I call it, but it shows, what makes the crash, doesn't it? :( ( With call it I meant deleting aclass through the m_Instance )
 
Top