Metro

Member
I'm not exactly sure how to ask my question, so I apologize in advance.

I am trying to create an item that functions as a container but the itemID (image) is something else entirely. Example, if I wanted the image of a table to function as a container and open a container gump when double clicked.

Here is portions of the code I have below. My problem is, when I reference the base for a chest or other actual container, everything works fine. When I change my base to that of a table for instance, the interaction breaks.

Code:
using Server;
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Mobiles;
using System;


namespace Server.Items
{

    [FlipableAddon(Direction.South, Direction.East)]
    public class MyContainerAddon : BaseAddonContainer
    {
        [Constructable]
        public MyContainerAddon() : base( 0x0ED5 )
        {
            Name = "MyContainer";
            Movable = false;
        }

        public override int DefaultGumpID
        {
            get
            {
                return 0x2658;
            }
        }

        public override void OnDoubleClick(Mobile from)
        {
        }

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

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

            writer.Write((int)0); // version
            writer.Write(m_Owner);  //Save the owner
        }

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

            int version = reader.ReadInt();
            m_Owner = reader.ReadMobile();
        }
    }
}

This is the script I am getting my inspiration from. The same thing happens when I change the base of this script to that of a table, the object stops acting like a container.

Code:
//Safety Deposit Box
//RunUO 2.0 Final & RunUO SVN
//By DxMonkey aka Tresdni & Fenris
/*
Simply place these around banks.  They are unmovable and show if they are unclaimed or not.  When a player double clicks
the box, and has enough to purchase it, the box will be assigned to them, and will open for them ONLY.  The purchase type
can be changed easily where marked.  It is set as default for 5,000 gold.
*/
using Server;
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Mobiles;
using System;


namespace Server.Items
{

[FlipableAttribute( 0xe41, 0xe40 )]
    public class SafetyDepositBox : BaseContainer
    {
    private Mobile m_Owner;
    Random random = new Random();
        [Constructable]
        public SafetyDepositBox() : base( 0xE41 )
        {
            Name = "An Unclaimed Safety Deposit Box [5,000 Gold]";
            Hue = random.Next(0, 1900);
            Movable = false;

        }

        public override void OnDoubleClick(Mobile from)
        {
            // set owner if not already set -- this is only done the first time.
            if ( m_Owner == null )
            {
                Item[] Token = from.Backpack.FindItemsByType( typeof( Gold ) );  //Search their backpack for item type, in this case - gold.
                    if ( from.Backpack.ConsumeTotal( typeof( Gold ), 5000 ) )  //Try to take 5,000 gold from their backpack.  If it does, it assigns the box to them.
                        {
                            m_Owner = from;
                            this.Name = m_Owner.Name.ToString() + "'s Safety Deposit Box";
                            from.SendMessage( "This safety deposit box has been assigned to you. 20,000 treasure tokens have been taken from your backpack." );
                        }
                        else
                            {
                                from.SendMessage( "You do not have enough treasure tokens to purchase the chest." );  //Gives them this message if they do not have that much gold in their pack.
                                return;
                            }   
            }
            else
            {
                if ( m_Owner != from )
                {
                    from.SendMessage( "This is not yours to use.  You should consider buying your own safety deposit box." );
                    return;
                }
            }
            base.OnDoubleClick( from );
        }
       
        public SafetyDepositBox( Serial serial ) : base( serial )
        {
        }

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

            writer.Write( (int) 0 ); // version
            writer.Write(m_Owner);  //Save the owner
        }

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

            int version = reader.ReadInt();
            m_Owner = reader.ReadMobile();
        }
    }
}
 
It must inherit BaseContainer, otherwise it will fail.
As for changing the interaction with a different graphic, i think it should work regardless of the itemid.
 
In my experience, a container must use a container image. Chests, boxes, baskets, drawers, anything that originally acted as a container.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back