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]

rtaylor1987

Sorceror
Just a heads-up, when I wrote the base script, I set the chests to be a random color when you add them - I figured this would add some rarity to the different boxes.

The hue can be removed/changed on line 29.

- R|Taylor (aka Fenris)
 

Garbastank

Wanderer
Possible Error

Came across this on playtest. Seems staff has no problem adding to a personalized security box....but when players try to add items to their own , It rejects it saying they arent the owner. When clearly, they are. (Says name on box and took 5k gold from them.) Any ideas?
 

Thagoras

Sorceror
Hey, So, I was at work thinking about the problems I will be facing playing my 2 characters on the Revelation server. How one will be a (mostly) pure mage and will have a hard time killin stuff for money and regs (when I need regs to get regs) when it occurred to me that one of the reasons why a person gets a house is because they need to transfer items from one character to the other. Then I was thinking about the possibilities of a joint bankbox and what I'd have to do to make such an item.

Then I remembered your Safety Deposit Box.

How much work do you think it would take to make the safety deposit box accessible by any character on the account? Like, one box per account.

I could probably script it (between my own projects), but I wanted to throw the idea out there.
 
still set the "owner" value
then on the double cluick method, just check to see if they are on the same account as the owner is instead of being the owner
 

rtaylor1987

Sorceror
Working Safety Deposit Box

I made the changes necessary to the safety deposit box to get it working properly. This has been tested on the latest SVN and works as intended. I've attached my fixed version, as well as copied my version into here for educational purposes.

My changes are highlighted in red.

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;

		} 
		
[COLOR="Red"]		public override bool IsDecoContainer
		{
			get{ return false; }
		}[/COLOR]
		
		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;
							}	
			}
[COLOR="Red"]			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;
					}[/COLOR]
				
				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();
		} 
	} 
}


This script will change the IsDecoContainer to false, allowing items to be placed into the container. Also, fixed the section that will open the container for the owner, as well as added range checks.

Hope you all enjoy!
 

Attachments

  • SafetyDepositBox.cs
    2.9 KB · Views: 87

Thagoras

Sorceror
Thanks! Wasn't even aware of the IdDecoContainer variable. I had considered the range option too...but figured it was supposed to work somewhat like the Bank.

I'm not sure about the random hue part. I placed one and it was one of those wacky hues. Don't a few of those hues crash the server if used on items?
 

rtaylor1987

Sorceror
I stopped the hue array right before the hues got too ridiculous. Currently, it only uses hues 1-1900. Some of those are a bit .. uhm.. unique, but from my experience, players tend to love the "unique" ones.

If you want to keep the hues basic without all the sparkly/neon/whatever hues, change line 31 from
Code:
Hue = random.Next(0, 1900);

to

Code:
Hue = random.Next(0, 999);

and that should keep everything fairly basic in terms of hues.
 

Diviny

Page
one of my players found that while using Telekinesis spell on that, anyone can open and move itens from/to it.
And Staff team can't open it by the double click way.
 
one of my players found that while using Telekinesis spell on that, anyone can open and move itens from/to it.
And Staff team can't open it by the double click way.
To fix the Telekinesis problem, just add the following code to the script.

Code:
        public override bool IsAccessibleTo(Mobile m)
        {
            if (m_Owner != null && m_Owner != m && m.AccessLevel == AccessLevel.Player)
                return false;

            return base.IsAccessibleTo(m);
        }

        public override bool CheckItemUse(Mobile from, Item item)
        {
            bool result = base.CheckItemUse(from, item);

            if (m_Owner == null && result)
            {
                OnDoubleClick(from);

                if (m_Owner == null && from.AccessLevel == AccessLevel.Player)
                    result = false;
            }

            return result;
        }
 

Obsidian Fire

Sorceror
I found that as a player I could not put anything in the chest, so I changed the "m_Owner" to "m_SDBOwner" and that seemed to fix the problem. I think the reason is because there is a "Owner" in the Admin access levels and unless you were the Owner you could not place items in the chest.

BTW this was tested on SVN669 , Client 7.0.13.0
 

jamesreg

Sorceror
is it possible to get it where commodity deeds can be used in the boxes like a normal bank box
also would it be possible to make the box where a player can give up his box?
 

jamesreg

Sorceror
Here is the above script which was removed reshard by someone who still loves the community
 

Attachments

  • SafetyDepositBox.cs
    2.5 KB · Views: 40

KoNNaN

Knight
restored text


Pretty simple script, but useful for us.

Description

- Place these around your banks and they will show as "Unclaimed Safety Deposit Box [5,000 Gold]

- Player double clicks it to claim, if they have 5,000 gold it will assign them the box, and will rename the box "Players Name's Safety Deposit Box".

- Only the player that is assigned to the box will be able to open it and use it.

- We treat these as a type of second bank box, although we don't charge gold for them, in our case we use treasure tokens.

I have marked the script if you want to change the price charged, or even the type of item consumed if you don't want to charge gold.

Installation

Simply drop it in your customs folder, and restart your shard.

Credits


Fenris - For the idea of the safety deposit boxes and the base script he provided me.

Me (aka DxMonkey) - Adding in the capability of these being sold by themselves, and the serialization/deserialization of the box's owner.

Possible Future Updates (To Do List)

- Make the box refresh/decay like a house does
- Make the box tradable

Enjoy ;)
 
New to scripting... taking a C# course... But how would i set the owner to be based off account? I found where i should put it, but i don't know what to change it to :/

Code:
            // 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;
                            }   
            }
 
Also.... is it possible to make one of these that can be accessed by anyone in a specific guild? Like a Guild Bank you could put in a Guild house?
 
here is how to check for the players being on same account

if( from.Account.Username == Owner.Account.Username )

just change the variables to match those in the script :)

as for guild, would need some changes for doing it
like instead of the account, would have to check guild status
would also need a variable for the guild too

it could be done, but would be a slight pain to do
 
Top