//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();
}
}
}
Hue = random.Next(0, 1900);
Hue = random.Next(0, 999);
To fix the Telekinesis problem, just add the following code to the script.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.
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;
}
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
// 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;
}
}