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!

Safety Deposit Box - Purchasable [RunUO 2.0 Final & SVN]

So this is Horrible... Been trying to do this for 6.5 hours... trying to teach myself as i go and look up stuff on the forums. Is this a very simple thing that i seem to just be missing? :/
 
Here is what i have so far. I could not get anywhere with what Lord_Greywolf posted with my limited knowledge. What i have here is taken partially from http://www.runuo.com/community/threads/account-bound-items.492910/

EDIT: I am trying to make the boxes work as a Shared Bank Account for all characters on one Account


Code:
//Safety Deposit Box
//RunUO 2.0 Final & RunUO SVN
//Original Script by DxMonkey aka Tresdni & Fenris
// Working script by 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 a_Account;
        private Mobile m_Owner;
        Random random = new Random();
        [Constructable]
        public SafetyDepositBox(string account, int itemID )
            : base(account, 0xE41)
        {
            Name = "An Unclaimed Safety Deposit Box [50,000 Gold]";
            Hue = random.Next(0, 1900);
            Movable = false;
            a_Account = account;
 
        }
        public SafetyDepositBox(Mobile a) : this(a.Account.Username)
        {
        }
/*      public SafetyDepositBox(string account, int itemID)
            : base( account, 0xe41, 0xe40 )
        {
        } */
 
        public override bool IsDecoContainer
        {
            get { return 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), 50000))  //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. 50,000 gold has been taken from your backpack.");
                }
                else
                {
                    from.SendMessage("You do not have enough gold 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)
                {
                    if (from.AccessLevel > AccessLevel.Player || from.InRange(this.GetWorldLocation(), 2) || this.RootParent is PlayerVendor)
                    {
                        Open(from);
                        return;
                    }
                    else
                    {
                        from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    }
                    return;
                }
 
                else if (m_Owner != from)
                {
                    from.SendMessage("This is not yours to use.  You should consider buying your own safety deposit box.");
                    return;
                }
            }
            return;
 
        }
 
        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();
        }
    }
}

Errors:
+ _Custom/Safety Deposit Box/SafetyDepositBox.cs:
CS1501: Line 28: No overload for method 'BaseContainer' takes '2' arguments
CS0029: Line 35: Cannot implicitly convert type 'string' to 'Server.Mobile'
CS1502: Line 38: The best overloaded method match for 'Server.Items.SafetyDepositBox.SafetyDepositBox(Server.Mobile)' has some invalid arguments
CS1503: Line 38: Argument '1': cannot convert from 'string' to 'Server.Mobile'


Any Help be chance ? :D
 
those errors have nothing to do with what i posted
you need to remove account from the section where you are having the problem

as for what i posted, i said to change the variables to match those in the script (i have not even looked at the script until you posted it above)
change Owner in there to m_Owner for what i suggested
and it only goes in the ondoubleclick section replacing this part: if (m_Owner == from) so it looks like this:
if( from.Account.Username == m_Owner.Account.Username )

and make sure to put
using.Server.Accounting
at the top of the script also
 
Well I feel more like a Moron then before. Thank you Lord GreyWolf :)

Below is the Finished Script then incase anyone else wants to use it.

Price is Currently Set to 5k each.

Code:
//Safety Deposit Box
//RunUO 2.0 Final & RunUO SVN
//Original Script by DxMonkey aka Tresdni & Fenris
// Working script by 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 [50,000 Gold]";
            Hue = random.Next(0, 1900);
            Movable = false;
 
        }
 
        public override bool IsDecoContainer
        {
            get { return 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. 5,000 gold has been taken from your backpack.");
                }
                else
                {
                    from.SendMessage("You do not have enough gold to purchase the chest.");  //Gives them this message if they do not have that much gold in their pack.
                    return;
                }
            }
            else
            {
                if (from.Account.Username == m_Owner.Account.Username)
                {
                    if (from.AccessLevel > AccessLevel.Player || from.InRange(this.GetWorldLocation(), 2) || this.RootParent is PlayerVendor)
                    {
                        Open(from);
                        return;
                    }
                    else
                    {
                        from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    }
                    return;
                }
 
                else if (m_Owner != from)
                {
                    from.SendMessage("This is not yours to use.  You should consider buying your own safety deposit box.");
                    return;
                }
            }
            return;
 
           
        }
 
        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();
        }
    }
}
 
ok so i got it working for guilds... Except if a NON-Guilded character double clicks it the server crashes... I have the "Check if in guild" wrong i think.... Let me know how badly im butchering this eh?

Code:
//Safety Deposit Box
//RunUO 2.0 Final & RunUO SVN
//Original Script by DxMonkey aka Tresdni & Fenris
// Working script by 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 Server.Guilds;
using System;
 
 
namespace Server.Items
{
 
    [FlipableAttribute(0xe41, 0xe40)]
    public class GuildBox : BaseContainer
    {
        private Mobile m_Owner;
        Random random = new Random();
        [Constructable]
        public GuildBox()
            : base(0xE41)
        {
            Name = "An Unclaimed Guild Deposit Box [5,000 Gold & Account Bound]";
            Hue = random.Next(0, 999);
            Movable = false;
 
        }
 
        public override bool IsDecoContainer
        {
            get { return 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.Guild.Name.ToString() + "'s Safety Deposit Box";
                    from.SendMessage("This safety deposit box has been assigned to you. 5,000 gold has been taken from your backpack.");
                }
                else
                {
                    from.SendMessage("You do not have enough gold to purchase the chest.");  //Gives them this message if they do not have that much gold in their pack.
                    return;
                }
            }
            else
            {
                if (from.Guild.Name == m_Owner.Guild.Name)
                {
                    if (from.AccessLevel > AccessLevel.Player || from.InRange(this.GetWorldLocation(), 2) || this.RootParent is PlayerVendor)
                    {
                        Open(from);
                        return;
                    }
                    else
                    {
                        from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    }
                    return;
                }
 
                else if (m_Owner.Guild.Name == null)
                {
                    from.SendMessage("This is not yours to use.  You should consider buying your own safety deposit box.");
                    return;
                }
            }
            return;
 
           
        }
 
        public GuildBox(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();
        }
    }
}
 
need to check 1st that both (owner and person trying to use) belong to guilds
i.e. if (from.Guild != null && m_Owner.Guild != null && from.Guild.Name == m_Owner.Guild.Name)
the the else if of owner guild name == null - cjust change that to something like this
else from.SendMessage("You do not belong to this guild. You should consider buying your own safety deposit box.");
 
i am giving up on the guild box one. Its a Feature my Small server of less then 20 people will more then likely not use. I have Wasted a lot of time trying to teach myself how to make it check and even with your hint there i have failed :( On to the next script for me i guess.

Thank you though Lord_Grey Wolf
 
Top