Hi everyone, i am trying to make the OSI buyable BOD Covers Token.

So far i got it to work but when i select a choice the bag doesn't drop.

If anyone is able to help that would be awesome. Thanks a lot!

upload_2016-3-27_3-51-59.png

Code:
using System;
using Server;
using Server.Network;
using Server.Engines.VeteranRewards;
using Server.Gumps;

namespace Server.Items
{
    public enum CoverBagType
    {
        Blacksmith = 100,
        Tailoring = 101
    }

    public class BODBookCoverBag : Bag, IRewardItem
    {
        private bool m_IsRewardItem;
        [Constructable]
        public BODBookCoverBag(CoverBagType type)
            : base()
        {
            switch ( type )
            {
                case CoverBagType.Blacksmith:
                        this.AddItem(new AgapiteBulkOrderCover());
                        this.AddItem(new BronzeBulkOrderCover());
                    break;
                case CoverBagType.Tailoring:
                        this.AddItem(new AgapiteBulkOrderCover());
                        this.AddItem(new BronzeBulkOrderCover());
                    break;
            }
        }

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

        [CommandProperty(AccessLevel.GameMaster)]
        public bool IsRewardItem
        {
            get
            {
                return this.m_IsRewardItem;
            }
            set
            {
                this.m_IsRewardItem = value;
                this.InvalidateProperties();
            }
        }
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.WriteEncodedInt(0); // version
           
            writer.Write((bool)this.m_IsRewardItem);
        }

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

            int version = reader.ReadEncodedInt();
           
            this.m_IsRewardItem = reader.ReadBool();
        }
    }

    public class BODBookCoverToken : Item, IRewardItem, IRewardOption
    {
        private CoverBagType m_BagType;
        private bool m_IsRewardItem;
        [Constructable]
        public BODBookCoverToken()
            : base(0x2AAA)
        {
            this.LootType = LootType.Blessed;
        }

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

        public override int LabelNumber
        {
            get
            {
                return 1070997;
            }
        }// A promotional token

        [CommandProperty(AccessLevel.GameMaster)]
        public bool IsRewardItem
        {
            get
            {
                return this.m_IsRewardItem;
            }
            set
            {
                this.m_IsRewardItem = value;
                this.InvalidateProperties();
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            if (this.m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null))
                return;
           
            if (this.IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(RewardOptionGump));
                from.SendGump(new RewardOptionGump(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(1070998,"BOD Book Covers"); // Use this to redeem<br>your ~1_PROMO~
           
            if (this.m_IsRewardItem)
                list.Add(1076218); // 2nd Year Veteran Reward
        }

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

            writer.WriteEncodedInt(0); // version

            writer.Write((bool)this.m_IsRewardItem);
        }

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

            int version = reader.ReadEncodedInt();
           
            this.m_IsRewardItem = reader.ReadBool();
        }

        public void GetOptions(RewardOptionList list)
        {
            list.Add((int)CoverBagType.Blacksmith, 1002043); // Blacksmith
            list.Add((int)CoverBagType.Tailoring, 1002155); // Tailoring
        }

        public void OnOptionSelected(Mobile from, int option)
        {
            this.m_BagType = (CoverBagType)option;

            if (!this.Deleted)
                base.OnDoubleClick(from);
        }
    }
}
 
Changed it but now getting errors:
Code:
--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 5923.33406
Publish 54
Core: Optimizing for 4 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Customs/Book Covers/BookCoverDeed.cs:
    CS0115: Line 18: 'Server.Items.BODBookCoverBag.Bag': no suitable method foun
d to override
    CS0115: Line 149: 'Server.Items.BODBookCoverToken.Token': no suitable method
found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Code:
using System;
using Server;
using Server.Network;
using Server.Engines.VeteranRewards;
using Server.Gumps;
using Server.Multis;

namespace Server.Items
{
    public enum CoverBagType
    {
        Blacksmith = 100,
        Tailoring = 101
    }

    public class BODBookCoverBag : BaseContainer, IRewardItem
    {
        public override BaseContainer Bag
        {
            get
            {
                BODBookCoverToken bag = new BODBookCoverToken();
                bag.IsRewardItem = this.m_IsRewardItem;
                bag.Blacksmith = this.m_Blacksmith;
                bag.Tailoring = this.m_Tailoring;

                return bag;
            }
        }

        private bool m_IsRewardItem;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool IsRewardItem
        {
            get
            {
                return this.m_IsRewardItem;
            }
            set
            {
                this.m_IsRewardItem = value;
            }
        }

        private MiningCartType m_BagType;

        [CommandProperty(AccessLevel.GameMaster)]
        public CoverBagType BagType
        {
            get
            {
                return this.m_BagType;
            }
        }

        private int m_Blacksmith;

        [CommandProperty(AccessLevel.GameMaster)]
        public int Blacksmith
        {
            get
            {
                return this.m_Blacksmith;
            }
            set
            {
                this.m_Blacksmith = value;
            }
        }

        private int m_Tailoring;

        [CommandProperty(AccessLevel.GameMaster)]
        public int Tailoring
        {
            get
            {
                return this.m_Tailoring;
            }
            set
            {
                this.m_Tailoring = value;
            }
        }
        [Constructable]
        public BODBookCoverBag(CoverBagType type)
            : base()
        {
            this.m_BagType = type;
            switch ( type )
            {
                case CoverBagType.Blacksmith:
                        this.AddItem(new AgapiteBulkOrderCover());
                        this.AddItem(new BronzeBulkOrderCover());
                    break;
                case CoverBagType.Tailoring:
                        this.AddItem(new AgapiteBulkOrderCover());
                        this.AddItem(new BronzeBulkOrderCover());
                    break;
            }
        }

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


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

            writer.WriteEncodedInt(1); // version

            #region version 1
            writer.Write((int)this.m_BagType);
            #endregion

            writer.Write((bool)this.m_IsRewardItem);
            writer.Write((int)this.m_Blacksmith);
            writer.Write((int)this.m_Tailor);
        }

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

            int version = reader.ReadEncodedInt();

            switch ( version )
            {
                case 1:
                    this.m_BagType = (CoverBagType)reader.ReadInt();
                    goto case 0;
                case 0:
                    this.m_IsRewardItem = reader.ReadBool();
                    this.m_Blacksmith = reader.ReadInt();
                    this.m_Tailoring = reader.ReadInt();

                    break;
            }
        }
    }

    public class BODBookCoverToken : Container, IRewardItem, IRewardOption
    {
        public override Container Token
        {
            get
            {
                BODBookCoverBag token = new BODBookCoverBag(this.m_BagType);
                token.IsRewardItem = this.m_IsRewardItem;
                token.Blacksmith = this.m_Blacksmith;
                token.Tailoring = this.m_Tailoring;

                return addon;
            }
        }


        private CoverBagType m_BagType;

        private bool m_IsRewardItem;

        [Constructable]
        public BODBookCoverToken()
            : base(0x2AAA)
        {
            this.Light = LightType.Circle300;
            this.LootType = LootType.Blessed;
        }

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

        public override int LabelNumber
        {
            get
            {
                return 1070997;
            }
        }// A promotional token

        [CommandProperty(AccessLevel.GameMaster)]
        public bool IsRewardItem
        {
            get
            {
                return this.m_IsRewardItem;
            }
            set
            {
                this.m_IsRewardItem = value;
                this.InvalidateProperties();
            }
        }
        public override void OnDoubleClick(Mobile from)
        {
            if (this.m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null))
                return;
           
            if (this.IsChildOf(from.Backpack))
            {
                from.CloseGump(typeof(RewardOptionGump));
                from.SendGump(new RewardOptionGump(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(1070998,"BOD Book Covers"); // Use this to redeem<br>your ~1_PROMO~
           
            if (this.m_IsRewardItem)
                list.Add(1076218); // 2nd Year Veteran Reward
        }

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

            writer.WriteEncodedInt(0); // version

            writer.Write((bool)this.m_IsRewardItem);
            writer.Write((int)this.m_Blacksmith);
            writer.Write((int)this.m_Tailoring);
        }

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

            int version = reader.ReadEncodedInt();
           
            this.m_IsRewardItem = reader.ReadBool();
        }

        public void GetOptions(RewardOptionList list)
        {
            list.Add((int)CoverBagType.Blacksmith, 1002043); // Blacksmith
            list.Add((int)CoverBagType.Tailoring, 1002155); // Tailoring
        }

        public void OnOptionSelected(Mobile from, int choice)
        {
            this.m_BagType = (CoverBagType)choice;

            if (!this.Deleted)
                base.OnDoubleClick(from);
        }
    }
}
 
If you want them to be overrideable in the future they need to be defined as virtual in that case
 
If you look at MiningCart.cs it is where i mostly made mine from and its not virtual there.

Thanks for your help, i am not really good at scripting but want to learn :)
 
Back