modernschroeder
Sorceror
Bank Box Max Items
Anyone know how to raise the maximum items the bank box can hold? I am running Runuo 2.
Thanks
Anyone know how to raise the maximum items the bank box can hold? I am running Runuo 2.
Thanks
using System;
using Server.Network;
namespace Server.Items
{
public class BankBox : Container
{
[COLOR="Red"] public override int DefaultMaxItems
{
get
{
// return base.DefaultMaxItems;
return 200;
}
}[/COLOR]
private Mobile m_Owner;
private bool m_Open;
using System;
using Server;
using Server.Mobiles;
public sealed class Update
{
public static void Initialize()
{
EventSink.Login += delegate( LoginEventArgs e )
{
((PlayerMobile)e.Mobile).BankBox.MaxItems = 1234;
};
}
}
// Created by Peoharen
using System;
using Server;
using Server.Accounting;
using Server.Mobiles;
namespace Server.Items
{
public class BankStorageIncreaseDeed : Item
{
// Maximum bonus these deeds can give is...
public const int BonusCap = 25;
// Standard private member with public access a GM can manipulate.
private int m_BonusSlots;
[CommandProperty( AccessLevel.GameMaster )]
public int BonusSlots
{
get { return m_BonusSlots; }
set { m_BonusSlots = value; }
}
[Constructable]
public BankStorageIncreaseDeed( int bonusslots ) : base( 0x14F0 )
{
Name = "Bank Storage Increase Deed";
m_BonusSlots = bonusslots;
}
// Adds a special messages at the bottom of the mouse over properties.
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
list.Add( 1114057, ((m_BonusSlots).ToString() + " Bonus Bank Slots") ); // ~1_VAL~
}
// This is how the tag is encoded into the account.
// It uses the mobile's serial, thus only the mobile that uses this can gain the benefit fo it.
public static string GetTag( Mobile m )
{
if ( m == null )
return String.Empty; // String.Empty is a faster way of checking for ""
else
return "Bonus Bank Slots[" + m.Serial.ToString() + "]";
}
// OVerride DoubleClick
public override void OnDoubleClick( Mobile from )
{
// Sanity, check for nulls
if ( from.Backpack == null || Parent != from.Backpack )
from.SendLocalizedMessage( 1080058 ); // This must be in your backpack to use it.
else if ( from.Account != null )
{
// Convert IAccount to Account
Account acc = (Account)from.Account;
// Get the tag and set up for reading the value.
string tag = GetTag( from );
int currentbonus = 0;
// Convert can create an exception if the value cannot be converted to an integer.
// so we throw it into Try/Catch to prevent the crash.
try { currentbonus = Convert.ToInt32( acc.GetTag( tag ) ); }
catch {}
// Check bonus slots vs cap.
if ( currentbonus + m_BonusSlots > BonusCap )
from.SendMessage( "You cannot use another one of these." );
else
{
from.SendMessage( "You increase your maximum item limit for your bank." );
currentbonus += m_BonusSlots;
// More sanity, then set max items to default (125) + bonus.
if ( from.BankBox != null )
from.BankBox.MaxItems = from.BankBox.DefaultMaxItems + currentbonus;
// Remove the tag and readd it with the new value.
acc.RemoveTag( tag );
acc.AddTag( tag, currentbonus.ToString() );
}
}
}
// Initialize is call on class creation, IE a way to set up stuff.
public static void Initialize()
{
// This is an event handler, the Login event is triggers when ever someone logs in.
// By using Events/Delegates we can tap into them from any script without edits to the base script.
EventSink.Login += delegate( LoginEventArgs e )
{
// Sanity
if ( e.Mobile.Account != null )
{
// Same as before really.
Account acc = (Account)e.Mobile.Account;
int currentbonus = 0;
try { currentbonus = Convert.ToInt32( acc.GetTag( GetTag( e.Mobile ) ) ); }
catch {}
if ( e.Mobile.BankBox != null && currentbonus > 0 )
e.Mobile.BankBox.MaxItems = e.Mobile.BankBox.DefaultMaxItems + currentbonus;
}
};
}
public BankStorageIncreaseDeed( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
// Save the bunus slots if the deed isn't used and instead traded or sold.
writer.Write( (int) m_BonusSlots );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
// Load the bonus slots.
m_BonusSlots = reader.ReadInt();
}
}
}
I was looking for a way to do this without the edits described in Hank the Drunk's post....I have a question....
Couldn't you do this by accessing the "equipped" bank box of the playermobile? Therefore making this per character instead of per account.
If so, how would you change the code that Peoharen gave?
EDIT: FYI for the OP, the code Peoharen gave doesn't delete the Deed when used.
[Constructable]
public BankStorageIncreaseDeed() : this( 25 )
{
}
[CommandProperty( AccessLevel.GameMaster )]
public int BonusSlots
{
get { return m_BonusSlots; }
set { m_BonusSlots = value; InvalidateProperties(); }
}