ServUO Version
Publish Unknown
Ultima Expansion
Endless Journey
Perhaps someone can help me, I am trying to delete a deed on gump reponse but am getting a crash, here is the gump and related crash log.

C#:
    public class BreedingAcceptGumpInstant : Gump
    {
        private Mobile m_Pet1;
        private Mobile m_Pet2;
        private InstantBreedDeed m_Deed;

        public BreedingAcceptGumpInstant(Mobile pet1, Mobile pet2) : base(0, 0)
        {
            InstantBreedDeed deed = m_Deed as InstantBreedDeed;
            m_Pet1 = pet1;
            m_Pet2 = pet2;


                    if (bc1 != null || bc2 != null)
                    {
                        //bc1.MatingDelay = DateTime.UtcNow + TimeSpan.FromHours(144.0);
                        //bc2.MatingDelay = DateTime.UtcNow + TimeSpan.FromHours(144.0);
                        bc1.MatingDelay = DateTime.UtcNow + TimeSpan.FromSeconds( 0.1 );
                        bc2.MatingDelay = DateTime.UtcNow + TimeSpan.FromSeconds( 0.1 );
                    }
                    m_Deed.Delete(); // Delete the deed

        }
    }

C#:
    Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Items.BreedingAcceptGumpInstnat.OnResponse(NetState state, RelayInfo info)
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc) in C:\ServUO\Server\Network\PacketHandlers.cs:line 1457
   at Knives.TownHouses.GumpResponse.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns) in C:\ServUO\Server\Network\MessagePump.cs:line 347
   at Server.Network.MessagePump.Slice() in C:\ServUO\Server\Network\MessagePump.cs:line 136
   at Server.Core.Main(String[] args) in C:\ServUO\Server\Main.cs:line 676

From testing it is crashing on this:
C#:
m_Deed.Delete(); // Delete the deed
 
Last edited:
C#:
InstantBreedDeed deed = m_Deed as InstantBreedDeed;
You've tried to inititialize variable for deed, but you don't have any reference on real deed.
You need to add additional param for deed in method signature and send deed as reference:
C#:
public BreedingAcceptGumpInstant(Mobile pet1, Mobile pet2, InstantBreedDeed  deed) : base(0, 0)
m_Deed = deed;
....
Also would be better to place checks at the beginning of the method, to define if we have all entries to start work with them.
First need to check if deed is still not deleted and player contains it in pack.
Then check if m_Pet1 and m_Pet2 != null and they have control master.
and check if Breeder's standing in radius.
 
Last edited:
C#:
InstantBreedDeed deed = m_Deed as InstantBreedDeed;
You've tried to inititialize variable for deed, but you don't have any reference on real deed.
You need to add additional param for deed in method signature and send deed as reference:
C#:
public BreedingAcceptGumpInstant(Mobile pet1, Mobile pet2, InstantBreedDeed  deed) : base(0, 0)
m_Deed = deed;
....
Also would be better to place checks at the beginning of the method, to define if we have all entries to start work with them.
First need to check if deed is still not deleted and player contains it in pack.
Then check if m_Pet1 and m_Pet2 != null and they have control master.
and check if Breeder's standing in radius.
I tried something similar to this but then I get the following, I know I can fix line 261 but unsure how to fix line 149..
C#:
C:\ServUO\Scripts\Custom\Custom Systems\FS-ATS Gen2\Advanced Pet System\Items\InstantBreedDeed.cs(149,40): error CS7036: There is no argument given that corresponds to the required formal parameter 'deed' of 'BreedingAcceptGumpInstant.BreedingAcceptGumpInstant(Mobile, Mobile, InstantBreedDeed)' [C:\ServUO\Scripts\Scripts.csproj]
C:\ServUO\Scripts\Custom\Custom Systems\FS-ATS Gen2\Advanced Pet System\Items\InstantBreedDeed.cs(261,35): error CS7036: There is no argument given that corresponds to the required formal parameter 'deed' of 'BreedingAcceptGumpInstant.BreedingAcceptGumpInstant(Mobile, Mobile, InstantBreedDeed)' [C:\ServUO\Scripts\Scripts.csproj]
 
Last edited:
You will need to pass the deed reference along, you cant just create a null variable, cast it to your deed and have it work, since it is still null.

So from the point you have the reference to the deed, pass it along the way to where you need to access it
 
You will need to pass the deed reference along, you cant just create a null variable, cast it to your deed and have it work, since it is still null.

So from the point you have the reference to the deed, pass it along the way to where you need to access it
Oh my you've lost me lol, I am just trying to fix the script and clean it up I never wrote it so I was only half sure what was wrong with it not how to fix it haha.. .I will continue to play around with it though and use some other scripts for reference..
 
What @PyrO is saying is on line 53 when you call BeginMatingTarget1, you need to pass the deed parameter to it.
Currently you're only passing "t" the targeted creature to BeginMatingTarget1
 
Yeah I ended up doing the following but haven't tested it yet:
C#:
Redacted

Welp that didn't work lol, crashed with:
C#:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Items.BreedingAcceptGumpInstant.OnResponse(NetState state, RelayInfo info)
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc) in C:\ServUO\Server\Network\PacketHandlers.cs:line 1457
   at Knives.TownHouses.GumpResponse.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns) in C:\ServUO\Server\Network\MessagePump.cs:line 347
   at Server.Network.MessagePump.Slice() in C:\ServUO\Server\Network\MessagePump.cs:line 136
   at Server.Core.Main(String[] args) in C:\ServUO\Server\Main.cs:line 676
 
Last edited:
Line 75,
public BeginMatingTarget1(BaseCreature pet, InstantBreedDeed deed) : base(10, false, TargetFlags.None)
{
m_Pet = pet;
}

you never set the private deed variable to the one you get from the parameter
 
what got you confused?

You define a space for a variable (private) in line 73

in line 75 you write the constructor with the parameter

but inside the constructor you do not set the variable you defined in line 73 with the parameter you have from line 75
 
Ok that was better for me to understand, I'm not a coder at all lol most of what I do is adding/changing or using snippets of other things to get what I need working. So thank you for that it was easier for me to understand when you explained it more! Also after adding in that part it seems to have worked, the deed deleted itself, no crashes and the pets were bred so thank you again.
 
Back