ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So I created a deed/gump taken mostly from the heritage token and I am trying to delete the deed on response, however I can't seem to figure out how to delete it.. anyone smarter than me want to take a look at this for me?

C#:
#region References
using System;
using Server;

using Server.Network;
using Server.Commands;
using System.Collections.Generic;
using Server.Items;
using Server.Gumps;
#endregion

namespace Server.Items
{
    public class ShieldChoiceToken : Item
    {
        [Constructable]
        public ShieldChoiceToken()
            : base(0x14F0)
        {
            LootType = LootType.Blessed;
            Weight = 1.0;
            Name = "Shield Choice Token";
        }

        public ShieldChoiceToken(Serial serial)
            : base(serial)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (this.IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(ShieldChoiceGump));
                from.SendGump(new ShieldChoiceGump(from));
            }
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }

        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            list.Add("<BASEFONT COLOR=#7CFC00>Use this to redeem your shield</BASEFONT>");
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();
        }
    }
}

namespace Server.Gumps
{
    public class ShieldChoiceGump : Gump
    {
        private readonly Mobile m_User;

        public static void Configure()
        {
            CommandSystem.Register("ShieldChoiceGump", AccessLevel.Administrator, e => DisplayTo(e.Mobile));
        }

        public static ShieldChoiceGump DisplayTo(Mobile user)
        {
            if (user == null || user.Deleted || !user.Player || user.NetState == null)
                return null;

            user.CloseGump(typeof(ShieldChoiceGump));

            var gump = new ShieldChoiceGump(user);

            user.SendGump(gump);

            return gump;
        }

        public Mobile User { get; }

        public ShieldChoiceGump(Mobile from)
            : base(0, 0)
        {
            m_User = from;

            AddPage(0);

            AddBackground(0, 0, 520, 145, 0x13BE);
            AddImageTiled(10, 10, 500, 20, 0xA40);
            AddImageTiled(10, 40, 500, 75, 0xA40);
            AddImageTiled(10, 114, 500, 20, 0xA40);
            AddAlphaRegion(10, 10, 500, 95);
            AddAlphaRegion(10, 114, 500, 20);
            AddButton(10, 114, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(45, 115, 160, 20, 1060051, 0x7FFF, false, false); // CANCEL
            AddLabel(14, 12, 1152, "Choose your item from the following:");

            AddPage(1);

            AddImageTiledButton(14, 44, 0x918, 0x919, 1, GumpButtonType.Reply, 0, 7030, 0x0, 18, 8);
            AddLabel(98, 44, 1152, "Heater Shield");
            AddImageTiledButton(264, 44, 0x918, 0x919, 2, GumpButtonType.Reply, 0, 43057, 0x0, 18, 12);
            AddLabel(348, 44, 1152, "Hildebrandt Shield");
        }

        public override void OnResponse(NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
                case 1:
                    sender.Mobile.AddToBackpack(new PlateShield());
                    break;
                case 2:
                    sender.Mobile.AddToBackpack(new HildebrandtShield());
                    break;
            }
        }
    }
}
 
C#:
#region References
using System;
using Server;

using Server.Network;
using Server.Commands;
using System.Collections.Generic;
using Server.Items;
using Server.Gumps;
#endregion

namespace Server.Items
{
    public class ShieldChoiceToken : Item
    {
        [Constructable]
        public ShieldChoiceToken()
            : base(0x14F0)
        {
            LootType = LootType.Blessed;
            Weight = 1.0;
            Name = "Shield Choice Token";
        }

        public ShieldChoiceToken(Serial serial)
            : base(serial)
        {
        }

        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
                ShieldChoiceGump.DisplayTo(from, this);
            else
                from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
        }

        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            list.Add("<BASEFONT COLOR=#7CFC00>Use this to redeem your shield<BASEFONT COLOR=#FFFFFF>");
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadEncodedInt();
        }
    }
}

namespace Server.Gumps
{
    public class ShieldChoiceGump : Gump
    {
        public static void Configure()
        {
            CommandSystem.Register("ShieldChoiceGump", AccessLevel.Administrator, e => DisplayTo(e.Mobile, null));
        }

        public static void DisplayTo(Mobile user, ShieldChoiceToken token)
        {
            if (user == null || user.Deleted || !user.Player || user.NetState == null)
                return;

            user.CloseGump(typeof(ShieldChoiceGump));
            user.SendGump(new ShieldChoiceGump(token));
        }

        public ShieldChoiceToken Token { get; }

        public ShieldChoiceGump(ShieldChoiceToken token)
            : base(0, 0)
        {
            Token = token;

            AddPage(0);

            AddBackground(0, 0, 520, 145, 0x13BE);
            AddImageTiled(10, 10, 500, 20, 0xA40);
            AddImageTiled(10, 40, 500, 75, 0xA40);
            AddImageTiled(10, 114, 500, 20, 0xA40);
            AddAlphaRegion(10, 10, 500, 95);
            AddAlphaRegion(10, 114, 500, 20);
            AddButton(10, 114, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(45, 115, 160, 20, 1060051, 0x7FFF, false, false); // CANCEL
            AddLabel(14, 12, 1152, "Choose your item from the following:");

            AddPage(1);

            AddImageTiledButton(14, 44, 0x918, 0x919, 1, GumpButtonType.Reply, 0, 7030, 0x0, 18, 8);
            AddLabel(98, 44, 1152, "Heater Shield");
            AddImageTiledButton(264, 44, 0x918, 0x919, 2, GumpButtonType.Reply, 0, 43057, 0x0, 18, 12);
            AddLabel(348, 44, 1152, "Hildebrandt Shield");
        }

        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 0)
                return;

            if (Token != null && !Token.IsChildOf(sender.Mobile.Backpack))
            {
                sender.Mobile.SendLocalizedMessage(1062334); // This item must be in your backpack to be used.
                return;
            }

            switch (info.ButtonID)
            {
                case 1: sender.Mobile.AddToBackpack(new PlateShield()); break;
                case 2: sender.Mobile.AddToBackpack(new HildebrandtShield()); break;
                default: return;
            }

            if (Token != null)
                Token.Consume();
        }
    }
}
 
I got this so had to change "state" to "sender", other than that it works like a charm! thank you sir!
C#:
error CS0103: The name 'state' does not exist in the current context
C#:
if (Token != null && !Token.IsChildOf(state.Mobile.Backpack))
 
I got this so had to change "state" to "sender", other than that it works like a charm! thank you sir!
C#:
error CS0103: The name 'state' does not exist in the current context
C#:
if (Token != null && !Token.IsChildOf(state.Mobile.Backpack))

That's what I get for writing code in the forum editor :D
 
Back