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!

[RunUO 2.0 RC1] Player Government System Version 2

Tru

Knight
madron;712708 said:
I have installed the system without any issues, until aa player goes to buy a house. Now perhaps I am confused. I use townhouse script, I know others do as well on a custom map of Malas. When said player clicks the townhouse script, the shard crashes, report below. Any ideas on how I can fix this?



I love this system, but I want players to use the housing already within the city limits. I have expanded the cities limits without issue. I even turned housing on and off, both times it crashed just double clicking the townhouse sign to buy.

thanks for yur help.

I think you posted this in the wrong thread...I notice a reference in the crash error to the TownHouseSign (and your comment about TownHouses) which would be Knives TownHouse Scripts and not the PlayerCity Scripts......Right?
 

madron

Wanderer
Tru;712741 said:
I think you posted this in the wrong thread...I notice a reference in the crash error to the TownHouseSign (and your comment about TownHouses) which would be Knives TownHouse Scripts and not the PlayerCity Scripts......Right?


Each time a player tries to purchase an already placed home within the city limits, just double clicking the sign crashes the shard. The crash report is from that. I still have to test if the shard crashes outside the city limits.

This never happened until I installed the player govt script today. I so want to use this, my players are so excited about the possiblities this will give them.

I wish we could associate the stone with static houseing using townhouse script, but I am not that good at scripts yet. I digress lol

Edited to add: without any cities set up, the shard does not crash when dbl clking the townhouse sign. As soon as I set up a town region using the deed, my player dbl clked the townhouse sign within the city limits, and the shard crashed.
 

Tru

Knight
madron;712752 said:
Each time a player tries to purchase an already placed home within the city limits, just double clicking the sign crashes the shard. The crash report is from that. I still have to test if the shard crashes outside the city limits.

This never happened until I installed the player govt script today. I so want to use this, my players are so excited about the possiblities this will give them.

I wish we could associate the stone with static houseing using townhouse script, but I am not that good at scripts yet. I digress lol

Edited to add: without any cities set up, the shard does not crash when dbl clking the townhouse sign. As soon as I set up a town region using the deed, my player dbl clked the townhouse sign within the city limits, and the shard crashed.


Can you run your shard in debug mode and crash it again then post that crash log....as it stands its not the player government system crashing its the Town House system. Debug info may help pin down the cause.

*After Thought* Did you change BaseHouse for both systems? If so the problem may be there.
 

madron

Wanderer
I did not use the patches for the townhouses, so no mods were done for basehouse regarding the townhouse system.

I got on my own player account, not my GM staff/player, we use a stone to go back and forth. I was able to buy the home, and then set up the city hall without crashing the shard. I have not tested if another player can come along and buy a home yet...I will do this tomorrow.

I will run this in debug and get my player to help me recreate this again. But it will not be until tomorrow, as its getting late for me here. Tru, thank you for taking the time to help me out here, it is appreciated.

I will post more tomorrow, thank you again.

I am posting my basehouse for you to look at, perhaps I have overlooked something. I am also using SVN 237, and what a difference an upgraded SVN makes.

basehouse:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Multis.Deeds;
using Server.Regions;
using Server.Network;
using Server.Targeting;
using Server.Accounting;
using Server.ContextMenus;
using Server.Gumps;
using Server.Guilds;
using Server.Engines.BulkOrders;
namespace Server.Multis
{
public abstract class BaseHouse : BaseMulti
{
public static bool NewVendorSystem{ get{ return Core.AOS; } } // Is new player vendor system enabled?
public const int MaxCoOwners = 15;
public const int MaxFriends = 50;
public const int MaxBans = 50;
public const bool DecayEnabled = true;
public static void Decay_OnTick()
{
for ( int i = 0; i < m_AllHouses.Count; ++i )
m_AllHouses.CheckDecay();
}
private DateTime m_LastRefreshed;
private bool m_RestrictDecay;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime LastRefreshed
{
get{ return m_LastRefreshed; }
set{ m_LastRefreshed = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool RestrictDecay
{
get{ return m_RestrictDecay; }
set{ m_RestrictDecay = value; }
}
public virtual TimeSpan DecayPeriod{ get{ return TimeSpan.FromDays( 5.0 ); } }
public virtual DecayType DecayType
{
get
{
if ( m_RestrictDecay || !DecayEnabled || DecayPeriod == TimeSpan.Zero )
return DecayType.Ageless;
if ( m_Owner == null )
return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh;
Account acct = m_Owner.Account as Account;
if ( acct == null )
return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh;
if ( acct.AccessLevel >= AccessLevel.GameMaster )
return DecayType.Ageless;
for ( int i = 0; i < acct.Length; ++i )
{
Mobile mob = acct;
if ( mob != null && mob.AccessLevel >= AccessLevel.GameMaster )
return DecayType.Ageless;
}
if ( !Core.AOS )
return DecayType.ManualRefresh;
if ( (acct.LastLogin + TimeSpan.FromDays( 90.0 )) < DateTime.Now )
return DecayType.Condemned;
List<BaseHouse> allHouses = new List<BaseHouse>( 2 );
for ( int i = 0; i < acct.Length; ++i )
{
Mobile mob = acct;
if ( mob != null )
allHouses.AddRange( GetHouses( mob ) );
}
BaseHouse newest = null;
for ( int i = 0; i < allHouses.Count; ++i )
{
BaseHouse check = allHouses;
if ( newest == null || IsNewer( check, newest ) )
newest = check;
}
if ( this == newest )
return DecayType.AutoRefresh;
return DecayType.ManualRefresh;
}
}
public bool IsNewer( BaseHouse check, BaseHouse house )
{
DateTime checkTime = ( check.LastTraded > check.BuiltOn ? check.LastTraded : check.BuiltOn );
DateTime houseTime = ( house.LastTraded > house.BuiltOn ? house.LastTraded : house.BuiltOn );
return ( checkTime > houseTime );
}
public virtual bool CanDecay
{
get
{
DecayType type = this.DecayType;
return ( type == DecayType.Condemned || type == DecayType.ManualRefresh );
}
}
[CommandProperty( AccessLevel.GameMaster )]
public virtual DecayLevel DecayLevel
{
get
{
if ( !CanDecay )
{
m_LastRefreshed = DateTime.Now;
return DecayLevel.Ageless;
}
TimeSpan timeAfterRefresh = DateTime.Now - m_LastRefreshed;
int percent = (int) ((timeAfterRefresh.Ticks * 1000) / DecayPeriod.Ticks);
if ( percent >= 1000 ) // 100.0%
return ( HasRentedVendors || VendorInventories.Count > 0 ) ? DecayLevel.DemolitionPending : DecayLevel.Collapsed;
else if ( percent >= 950 ) // 95.0% - 99.9%
return DecayLevel.IDOC;
else if ( percent >= 750 ) // 75.0% - 94.9%
return DecayLevel.Greatly;
else if ( percent >= 500 ) // 50.0% - 74.9%
return DecayLevel.Fairly;
else if ( percent >= 250 ) // 25.0% - 49.9%
return DecayLevel.Somewhat;
else if ( percent >= 005 ) // 00.5% - 24.9%
return DecayLevel.Slightly;
return DecayLevel.LikeNew;
}
}
public virtual bool RefreshDecay()
{
if ( DecayType == DecayType.Condemned )
return false;
DecayLevel oldLevel = this.DecayLevel;
m_LastRefreshed = DateTime.Now;
return ( oldLevel > DecayLevel.LikeNew );
}
public virtual bool CheckDecay()
{
if ( !Deleted && this.DecayLevel == DecayLevel.Collapsed )
{
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Decay_Sandbox ) );
return true;
}
return false;
}
public virtual void KillVendors()
{
ArrayList list = new ArrayList( PlayerVendors );
foreach ( PlayerVendor vendor in list )
vendor.Destroy( true );
list = new ArrayList( PlayerBarkeepers );
foreach ( PlayerBarkeeper barkeeper in list )
barkeeper.Delete();
}
public virtual void Decay_Sandbox()
{
if ( Deleted )
return;
KillVendors();
Delete();
}
[CommandProperty( AccessLevel.GameMaster )]
public virtual double BonusStorageScalar { get { return (Core.ML ? 1.2 : 1.0); } }
private bool m_Public;
private HouseRegion m_Region;
private HouseSign m_Sign;
private TrashBarrel m_Trash;
private ArrayList m_Doors;
private Mobile m_Owner;
private ArrayList m_Access;
private ArrayList m_Bans;
private ArrayList m_CoOwners;
private ArrayList m_Friends;
private ArrayList m_PlayerVendors = new ArrayList();
private ArrayList m_PlayerBarkeepers = new ArrayList();
private ArrayList m_LockDowns;
private ArrayList m_VendorRentalContracts;
private ArrayList m_Secures;
private ArrayList m_Addons;
private ArrayList m_VendorInventories = new ArrayList();
private ArrayList m_RelocatedEntities = new ArrayList();
private MovingCrate m_MovingCrate;
private ArrayList m_InternalizedVendors;
private int m_MaxLockDowns;
private int m_MaxSecures;
private int m_Price;
private int m_Visits;
private DateTime m_BuiltOn, m_LastTraded;
private Point3D m_RelativeBanLocation;
private static Dictionary<Mobile, List<BaseHouse>> m_Table = new Dictionary<Mobile, List<BaseHouse>>();
public virtual bool IsAosRules{ get{ return Core.AOS; } }
public virtual bool IsActive{ get{ return true; } }
public virtual HousePlacementEntry GetAosEntry()
{
return HousePlacementEntry.Find( this );
}
public virtual int GetAosMaxSecures()
{
HousePlacementEntry hpe = GetAosEntry();
if ( hpe == null )
return 0;
return (int)(hpe.Storage * BonusStorageScalar);
}
public virtual int GetAosMaxLockdowns()
{
HousePlacementEntry hpe = GetAosEntry();
if ( hpe == null )
return 0;
return (int)(hpe.Lockdowns * BonusStorageScalar);
}
public virtual int GetAosCurSecures( out int fromSecures, out int fromVendors, out int fromLockdowns, out int fromMovingCrate )
{
fromSecures = 0;
fromVendors = 0;
fromLockdowns = 0;
fromMovingCrate = 0;
ArrayList list = m_Secures;
for ( int i = 0; list != null && i < list.Count; ++i )
{
SecureInfo si = (SecureInfo)list;
fromSecures += si.Item.TotalItems;
}
if ( m_LockDowns != null )
fromLockdowns += m_LockDowns.Count;
if ( !NewVendorSystem )
{
foreach ( PlayerVendor vendor in PlayerVendors )
{
if ( vendor.Backpack != null )
{
fromVendors += vendor.Backpack.TotalItems;
}
}
}
if ( MovingCrate != null )
{
fromMovingCrate += MovingCrate.TotalItems;
foreach ( Item item in MovingCrate.Items )
{
if ( item is PackingBox )
fromMovingCrate--;
}
}
return fromSecures + fromVendors + fromLockdowns + fromMovingCrate;
}
public bool InRange( IPoint2D from, int range )
{
if ( Region == null )
return false;
foreach ( Rectangle3D rect in Region.Area )
{
if ( from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range )
return true;
}
return false;
}
public virtual int GetNewVendorSystemMaxVendors()
{
HousePlacementEntry hpe = GetAosEntry();
if ( hpe == null )
return 0;

return (int)(hpe.Vendors * BonusStorageScalar);
}
public virtual bool CanPlaceNewVendor()
{
if ( !IsAosRules )
return true;
if ( !NewVendorSystem )
return CheckAosLockdowns( 10 );
return ( (PlayerVendors.Count + VendorRentalContracts.Count) < GetNewVendorSystemMaxVendors() );
}
public const int MaximumBarkeepCount = 2;
public virtual bool CanPlaceNewBarkeep()
{
return ( PlayerBarkeepers.Count < MaximumBarkeepCount );
}
public static void IsThereVendor( Point3D location, Map map, out bool vendor, out bool rentalContract )
{
vendor = false;
rentalContract = false;
IPooledEnumerable eable = map.GetObjectsInRange( location, 0 );
foreach ( IEntity entity in eable )
{
if ( Math.Abs( location.Z - entity.Z ) <= 16 )
{
if ( entity is PlayerVendor || entity is PlayerBarkeeper || entity is PlayerVendorPlaceholder )
{
vendor = true;
break;
}
if ( entity is VendorRentalContract )
{
rentalContract = true;
break;
}
}
}
eable.Free();
}
public bool HasPersonalVendors
{
get
{
foreach ( PlayerVendor vendor in PlayerVendors )
{
if ( !(vendor is RentedVendor) )
return true;
}
return false;
}
}
public bool HasRentedVendors
{
get
{
foreach ( PlayerVendor vendor in PlayerVendors )
{
if ( vendor is RentedVendor )
return true;
}
return false;
}
}
public ArrayList AvailableVendorsFor( Mobile m )
{
ArrayList list = new ArrayList();
foreach ( PlayerVendor vendor in PlayerVendors )
{
if ( vendor.CanInteractWith( m, false ) )
list.Add( vendor );
}
return list;
}
public bool AreThereAvailableVendorsFor( Mobile m )
{
foreach ( PlayerVendor vendor in PlayerVendors )
{
if ( vendor.CanInteractWith( m, false ) )
return true;
}
return false;
}
public void MoveAllToCrate()
{
RelocatedEntities.Clear();
if ( MovingCrate != null )
MovingCrate.Hide();
if ( m_Trash != null )
{
m_Trash.Delete();
m_Trash = null;
}
foreach ( Item item in LockDowns )
{
if ( !item.Deleted )
{
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
if ( item.Parent == null )
DropToMovingCrate( item );
}
}
LockDowns.Clear();
foreach ( Item item in VendorRentalContracts )
{
if ( !item.Deleted )
{
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
if ( item.Parent == null )
DropToMovingCrate( item );
}
}
VendorRentalContracts.Clear();
foreach ( SecureInfo info in Secures )
{
Item item = info.Item;
if ( !item.Deleted )
{
if ( item is StrongBox )
item = ((StrongBox)item).ConvertToStandardContainer();
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
if ( item.Parent == null )
DropToMovingCrate( item );
}
}
Secures.Clear();
foreach ( Item addon in Addons )
{
if ( !addon.Deleted )
{
Item deed = null;
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
int hue = 0;
if( addon is IAddon )
{
deed = ((IAddon)addon).Deed;
if( addon is BaseAddon && ((BaseAddon)addon).RetainDeedHue) //There are things that are IAddon which aren't BaseAddon
{
BaseAddon ba = (BaseAddon)addon;
retainDeedHue = true;
for( int i = 0; hue == 0 && i < ba.Components.Count; ++i )
{
AddonComponent c = ba.Components;
if( c.Hue != 0 )
hue = c.Hue;
}
}
}
if ( deed != null )
{
addon.Delete();
if( retainDeedHue )
deed.Hue = hue;
DropToMovingCrate( deed );
}
else
{
DropToMovingCrate( addon );
}
}
}
Addons.Clear();
foreach ( PlayerVendor mobile in PlayerVendors )
{
mobile.Return();
mobile.Internalize();
InternalizedVendors.Add( mobile );
}
foreach ( Mobile mobile in PlayerBarkeepers )
{
mobile.Internalize();
InternalizedVendors.Add( mobile );
}
}
public List<IEntity> GetHouseEntities()
{
List<IEntity> list = new List<IEntity>();
if ( MovingCrate != null )
MovingCrate.Hide();
if ( m_Trash != null && m_Trash.Map != Map.Internal )
list.Add( m_Trash );
foreach ( Item item in LockDowns )
{
if ( item.Parent == null && item.Map != Map.Internal )
list.Add( item );
}
foreach ( Item item in VendorRentalContracts )
{
if ( item.Parent == null && item.Map != Map.Internal )
list.Add( item );
}
foreach ( SecureInfo info in Secures )
{
Item item = info.Item;
if ( item.Parent == null && item.Map != Map.Internal )
list.Add( item );
}
foreach ( Item item in Addons )
{
if ( item.Parent == null && item.Map != Map.Internal )
list.Add( item );
}
foreach ( PlayerVendor mobile in PlayerVendors )
{
mobile.Return();
if ( mobile.Map != Map.Internal )
list.Add( mobile );
}
foreach ( Mobile mobile in PlayerBarkeepers )
{
if ( mobile.Map != Map.Internal )
list.Add( mobile );
}
return list;
}
public void RelocateEntities()
{
foreach ( IEntity entity in GetHouseEntities() )
{
Point3D relLoc = new Point3D( entity.X - this.X, entity.Y - this.Y, entity.Z - this.Z );
RelocatedEntity relocEntity = new RelocatedEntity( entity, relLoc );
RelocatedEntities.Add( relocEntity );
if ( entity is Item )
((Item)entity).Internalize();
else
((Mobile)entity).Internalize();
}
}
public void RestoreRelocatedEntities()
{
foreach ( RelocatedEntity relocEntity in RelocatedEntities )
{
Point3D relLoc = relocEntity.RelativeLocation;
Point3D location = new Point3D( relLoc.X + this.X, relLoc.Y + this.Y, relLoc.Z + this.Z );
IEntity entity = relocEntity.Entity;
if ( entity is Item )
{
Item item = (Item) entity;
if ( !item.Deleted )
{
if ( item is IAddon )
{
if ( ((IAddon)item).CouldFit( location, this.Map ) )
{
item.MoveToWorld( location, this.Map );
continue;
}
}
else
{
int height;
bool requireSurface;
if ( item is VendorRentalContract )
{
height = 16;
requireSurface = true;
}
else
{
height = item.ItemData.Height;
requireSurface = false;
}
if ( this.Map.CanFit( location.X, location.Y, location.Z, height, false, false, requireSurface ) )
{
item.MoveToWorld( location, this.Map );
continue;
}
}
// The item can't fit
if ( item is TrashBarrel )
{
item.Delete(); // Trash barrels don't go to the moving crate
}
else
{
SetLockdown( item, false );
item.IsSecure = false;
item.Movable = true;
Item relocateItem = item;
if ( item is StrongBox )
relocateItem = ((StrongBox)item).ConvertToStandardContainer();
if( item is IAddon )
{
Item deed = ((IAddon)item).Deed;
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
int hue = 0;
if( item is BaseAddon && ((BaseAddon)item).RetainDeedHue ) //There are things that are IAddon which aren't BaseAddon
{
BaseAddon ba = (BaseAddon)item;
retainDeedHue = true;
for( int i = 0; hue == 0 && i < ba.Components.Count; ++i )
{
AddonComponent c = ba.Components;
if( c.Hue != 0 )
hue = c.Hue;
}
}
if( deed != null && retainDeedHue )
deed.Hue = hue;
relocateItem = deed;
item.Delete();
}
if ( relocateItem != null )
DropToMovingCrate( relocateItem );
}
}
if ( m_Trash == item )
m_Trash = null;
LockDowns.Remove( item );
VendorRentalContracts.Remove( item );
Addons.Remove( item );
for ( int i = Secures.Count - 1; i >= 0; i-- )
{
if ( ((SecureInfo)Secures).Item == item )
Secures.RemoveAt( i );
}
}
else
{
Mobile mobile = (Mobile) entity;
if ( !mobile.Deleted )
{
if ( this.Map.CanFit( location, 16, false, false ) )
{
mobile.MoveToWorld( location, this.Map );
}
else
{
InternalizedVendors.Add( mobile );
}
}
}
}
RelocatedEntities.Clear();
}
public void DropToMovingCrate( Item item )
{
if ( MovingCrate == null )
MovingCrate = new MovingCrate( this );
MovingCrate.DropItem( item );
}
public List<Item> GetItems()
{
if( this.Map == null || this.Map == Map.Internal )
return new List<Item>();
Point2D start = new Point2D( this.X + Components.Min.X, this.Y + Components.Min.Y );
Point2D end = new Point2D( this.X + Components.Max.X + 1, this.Y + Components.Max.Y + 1 );
Rectangle2D rect = new Rectangle2D( start, end );
List<Item> list = new List<Item>();
IPooledEnumerable eable = this.Map.GetItemsInBounds( rect );

foreach ( Item item in eable )
if ( item.Movable && IsInside( item ) )
list.Add( item );
eable.Free();
return list;
}
public List<Mobile> GetMobiles()
{
if( this.Map == null || this.Map == Map.Internal )
return new List<Mobile>();
List<Mobile> list = new List<Mobile>();
foreach ( Mobile mobile in Region.GetMobiles() )
if ( IsInside( mobile ) )
list.Add( mobile );
return list;
}
public virtual bool CheckAosLockdowns( int need )
{
return ( (GetAosCurLockdowns() + need) <= GetAosMaxLockdowns() );
}
public virtual bool CheckAosStorage( int need )
{
int fromSecures, fromVendors, fromLockdowns, fromMovingCrate;
return ( (GetAosCurSecures( out fromSecures, out fromVendors, out fromLockdowns, out fromMovingCrate ) + need) <= GetAosMaxSecures() );
}
public static void Configure()
{
Item.LockedDownFlag = 1;
Item.SecureFlag = 2;
Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( Decay_OnTick ) );
}
public virtual int GetAosCurLockdowns()
{
int v = 0;
if ( m_LockDowns != null )
v += m_LockDowns.Count;
if ( m_Secures != null )
v += m_Secures.Count;
if ( !NewVendorSystem )
v += PlayerVendors.Count * 10;
return v;
}
public static bool CheckLockedDown( Item item )
{
BaseHouse house = FindHouseAt( item );
return ( house != null && house.IsLockedDown( item ) );
}
public static bool CheckSecured( Item item )
{
BaseHouse house = FindHouseAt( item );
return ( house != null && house.IsSecure( item ) );
}
public static bool CheckLockedDownOrSecured( Item item )
{
BaseHouse house = FindHouseAt( item );
return ( house != null && (house.IsSecure( item ) || house.IsLockedDown( item )) );
}
public static List<BaseHouse> GetHouses( Mobile m )
{
List<BaseHouse> list = new List<BaseHouse>();
if ( m != null )
{
List<BaseHouse> exists = null;
m_Table.TryGetValue( m, out exists );
if ( exists != null )
{
for ( int i = 0; i < exists.Count; ++i )
{
BaseHouse house = exists;
if ( house != null && !house.Deleted && house.Owner == m )
list.Add( house );
}
}
}
return list;
}
public static bool CheckHold( Mobile m, Container cont, Item item, bool message, bool checkItems, int plusItems, int plusWeight )
{
BaseHouse house = FindHouseAt( cont );
if ( house == null || !house.IsAosRules )
return true;
if ( house.IsSecure( cont ) && !house.CheckAosStorage( 1 + item.TotalItems + plusItems ) )
{
if ( message )
m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.
return false;
}
return true;
}
public static bool CheckAccessible( Mobile m, Item item )
{
if ( m.AccessLevel >= AccessLevel.GameMaster )
return true; // Staff can access anything
BaseHouse house = FindHouseAt( item );
if ( house == null )
return true;
SecureAccessResult res = house.CheckSecureAccess( m, item );
switch ( res )
{
case SecureAccessResult.Insecure: break;
case SecureAccessResult.Accessible: return true;
case SecureAccessResult.Inaccessible: return false;
}
if ( house.IsLockedDown( item ) )
return house.IsCoOwner( m ) && (item is Container);
return true;
}
public static BaseHouse FindHouseAt( Mobile m )
{
if ( m == null || m.Deleted )
return null;
return FindHouseAt( m.Location, m.Map, 16 );
}
public static BaseHouse FindHouseAt( Item item )
{
if ( item == null || item.Deleted )
return null;
return FindHouseAt( item.GetWorldLocation(), item.Map, item.ItemData.Height );
}
public static BaseHouse FindHouseAt( Point3D loc, Map map, int height )
{
if ( map == null || map == Map.Internal )
return null;
Sector sector = map.GetSector( loc );
for ( int i = 0; i < sector.Multis.Count; ++i )
{
BaseHouse house = sector.Multis as BaseHouse;
if ( house != null && house.IsInside( loc, height ) )
return house;
}
return null;
}
public bool IsInside( Mobile m )
{
if ( m == null || m.Deleted || m.Map != this.Map )
return false;
return IsInside( m.Location, 16 );
}
public bool IsInside( Item item )
{
if ( item == null || item.Deleted || item.Map != this.Map )
return false;
return IsInside( item.Location, item.ItemData.Height );
}
public bool CheckAccessibility( Item item, Mobile from )
{
SecureAccessResult res = CheckSecureAccess( from, item );
switch ( res )
{
case SecureAccessResult.Insecure: break;
case SecureAccessResult.Accessible: return true;
case SecureAccessResult.Inaccessible: return false;
}
if ( !IsLockedDown( item ) )
return true;
else if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
else if ( item is Runebook )
return true;
else if ( item is ISecurable )
return HasSecureAccess( from, ((ISecurable)item).Level );
else if ( item is Container )
return IsCoOwner( from );
else if ( item is BaseLight )
return IsFriend( from );
else if ( item is PotionKeg )
return IsFriend( from );
else if ( item is BaseBoard )
return true;
else if ( item is Dices )
return true;
else if ( item is RecallRune )
return true;
else if ( item is TreasureMap )
return true;
else if ( item is Clock )
return true;
else if ( item is BaseBook )
return true;
else if ( item is BaseInstrument )
return true;
else if ( item is Dyes || item is DyeTub )
return true;
else if ( item is VendorRentalContract )
return true;
return false;
}
public virtual bool IsInside( Point3D p, int height )
{
if ( Deleted )
return false;
MultiComponentList mcl = Components;
int x = p.X - (X + mcl.Min.X);
int y = p.Y - (Y + mcl.Min.Y);
if ( x < 0 || x >= mcl.Width || y < 0 || y >= mcl.Height )
return false;
if ( this is HouseFoundation && y < (mcl.Height-1) && p.Z >= this.Z )
return true;
Tile[] tiles = mcl.Tiles[x][y];
for ( int j = 0; j < tiles.Length; ++j )
{
Tile tile = tiles[j];
int id = tile.ID & 0x3FFF;
ItemData data = TileData.ItemTable[id];
// Slanted roofs do not count; they overhang blocking south and east sides of the multi
if ( (data.Flags & TileFlag.Roof) != 0 )
continue;
// Signs and signposts are not considered part of the multi
if ( (id >= 0xB95 && id <= 0xC0E) || (id >= 0xC43 && id <= 0xC44) )
continue;
int tileZ = tile.Z + this.Z;
if ( p.Z == tileZ || (p.Z + height) > tileZ )
return true;
}
return false;
}
public SecureAccessResult CheckSecureAccess( Mobile m, Item item )
{
if ( m_Secures == null || !(item is Container) )
return SecureAccessResult.Insecure;
for ( int i = 0; i < m_Secures.Count; ++i )
{
SecureInfo info = (SecureInfo)m_Secures;
if ( info.Item == item )
return HasSecureAccess( m, info.Level ) ? SecureAccessResult.Accessible : SecureAccessResult.Inaccessible;
}
return SecureAccessResult.Insecure;
}
private static List<BaseHouse> m_AllHouses = new List<BaseHouse>();
public BaseHouse( int multiID, Mobile owner, int MaxLockDown, int MaxSecure ) : base( multiID | 0x4000 )
{
m_AllHouses.Add( this );
m_LastRefreshed = DateTime.Now;
m_BuiltOn = DateTime.Now;
m_LastTraded = DateTime.MinValue;
m_Doors = new ArrayList();
m_LockDowns = new ArrayList();
m_Secures = new ArrayList();
m_Addons = new ArrayList();
m_CoOwners = new ArrayList();
m_Friends = new ArrayList();
m_Bans = new ArrayList();
m_Access = new ArrayList();
m_VendorRentalContracts = new ArrayList();
m_InternalizedVendors = new ArrayList();
m_Owner = owner;
m_MaxLockDowns = MaxLockDown;
m_MaxSecures = MaxSecure;
m_RelativeBanLocation = this.BaseBanLocation;
UpdateRegion();
if ( owner != null )
{
List<BaseHouse> list = null;
m_Table.TryGetValue( owner, out list );
if ( list == null )
m_Table[owner] = list = new List<BaseHouse>();
list.Add( this );
}
Movable = false;
}
public BaseHouse( Serial serial ) : base( serial )
{
m_AllHouses.Add( this );
}
public override void OnMapChange()
{
if ( m_LockDowns == null )
return;
UpdateRegion();
if ( m_Sign != null && !m_Sign.Deleted )
m_Sign.Map = this.Map;
if ( m_Doors != null )
{
foreach ( Item item in m_Doors )
item.Map = this.Map;
}
foreach ( IEntity entity in GetHouseEntities() )
{
if ( entity is Item )
((Item)entity).Map = this.Map;
else
((Mobile)entity).Map = this.Map;
}
}
public virtual void ChangeSignType( int itemID )
{
if ( m_Sign != null )
m_Sign.ItemID = itemID;
}
public abstract Rectangle2D[] Area{ get; }
public abstract Point3D BaseBanLocation{ get; }
public virtual void UpdateRegion()
{
if ( m_Region != null )
m_Region.Unregister();
if ( this.Map != null )
{
m_Region = new HouseRegion( this );
m_Region.Register();
}
else
{
m_Region = null;
}
}
public override void OnLocationChange( Point3D oldLocation )
{
if ( m_LockDowns == null )
return;
int x = base.Location.X - oldLocation.X;
int y = base.Location.Y - oldLocation.Y;
int z = base.Location.Z - oldLocation.Z;
if ( m_Sign != null && !m_Sign.Deleted )
m_Sign.Location = new Point3D( m_Sign.X + x, m_Sign.Y + y, m_Sign.Z + z );
UpdateRegion();
if ( m_Doors != null )
{
foreach ( Item item in m_Doors )
{
if ( !item.Deleted )
item.Location = new Point3D( item.X + x, item.Y + y, item.Z + z );
}
}
foreach ( IEntity entity in GetHouseEntities() )
{
Point3D newLocation = new Point3D( entity.X + x, entity.Y + y, entity.Z + z );
if ( entity is Item )
((Item)entity).Location = newLocation;
else
((Mobile)entity).Location = newLocation;
}
}
public BaseDoor AddEastDoor( int x, int y, int z )
{
return AddEastDoor( true, x, y, z );
}
public BaseDoor AddEastDoor( bool wood, int x, int y, int z )
{
BaseDoor door = MakeDoor( wood, DoorFacing.SouthCW );
AddDoor( door, x, y, z );
return door;
}
public BaseDoor AddSouthDoor( int x, int y, int z )
{
return AddSouthDoor( true, x, y, z );
}
public BaseDoor AddSouthDoor( bool wood, int x, int y, int z )
{
BaseDoor door = MakeDoor( wood, DoorFacing.WestCW );
AddDoor( door, x, y, z );
return door;
}
public BaseDoor AddEastDoor( int x, int y, int z, uint k )
{
return AddEastDoor( true, x, y, z, k );
}
public BaseDoor AddEastDoor( bool wood, int x, int y, int z, uint k )
{
BaseDoor door = MakeDoor( wood, DoorFacing.SouthCW );
door.Locked = true;
door.KeyValue = k;
AddDoor( door, x, y, z );
return door;
}
public BaseDoor AddSouthDoor( int x, int y, int z, uint k )
{
return AddSouthDoor( true, x, y, z, k );
}
public BaseDoor AddSouthDoor( bool wood, int x, int y, int z, uint k )
{
BaseDoor door = MakeDoor( wood, DoorFacing.WestCW );
door.Locked = true;
door.KeyValue = k;
AddDoor( door, x, y, z );
return door;
}
public BaseDoor[] AddSouthDoors( int x, int y, int z, uint k )
{
return AddSouthDoors( true, x, y, z, k );
}
public BaseDoor[] AddSouthDoors( bool wood, int x, int y, int z, uint k )
{
BaseDoor westDoor = MakeDoor( wood, DoorFacing.WestCW );
BaseDoor eastDoor = MakeDoor( wood, DoorFacing.EastCCW );
westDoor.Locked = true;
eastDoor.Locked = true;
westDoor.KeyValue = k;
eastDoor.KeyValue = k;
westDoor.Link = eastDoor;
eastDoor.Link = westDoor;
AddDoor( westDoor, x, y, z );
AddDoor( eastDoor, x + 1, y, z );
return new BaseDoor[2]{ westDoor, eastDoor };
}
public uint CreateKeys( Mobile m )
{
uint value = Key.RandomValue();
if ( !IsAosRules )
{
Key packKey = new Key( KeyType.Gold );
Key bankKey = new Key( KeyType.Gold );
packKey.KeyValue = value;
bankKey.KeyValue = value;
packKey.LootType = LootType.Newbied;
bankKey.LootType = LootType.Newbied;
BankBox box = m.BankBox;
if ( !box.TryDropItem( m, bankKey, false ) )
bankKey.Delete();
m.AddToBackpack( packKey );
}
return value;
}
public BaseDoor[] AddSouthDoors( int x, int y, int z )
{
return AddSouthDoors( true, x, y, z, false );
}
public BaseDoor[] AddSouthDoors( bool wood, int x, int y, int z, bool inv )
{
BaseDoor westDoor = MakeDoor( wood, inv ? DoorFacing.WestCCW : DoorFacing.WestCW );
BaseDoor eastDoor = MakeDoor( wood, inv ? DoorFacing.EastCW : DoorFacing.EastCCW );
westDoor.Link = eastDoor;
eastDoor.Link = westDoor;
AddDoor( westDoor, x, y, z );
AddDoor( eastDoor, x + 1, y, z );
return new BaseDoor[2]{ westDoor, eastDoor };
}
public BaseDoor MakeDoor( bool wood, DoorFacing facing )
{
if ( wood )
return new DarkWoodHouseDoor( facing );
else
return new MetalHouseDoor( facing );
}
public void AddDoor( BaseDoor door, int xoff, int yoff, int zoff )
{
door.MoveToWorld( new Point3D( xoff+this.X, yoff+this.Y, zoff+this.Z ), this.Map );
m_Doors.Add( door );
}
public void AddTrashBarrel( Mobile from )
{
if ( !IsActive )
return;
for ( int i = 0; m_Doors != null && i < m_Doors.Count; ++i )
{
BaseDoor door = m_Doors as BaseDoor;
Point3D p = door.Location;
if ( door.Open )
p = new Point3D( p.X - door.Offset.X, p.Y - door.Offset.Y, p.Z - door.Offset.Z );
if ( (from.Z + 16) >= p.Z && (p.Z + 16) >= from.Z )
{
if ( from.InRange( p, 1 ) )
{
from.SendLocalizedMessage( 502120 ); // You cannot place a trash barrel near a door or near steps.
return;
}
}
}
if ( m_Trash == null || m_Trash.Deleted )
{
m_Trash = new TrashBarrel();
m_Trash.Movable = false;
m_Trash.MoveToWorld( from.Location, from.Map );
from.SendLocalizedMessage( 502121 ); /* You have a new trash barrel.
* Three minutes after you put something in the barrel, the trash will be emptied.
* Be forewarned, this is permanent! */
}
else
{
m_Trash.MoveToWorld( from.Location, from.Map );
}
}
public void SetSign( int xoff, int yoff, int zoff )
{
m_Sign = new HouseSign( this );
m_Sign.MoveToWorld( new Point3D( this.X + xoff, this.Y + yoff, this.Z + zoff ), this.Map );
}
private void SetLockdown( Item i, bool locked )
{
SetLockdown( i, locked, false );
}
private void SetLockdown( Item i, bool locked, bool checkContains )
{
if ( m_LockDowns == null )
return;
i.Movable = !locked;
i.IsLockedDown = locked;
if ( locked )
{
if ( i is VendorRentalContract )
{
if ( !VendorRentalContracts.Contains( i ) )
VendorRentalContracts.Add( i );
}
else
{
if ( !checkContains || !m_LockDowns.Contains( i ) )
m_LockDowns.Add( i );
}
}
else
{
VendorRentalContracts.Remove( i );
m_LockDowns.Remove( i );
}
if ( !locked )
i.SetLastMoved();
if ( (i is Container) && (!locked || !(i is BaseBoard)) )
{
foreach ( Item c in i.Items )
SetLockdown( c, locked, checkContains );
}
}
public bool LockDown( Mobile m, Item item )
{
return LockDown( m, item, true );
}
public bool LockDown( Mobile m, Item item, bool checkIsInside )
{
if ( !IsCoOwner( m ) || !IsActive )
return false;
if ( item.Movable && !IsSecure( item ) )
{
int amt = 1 + item.TotalItems;
Item rootItem = item.RootParent as Item;
Item parentItem = item.Parent as Item;
if ( checkIsInside && item.RootParent is Mobile )
{
m.SendLocalizedMessage( 1005525 );//That is not in your house
}
else if ( checkIsInside && !IsInside( item.GetWorldLocation(), item.ItemData.Height ) )
{
m.SendLocalizedMessage( 1005525 );//That is not in your house
}
else if ( Ethics.Ethic.IsImbued( item ) )
{
m.SendLocalizedMessage( 1005377 );//You cannot lock that down
}
else if ( IsSecure( rootItem ) )
{
m.SendLocalizedMessage( 501737 ); // You need not lock down items in a secure container.
}
else if ( parentItem != null && !IsLockedDown( parentItem ) )
{
m.SendLocalizedMessage( 501736 ); // You must lockdown the container first!
}
else if ( !(item is VendorRentalContract) && ( IsAosRules ? (!CheckAosLockdowns( amt ) || !CheckAosStorage( amt )) : (this.LockDownCount + amt) > m_MaxLockDowns ) )
{
m.SendLocalizedMessage( 1005379 );//That would exceed the maximum lock down limit for this house
}
else
{
SetLockdown( item, true );
return true;
}
}
else if ( m_LockDowns.IndexOf( item ) != -1 )
{
m.SendLocalizedMessage( 1005526 );//That is already locked down
return true;
}
else
{
m.SendLocalizedMessage( 1005377 );//You cannot lock that down
}
return false;
}
private class TransferItem : Item
{
private BaseHouse m_House;
public override string DefaultName
{
get { return "a house transfer contract"; }
}
public TransferItem( BaseHouse house ) : base( 0x14F0 )
{
m_House = house;
Hue = 0x480;
Movable = false;
}
public override void GetProperties( ObjectPropertyList list )
{
base.GetProperties( list );
string houseName, owner, location;
houseName = ( m_House == null ? "an unnamed house" : m_House.Sign.GetName() );
Mobile houseOwner = ( m_House == null ? null : m_House.Owner );
if ( houseOwner == null )
owner = "nobody";
else
owner = houseOwner.Name;
int xLong = 0, yLat = 0, xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
bool valid = m_House != null && Sextant.Format( m_House.Location, m_House.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth );
if ( valid )
location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
else
location = "unknown";
list.Add( 1061112, Utility.FixHtml( houseName ) ); // House Name: ~1_val~
list.Add( 1061113, owner ); // Owner: ~1_val~
list.Add( 1061114, location ); // Location: ~1_val~
}
public TransferItem( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
Delete();
}
public override bool AllowSecureTrade( Mobile from, Mobile to, Mobile newOwner, bool accepted )
{
if ( !base.AllowSecureTrade( from, to, newOwner, accepted ) )
return false;
else if ( !accepted )
return true;
if ( Deleted || m_House == null || m_House.Deleted || !m_House.IsOwner( from ) || !from.CheckAlive() || !to.CheckAlive() )
return false;
if ( BaseHouse.HasAccountHouse( to ) )
{
from.SendLocalizedMessage( 501388 ); // You cannot transfer ownership to another house owner or co-owner!
return false;
}
return m_House.CheckTransferPosition( from, to );
}
public override void OnSecureTrade( Mobile from, Mobile to, Mobile newOwner, bool accepted )
{
if ( Deleted || m_House == null || m_House.Deleted || !m_House.IsOwner( from ) || !from.CheckAlive() || !to.CheckAlive() )
return;
Delete();
if ( !accepted )
return;
from.SendLocalizedMessage( 501338 ); // You have transferred ownership of the house.
to.SendLocalizedMessage( 501339 ); /* You are now the owner of this house.
* The house's co-owner, friend, ban, and access lists have been cleared.
* You should double-check the security settings on any doors and teleporters in the house.
*/
m_House.RemoveKeys( from );
m_House.Owner = to;
m_House.Bans.Clear();
m_House.Friends.Clear();
m_House.CoOwners.Clear();
m_House.ChangeLocks( to );
m_House.LastTraded = DateTime.Now;
}
}
public bool CheckTransferPosition( Mobile from, Mobile to )
{
bool isValid = true;
Item sign = m_Sign;
Point3D p = ( sign == null ? Point3D.Zero : sign.GetWorldLocation() );
if ( from.Map != Map || to.Map != Map )
isValid = false;
else if ( sign == null )
isValid = false;
else if ( from.Map != sign.Map || to.Map != sign.Map )
isValid = false;
else if ( IsInside( from ) )
isValid = false;
else if ( IsInside( to ) )
isValid = false;
else if ( !from.InRange( p, 2 ) )
isValid = false;
else if ( !to.InRange( p, 2 ) )
isValid = false;
if ( !isValid )
from.SendLocalizedMessage( 1062067 ); // In order to transfer the house, you and the recipient must both be outside the building and within two paces of the house sign.
return isValid;
}
public void BeginConfirmTransfer( Mobile from, Mobile to )
{
if ( Deleted || !from.CheckAlive() || !IsOwner( from ) )
return;
if ( NewVendorSystem && HasPersonalVendors )
{
from.SendLocalizedMessage( 1062467 ); // You cannot trade this house while you still have personal vendors inside.
}
else if ( DecayLevel == DecayLevel.DemolitionPending )
{
from.SendLocalizedMessage( 1005321 ); // This house has been marked for demolition, and it cannot be transferred.
}
else if ( from == to )
{
from.SendLocalizedMessage( 1005330 ); // You cannot transfer a house to yourself, silly.
}
else if ( to.Player )
{
if ( BaseHouse.HasAccountHouse( to ) )
{
from.SendLocalizedMessage( 501388 ); // You cannot transfer ownership to another house owner or co-owner!
}
else if ( CheckTransferPosition( from, to ) )
{
from.SendLocalizedMessage( 1005326 ); // Please wait while the other player verifies the transfer.
if ( HasRentedVendors )
{
/* You are about to be traded a home that has active vendor contracts.
* While there are active vendor contracts in this house, you
* <strong>cannot</strong> demolish <strong>OR</strong> customize the home.
* When you accept this house, you also accept landlordship for every
* contract vendor in the house.
*/
to.SendGump( new WarningGump( 1060635, 30720, 1062487, 32512, 420, 280, new WarningGumpCallback( ConfirmTransfer_Callback ), from ) );
}
else
{
to.CloseGump( typeof( Gumps.HouseTransferGump ) );
to.SendGump( new Gumps.HouseTransferGump( from, to, this ) );
}
}
}
else
{
from.SendLocalizedMessage( 501384 ); // Only a player can own a house!
}
}
private void ConfirmTransfer_Callback( Mobile to, bool ok, object state )
{
Mobile from = (Mobile) state;
if ( !ok || Deleted || !from.CheckAlive() || !IsOwner( from ) )
return;
if ( CheckTransferPosition( from, to ) )
{
to.CloseGump( typeof( Gumps.HouseTransferGump ) );
to.SendGump( new Gumps.HouseTransferGump( from, to, this ) );
}
}
public void EndConfirmTransfer( Mobile from, Mobile to )
{
if ( Deleted || !from.CheckAlive() || !IsOwner( from ) )
return;
if ( NewVendorSystem && HasPersonalVendors )
{
from.SendLocalizedMessage( 1062467 ); // You cannot trade this house while you still have personal vendors inside.
}
else if ( DecayLevel == DecayLevel.DemolitionPending )
{
from.SendLocalizedMessage( 1005321 ); // This house has been marked for demolition, and it cannot be transferred.
}
else if ( from == to )
{
from.SendLocalizedMessage( 1005330 ); // You cannot transfer a house to yourself, silly.
}
else if ( to.Player )
{
if ( BaseHouse.HasAccountHouse( to ) )
{
from.SendLocalizedMessage( 501388 ); // You cannot transfer ownership to another house owner or co-owner!
}
else if ( CheckTransferPosition( from, to ) )
{
NetState fromState = from.NetState, toState = to.NetState;
if ( fromState != null && toState != null )
{
if ( from.HasTrade )
{
from.SendLocalizedMessage( 1062071 ); // You cannot trade a house while you have other trades pending.
}
else if ( to.HasTrade )
{
to.SendLocalizedMessage( 1062071 ); // You cannot trade a house while you have other trades pending.
}
else if( !to.Alive )
{
// TODO: Check if the message is correct.
from.SendLocalizedMessage( 1062069 ); // You cannot transfer this house to that person.
}
else
{
Container c = fromState.AddTrade( toState );
c.DropItem( new TransferItem( this ) );
}
}
}
}
else
{
from.SendLocalizedMessage( 501384 ); // Only a player can own a house!
}
}
public void Release( Mobile m, Item item )
{
if ( !IsCoOwner( m ) || !IsActive )
return;
if ( IsLockedDown( item ) )
{
item.PublicOverheadMessage( Server.Network.MessageType.Label, 0x3B2, 501657 );//[no longer locked down]
SetLockdown( item, false );
//TidyItemList( m_LockDowns );
}
else if ( IsSecure( item ) )
{
ReleaseSecure( m, item );
}
else
{
m.SendLocalizedMessage( 501722 );//That isn't locked down...
}
}

public void AddSecure( Mobile m, Item item )
{
if ( m_Secures == null || !IsOwner( m ) || !IsActive )
return;
if ( !IsInside( item ) )
{
m.SendLocalizedMessage( 1005525 ); // That is not in your house
}
else if ( IsLockedDown( item ) )
{
m.SendLocalizedMessage( 1010550 ); // This is already locked down and cannot be secured.
}
else if ( !(item is Container) )
{
LockDown( m, item );
}
else
{
SecureInfo info = null;
for ( int i = 0; info == null && i < m_Secures.Count; ++i )
if ( ((SecureInfo)m_Secures).Item == item )
info = (SecureInfo)m_Secures;
if ( info != null )
{
m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
}
else if ( item.Parent != null )
{
m.SendLocalizedMessage( 1010423 ); // You cannot secure this, place it on the ground first.
}
else if ( !item.Movable )
{
m.SendLocalizedMessage( 1010424 ); // You cannot secure this.
}
else if ( !IsAosRules && SecureCount >= MaxSecures )
{
// The maximum number of secure items has been reached :
m.SendLocalizedMessage( 1008142, true, MaxSecures.ToString() );
}
else if ( IsAosRules ? !CheckAosLockdowns( 1 ) : ((LockDownCount + 125) >= MaxLockDowns) )
{
m.SendLocalizedMessage( 1005379 ); // That would exceed the maximum lock down limit for this house
}
else if ( IsAosRules && !CheckAosStorage( item.TotalItems ) )
{
m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.
}
else
{
info = new SecureInfo( (Container)item, SecureLevel.CoOwners );
item.IsLockedDown = false;
item.IsSecure = true;
m_Secures.Add( info );
m_LockDowns.Remove( item );
item.Movable = false;
m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
}
}
}
public virtual bool IsCombatRestricted( Mobile m )
{
if ( m == null || !m.Player || m.AccessLevel >= AccessLevel.GameMaster || !IsAosRules || ( m_Owner != null && m_Owner.AccessLevel >= AccessLevel.GameMaster ))
return false;
for ( int i = 0; i < m.Aggressed.Count; ++i )
{
AggressorInfo info = m.Aggressed;
Guild attackerGuild = m.Guild as Guild;
Guild defenderGuild = info.Defender.Guild as Guild;
if ( info.Defender.Player && info.Defender.Alive && (DateTime.Now - info.LastCombatTime) < HouseRegion.CombatHeatDelay && (attackerGuild == null || defenderGuild == null || defenderGuild != attackerGuild && !defenderGuild.IsEnemy( attackerGuild )) )
return true;
}
return false;
}
public bool HasSecureAccess( Mobile m, SecureLevel level )
{
if ( m.AccessLevel >= AccessLevel.GameMaster )
return true;
if ( IsCombatRestricted( m ) )
return false;
switch ( level )
{
case SecureLevel.Owner: return IsOwner( m );
case SecureLevel.CoOwners: return IsCoOwner( m );
case SecureLevel.Friends: return IsFriend( m );
case SecureLevel.Anyone: return true;
case SecureLevel.Guild: return IsGuildMember( m );
}
return false;
}
public void ReleaseSecure( Mobile m, Item item )
{
if ( m_Secures == null || !IsOwner( m ) || item is StrongBox || !IsActive )
return;
for ( int i = 0; i < m_Secures.Count; ++i )
{
SecureInfo info = (SecureInfo)m_Secures;
if ( info.Item == item && HasSecureAccess( m, info.Level ) )
{
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
item.SetLastMoved();
item.PublicOverheadMessage( Server.Network.MessageType.Label, 0x3B2, 501656 );//[no longer secure]
m_Secures.RemoveAt( i );
return;
}
}
m.SendLocalizedMessage( 501717 );//This isn't secure...
}
public override bool Decays
{
get
{
return false;
}
}
public void AddStrongBox( Mobile from )
{
if ( !IsCoOwner( from ) || !IsActive )
return;
if ( from == Owner )
{
from.SendLocalizedMessage( 502109 ); // Owners don't get a strong box
return;
}
if ( IsAosRules ? !CheckAosLockdowns( 1 ) : ((LockDownCount + 1) > m_MaxLockDowns) )
{
from.SendLocalizedMessage( 1005379 );//That would exceed the maximum lock down limit for this house
return;
}
foreach ( SecureInfo info in m_Secures )
{
Container c = info.Item;
if ( !c.Deleted && c is StrongBox && ((StrongBox)c).Owner == from )
{
from.SendLocalizedMessage( 502112 );//You already have a strong box
return;
}
}
for ( int i = 0; m_Doors != null && i < m_Doors.Count; ++i )
{
BaseDoor door = m_Doors as BaseDoor;
Point3D p = door.Location;
if ( door.Open )
p = new Point3D( p.X - door.Offset.X, p.Y - door.Offset.Y, p.Z - door.Offset.Z );
if ( (from.Z + 16) >= p.Z && (p.Z + 16) >= from.Z )
{
if ( from.InRange( p, 1 ) )
{
from.SendLocalizedMessage( 502113 ); // You cannot place a strongbox near a door or near steps.
return;
}
}
}
StrongBox sb = new StrongBox( from, this );
sb.Movable = false;
sb.IsLockedDown = false;
sb.IsSecure = true;
m_Secures.Add( new SecureInfo( sb, SecureLevel.CoOwners ) );
sb.MoveToWorld( from.Location, from.Map );
}
public void Kick( Mobile from, Mobile targ )
{
if ( !IsFriend( from ) || m_Friends == null )
return;
if ( targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel )
{
from.SendLocalizedMessage( 501346 ); // Uh oh...a bigger boot may be required!
}
else if ( IsFriend( targ ) )
{
from.SendLocalizedMessage( 501348 ); // You cannot eject a friend of the house!
}
else if ( targ is PlayerVendor )
{
from.SendLocalizedMessage( 501351 ); // You cannot eject a vendor.
}
else if ( !IsInside( targ ) )
{
from.SendLocalizedMessage( 501352 ); // You may not eject someone who is not in your house!
}
else if ( targ is BaseCreature && ((BaseCreature)targ).NoHouseRestrictions )
{
from.SendLocalizedMessage( 501347 ); // You cannot eject that from the house!
}
else
{
targ.MoveToWorld( BanLocation, Map );
from.SendLocalizedMessage( 1042840, targ.Name ); // ~1_PLAYER NAME~ has been ejected from this house.
targ.SendLocalizedMessage( 501341 ); /* You have been ejected from this house.
* If you persist in entering, you may be banned from the house.
*/
}
}
public void RemoveAccess( Mobile from, Mobile targ )
{
if ( !IsFriend( from ) || m_Access == null )
return;
if ( m_Access.Contains( targ ) )
{
m_Access.Remove( targ );
if ( !HasAccess( targ ) && IsInside( targ ) )
{
targ.Location = BanLocation;
targ.SendLocalizedMessage( 1060734 ); // Your access to this house has been revoked.
}
from.SendLocalizedMessage( 1050051 ); // The invitation has been revoked.
}
}
public void RemoveBan( Mobile from, Mobile targ )
{
if ( !IsCoOwner( from ) || m_Bans == null )
return;
if ( m_Bans.Contains( targ ) )
{
m_Bans.Remove( targ );
from.SendLocalizedMessage( 501297 ); // The ban is lifted.
}
}
public void Ban( Mobile from, Mobile targ )
{
if ( !IsFriend( from ) || m_Bans == null )
return;
if ( targ.AccessLevel > AccessLevel.Player && from.AccessLevel <= targ.AccessLevel )
{
from.SendLocalizedMessage( 501354 ); // Uh oh...a bigger boot may be required.
}
else if ( IsFriend( targ ) )
{
from.SendLocalizedMessage( 501348 ); // You cannot eject a friend of the house!
}
else if ( targ is PlayerVendor )
{
from.SendLocalizedMessage( 501351 ); // You cannot eject a vendor.
}
else if ( m_Bans.Count >= MaxBans )
{
from.SendLocalizedMessage( 501355 ); // The ban limit for this house has been reached!
}
else if ( IsBanned( targ ) )
{
from.SendLocalizedMessage( 501356 ); // This person is already banned!
}
else if ( !IsInside( targ ) )
{
from.SendLocalizedMessage( 501352 ); // You may not eject someone who is not in your house!
}
else if ( !Public && IsAosRules )
{
from.SendLocalizedMessage( 1062521 ); // You cannot ban someone from a private house. Revoke their access instead.
}
else if ( targ is BaseCreature && ((BaseCreature)targ).NoHouseRestrictions )
{
from.SendLocalizedMessage( 1062040 ); // You cannot ban that.
}
else
{
m_Bans.Add( targ );
from.SendLocalizedMessage( 1042839, targ.Name ); // ~1_PLAYER_NAME~ has been banned from this house.
targ.SendLocalizedMessage( 501340 ); // You have been banned from this house.
targ.MoveToWorld( BanLocation, Map );
}
}
public void GrantAccess( Mobile from, Mobile targ )
{
if ( !IsFriend( from ) || m_Access == null )
return;
if ( HasAccess( targ ) )
{
from.SendLocalizedMessage( 1060729 ); // That person already has access to this house.
}
else if ( !targ.Player )
{
from.SendLocalizedMessage( 1060712 ); // That is not a player.
}
else if ( IsBanned( targ ) )
{
from.SendLocalizedMessage( 501367 ); // This person is banned! Unban them first.
}
else
{
m_Access.Add( targ );
targ.SendLocalizedMessage( 1060735 ); // You have been granted access to this house.
}
}
public void AddCoOwner( Mobile from, Mobile targ )
{
if ( !IsOwner( from ) || m_CoOwners == null || m_Friends == null )
return;
if ( IsOwner( targ ) )
{
from.SendLocalizedMessage( 501360 ); // This person is already the house owner!
}
else if ( m_Friends.Contains( targ ) )
{
from.SendLocalizedMessage( 501361 ); // This person is a friend of the house. Remove them first.
}
else if ( !targ.Player )
{
from.SendLocalizedMessage( 501362 ); // That can't be a co-owner of the house.
}
else if ( HasAccountHouse( targ ) )
{
from.SendLocalizedMessage( 501364 ); // That person is already a house owner.
}
else if ( IsBanned( targ ) )
{
from.SendLocalizedMessage( 501367 ); // This person is banned! Unban them first.
}
else if ( m_CoOwners.Count >= MaxCoOwners )
{
from.SendLocalizedMessage( 501368 ); // Your co-owner list is full!
}
else if ( m_CoOwners.Contains( targ ) )
{
from.SendLocalizedMessage( 501369 ); // This person is already on your co-owner list!
}
else
{
m_CoOwners.Add( targ );
targ.Delta( MobileDelta.Noto );
targ.SendLocalizedMessage( 501343 ); // You have been made a co-owner of this house.
}
}
public void RemoveCoOwner( Mobile from, Mobile targ )
{
if ( !IsOwner( from ) || m_CoOwners == null )
return;
if ( m_CoOwners.Contains( targ ) )
{
m_CoOwners.Remove( targ );
targ.Delta( MobileDelta.Noto );
from.SendLocalizedMessage( 501299 ); // Co-owner removed from list.
targ.SendLocalizedMessage( 501300 ); // You have been removed as a house co-owner.
foreach ( SecureInfo info in m_Secures )
{
Container c = info.Item;
if ( c is StrongBox && ((StrongBox)c).Owner == targ )
{
c.IsLockedDown = false;
c.IsSecure = false;
m_Secures.Remove( c );
c.Destroy();
break;
}
}
}
}
public void AddFriend( Mobile from, Mobile targ )
{
if ( !IsCoOwner( from ) || m_Friends == null || m_CoOwners == null )
return;
if ( IsOwner( targ ) )
{
from.SendLocalizedMessage( 501370 ); // This person is already an owner of the house!
}
else if ( m_CoOwners.Contains( targ ) )
{
from.SendLocalizedMessage( 501369 ); // This person is already on your co-owner list!
}
else if ( !targ.Player )
{
from.SendLocalizedMessage( 501371 ); // That can't be a friend of the house.
}
else if ( IsBanned( targ ) )
{
from.SendLocalizedMessage( 501374 ); // This person is banned! Unban them first.
}
else if ( m_Friends.Count >= MaxFriends )
{
from.SendLocalizedMessage( 501375 ); // Your friends list is full!
}
else if ( m_Friends.Contains( targ ) )
{
from.SendLocalizedMessage( 501376 ); // This person is already on your friends list!
}
else
{
m_Friends.Add( targ );
targ.Delta( MobileDelta.Noto );
targ.SendLocalizedMessage( 501337 ); // You have been made a friend of this house.
}
}
public void RemoveFriend( Mobile from, Mobile targ )
{
if ( !IsCoOwner( from ) || m_Friends == null )
return;
if ( m_Friends.Contains( targ ) )
{
m_Friends.Remove( targ );
targ.Delta( MobileDelta.Noto );
from.SendLocalizedMessage( 501298 ); // Friend removed from list.
targ.SendLocalizedMessage( 1060751 ); // You are no longer a friend of this house.
}
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 14 ); // version
writer.Write( (Point3D) m_RelativeBanLocation );
writer.WriteItemList( m_VendorRentalContracts, true );
writer.WriteMobileList( m_InternalizedVendors, true );
writer.WriteEncodedInt( m_RelocatedEntities.Count );
foreach ( RelocatedEntity relEntity in m_RelocatedEntities )
{
writer.Write( (Point3D) relEntity.RelativeLocation );
if ( ( relEntity.Entity is Item && ((Item)relEntity.Entity).Deleted ) || ( relEntity.Entity is Mobile && ((Mobile)relEntity.Entity).Deleted ) )
writer.Write( (int) Serial.MinusOne );
else
writer.Write( (int) relEntity.Entity.Serial );
}
writer.WriteEncodedInt( m_VendorInventories.Count );
for ( int i = 0; i < m_VendorInventories.Count; i++ )
{
VendorInventory inventory = (VendorInventory) m_VendorInventories;
inventory.Serialize( writer );
}
writer.Write( (DateTime) m_LastRefreshed );
writer.Write( (bool) m_RestrictDecay );
writer.Write( (int) m_Visits );
writer.Write( (int) m_Price );
writer.WriteMobileList( m_Access );
writer.Write( m_BuiltOn );
writer.Write( m_LastTraded );
writer.WriteItemList( m_Addons, true );
writer.Write( m_Secures.Count );
for ( int i = 0; i < m_Secures.Count; ++i )
((SecureInfo)m_Secures).Serialize( writer );
writer.Write( m_Public );
//writer.Write( BanLocation );
writer.Write( m_Owner );
// Version 5 no longer serializes region coords
/*writer.Write( (int)m_Region.Coords.Count );
foreach( Rectangle2D rect in m_Region.Coords )
{
writer.Write( rect );
}*/
writer.WriteMobileList( m_CoOwners, true );
writer.WriteMobileList( m_Friends, true );
writer.WriteMobileList( m_Bans, true );
writer.Write( m_Sign );
writer.Write( m_Trash );
writer.WriteItemList( m_Doors, true );
writer.WriteItemList( m_LockDowns, true );
//writer.WriteItemList( m_Secures, true );
writer.Write( (int) m_MaxLockDowns );
writer.Write( (int) m_MaxSecures );
// Items in locked down containers that aren't locked down themselves must decay!
for ( int i = 0; i < m_LockDowns.Count; ++i )
{
Item item = (Item)m_LockDowns;
if ( item is Container && !(item is BaseBoard) )
{
Container cont = (Container)item;
List<Item> children = cont.Items;
for ( int j = 0; j < children.Count; ++j )
{
Item child = children[j];
if ( child.Decays && !child.IsLockedDown && !child.IsSecure && (child.LastMoved + child.DecayTime) <= DateTime.Now )
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( child.Delete ) );
}
}
}
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
int count;
switch ( version )
{
case 14:
{
m_RelativeBanLocation = reader.ReadPoint3D();
goto case 13;
}
case 13: // removed ban location serialization
case 12:
{
m_VendorRentalContracts = reader.ReadItemList();
m_InternalizedVendors = reader.ReadMobileList();
int relocatedCount = reader.ReadEncodedInt();
for ( int i = 0; i < relocatedCount; i++ )
{
Point3D relLocation = reader.ReadPoint3D();
IEntity entity = World.FindEntity( reader.ReadInt() );
if ( entity != null )
m_RelocatedEntities.Add( new RelocatedEntity( entity, relLocation ) );
}
int inventoryCount = reader.ReadEncodedInt();
for ( int i = 0; i < inventoryCount; i++ )
{
VendorInventory inventory = new VendorInventory( this, reader );
m_VendorInventories.Add( inventory );
}
goto case 11;
}
case 11:
{
m_LastRefreshed = reader.ReadDateTime();
m_RestrictDecay = reader.ReadBool();
goto case 10;
}
case 10: // just a signal for updates
case 9:
{
m_Visits = reader.ReadInt();
goto case 8;
}
case 8:
{
m_Price = reader.ReadInt();
goto case 7;
}
case 7:
{
m_Access = reader.ReadMobileList();
goto case 6;
}
case 6:
{
m_BuiltOn = reader.ReadDateTime();
m_LastTraded = reader.ReadDateTime();
goto case 5;
}
case 5: // just removed fields
case 4:
{
m_Addons = reader.ReadItemList();
goto case 3;
}
case 3:
{
count = reader.ReadInt();
m_Secures = new ArrayList( count );
for ( int i = 0; i < count; ++i )
{
SecureInfo info = new SecureInfo( reader );
if ( info.Item != null )
{
info.Item.IsSecure = true;
m_Secures.Add( info );
}
}
goto case 2;
}
case 2:
{
m_Public = reader.ReadBool();
goto case 1;
}
case 1:
{
if ( version < 13 )
reader.ReadPoint3D(); // house ban location
goto case 0;
}
case 0:
{
if ( version < 14 )
m_RelativeBanLocation = this.BaseBanLocation;
if ( version < 12 )
{
m_VendorRentalContracts = new ArrayList();
m_InternalizedVendors = new ArrayList();
}
if ( version < 4 )
m_Addons = new ArrayList();
if ( version < 7 )
m_Access = new ArrayList();
if ( version < 8 )
m_Price = DefaultPrice;
m_Owner = reader.ReadMobile();
if ( version < 5 )
{
count = reader.ReadInt();
for(int i=0;i<count;i++)
reader.ReadRect2D();
}
UpdateRegion();
m_CoOwners = reader.ReadMobileList();
m_Friends = reader.ReadMobileList();
m_Bans = reader.ReadMobileList();
m_Sign = reader.ReadItem() as HouseSign;
m_Trash = reader.ReadItem() as TrashBarrel;
m_Doors = reader.ReadItemList();
m_LockDowns = reader.ReadItemList();
for ( int i = 0; i < m_LockDowns.Count; ++i )
((Item)m_LockDowns).IsLockedDown = true;
for ( int i = 0; i < m_VendorRentalContracts.Count; ++i )
((Item)m_VendorRentalContracts).IsLockedDown = true;
if ( version < 3 )
{
ArrayList items = reader.ReadItemList();
m_Secures = new ArrayList( items.Count );
for ( int i = 0; i < items.Count; ++i )
{
Container c = items as Container;
if ( c != null )
{
c.IsSecure = true;
m_Secures.Add( new SecureInfo( c, SecureLevel.CoOwners ) );
}
}
}
m_MaxLockDowns = reader.ReadInt();
m_MaxSecures = reader.ReadInt();
if ( (Map == null || Map == Map.Internal) && Location == Point3D.Zero )
Delete();
if ( m_Owner != null )
{
List<BaseHouse> list = null;
m_Table.TryGetValue( m_Owner, out list );
if ( list == null )
m_Table[m_Owner] = list = new List<BaseHouse>();
list.Add( this );
}
break;
}
}
if ( version <= 1 )
ChangeSignType( 0xBD2 );//private house, plain brass sign
if ( version < 10 )
{
/* NOTE: This can exceed the house lockdown limit. It must be this way, because
* we do not want players' items to decay without them knowing. Or not even
* having a chance to fix it themselves.
*/
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixLockdowns_Sandbox ) );
}
if ( version < 11 )
m_LastRefreshed = DateTime.Now + TimeSpan.FromHours( 24 * Utility.RandomDouble() );
if ( !CheckDecay() )
{
if ( RelocatedEntities.Count > 0 )
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RestoreRelocatedEntities ) );
if ( m_Owner == null && m_Friends.Count == 0 && m_CoOwners.Count == 0 )
Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( Delete ) );
}
}
private void FixLockdowns_Sandbox()
{
ArrayList lockDowns = new ArrayList();
for ( int i = 0; m_LockDowns != null && i < m_LockDowns.Count; ++i )
{
Item item = (Item)m_LockDowns;
if ( item is Container )
lockDowns.Add( item );
}
for ( int i = 0; i < lockDowns.Count; ++i )
SetLockdown( (Item)lockDowns, true, true );
}
public static void HandleDeletion( Mobile mob )
{
List<BaseHouse> houses = GetHouses( mob );
if ( houses.Count == 0 )
return;
Account acct = mob.Account as Account;
Mobile trans = null;
for ( int i = 0; i < acct.Length; ++i )
{
if ( acct != null && acct != mob )
trans = acct;
}
for ( int i = 0; i < houses.Count; ++i )
{
BaseHouse house = houses;
bool canClaim = false;
if ( trans == null )
canClaim = ( house.CoOwners.Count > 0 );
/*{
for ( int j = 0; j < house.CoOwners.Count; ++j )
{
Mobile check = house.CoOwners[j] as Mobile;
if ( check != null && !check.Deleted && !HasAccountHouse( check ) )
{
canClaim = true;
break;
}
}
}*/
if ( trans == null && !canClaim )
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( house.Delete ) );
else
house.Owner = trans;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner
{
get
{
return m_Owner;
}
set
{
if ( m_Owner != null )
{
List<BaseHouse> list = null;
m_Table.TryGetValue( m_Owner, out list );
if ( list == null )
m_Table[m_Owner] = list = new List<BaseHouse>();
list.Remove( this );
m_Owner.Delta( MobileDelta.Noto );
}
m_Owner = value;
if ( m_Owner != null )
{
List<BaseHouse> list = null;
m_Table.TryGetValue( m_Owner, out list );
if ( list == null )
m_Table[m_Owner] = list = new List<BaseHouse>();
list.Add( this );
m_Owner.Delta( MobileDelta.Noto );
}
if ( m_Sign != null )
m_Sign.InvalidateProperties();
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Visits
{
get{ return m_Visits; }
set{ m_Visits = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public bool Public
{
get
{
return m_Public;
}
set
{
if ( m_Public != value )
{
m_Public = value;
if ( !m_Public ) // Privatizing the house, change to brass sign
ChangeSignType( 0xBD2 );
if ( m_Sign != null )
m_Sign.InvalidateProperties();
}
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int MaxSecures
{
get
{
return m_MaxSecures;
}
set
{
m_MaxSecures = value;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D BanLocation
{
get
{
return m_Region.GoLocation;
}
set
{
this.RelativeBanLocation = new Point3D( value.X - this.X, value.Y - this.Y, value.Z - this.Z );
}
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D RelativeBanLocation
{
get
{
return m_RelativeBanLocation;
}
set
{
m_RelativeBanLocation = value;
m_Region.GoLocation = new Point3D( this.X + value.X, this.Y + value.Y, this.Z + value.Z );
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int MaxLockDowns
{
get
{
return m_MaxLockDowns;
}
set
{
m_MaxLockDowns = value;
}
}
public Region Region{ get{ return m_Region; } }
public ArrayList CoOwners{ get{ return m_CoOwners; } set{ m_CoOwners = value; } }
public ArrayList Friends{ get{ return m_Friends; } set{ m_Friends = value; } }
public ArrayList Access{ get{ return m_Access; } set{ m_Access = value; } }
public ArrayList Bans{ get{ return m_Bans; } set{ m_Bans = value; } }
public ArrayList Doors{ get{ return m_Doors; } set{ m_Doors = value; } }
public int LockDownCount
{
get
{
int count = 0;
if ( m_LockDowns != null )
count += m_LockDowns.Count;
if ( m_Secures != null )
{
for ( int i = 0; i < m_Secures.Count; ++i )
{
SecureInfo info = (SecureInfo)m_Secures;
if ( info.Item.Deleted )
continue;
else if ( info.Item is StrongBox )
count += 1;
else
count += 125;
}
}
return count;
}
}
public int SecureCount
{
get
{
int count = 0;
if ( m_Secures != null )
{
for ( int i = 0; i < m_Secures.Count; i++ )
{
SecureInfo info = (SecureInfo)m_Secures;
if ( info.Item.Deleted )
continue;
else if ( !(info.Item is StrongBox) )
count += 1;
}
}
return count;
}
}
public ArrayList Addons{ get{ return m_Addons; } set{ m_Addons = value; } }
public ArrayList LockDowns{ get{ return m_LockDowns; } }
public ArrayList Secures{ get{ return m_Secures; } }
public HouseSign Sign{ get{ return m_Sign; } set{ m_Sign = value; } }
public ArrayList PlayerVendors{ get{ return m_PlayerVendors; } }
public ArrayList PlayerBarkeepers{ get{ return m_PlayerBarkeepers; } }
public ArrayList VendorRentalContracts{ get{ return m_VendorRentalContracts; } }
public ArrayList VendorInventories{ get{ return m_VendorInventories; } }
public ArrayList RelocatedEntities{ get{ return m_RelocatedEntities; } }
public MovingCrate MovingCrate{ get{ return m_MovingCrate; } set{ m_MovingCrate = value; } }
public ArrayList InternalizedVendors{ get{ return m_InternalizedVendors; } }
public DateTime BuiltOn
{
get{ return m_BuiltOn; }
set{ m_BuiltOn = value; }
}
public DateTime LastTraded
{
get{ return m_LastTraded; }
set{ m_LastTraded = value; }
}
public override void OnDelete()
{
/*Map map = this.Map;
if ( map != null )
{
MultiComponentList mcl = Components;
IPooledEnumerable eable = map.GetItemsInBounds( new Rectangle2D( X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height ) );
foreach ( Item item in eable )
if ( item is Guildstone && Contains( item ) )
item.Delete();

eable.Free();
}*/
RestoreRelocatedEntities();
new FixColumnTimer( this ).Start();
base.OnDelete();
}
private class FixColumnTimer : Timer
{
private Map m_Map;
private int m_StartX, m_StartY, m_EndX, m_EndY;
public FixColumnTimer( BaseMulti multi ) : base( TimeSpan.Zero )
{
m_Map = multi.Map;
MultiComponentList mcl = multi.Components;
m_StartX = multi.X + mcl.Min.X;
m_StartY = multi.Y + mcl.Min.Y;
m_EndX = multi.X + mcl.Max.X;
m_EndY = multi.Y + mcl.Max.Y;
}
protected override void OnTick()
{
if ( m_Map == null )
return;
for ( int x = m_StartX; x <= m_EndX; ++x )
for ( int y = m_StartY; y <= m_EndY; ++y )
m_Map.FixColumn( x, y );
}
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
if ( m_Owner != null )
{
List<BaseHouse> list = null;
m_Table.TryGetValue( m_Owner, out list );

if ( list == null )
m_Table[m_Owner] = list = new List<BaseHouse>();
list.Remove( this );
}
if ( m_Region != null )
{
m_Region.Unregister();
m_Region = null;
}
if ( m_Sign != null )
m_Sign.Delete();
if ( m_Trash != null )
m_Trash.Delete();
if ( m_Doors != null )
{
for ( int i = 0; i < m_Doors.Count; ++i )
{
Item item = (Item)m_Doors;
if ( item != null )
item.Delete();
}
m_Doors.Clear();
}
if ( m_LockDowns != null )
{
for ( int i = 0; i < m_LockDowns.Count; ++i )
{
Item item = (Item)m_LockDowns;
if ( item != null )
{
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
item.SetLastMoved();
}
}
m_LockDowns.Clear();
}
if ( VendorRentalContracts != null )
{
for ( int i = 0; i < VendorRentalContracts.Count; ++i )
{
Item item = (Item)VendorRentalContracts;
if ( item != null )
{
item.IsLockedDown = false;
item.IsSecure = false;
item.Movable = true;
item.SetLastMoved();
}
}
VendorRentalContracts.Clear();
}
if ( m_Secures != null )
{
for ( int i = 0; i < m_Secures.Count; ++i )
{
SecureInfo info = (SecureInfo)m_Secures;
if ( info.Item is StrongBox )
{
info.Item.Destroy();
}
else
{
info.Item.IsLockedDown = false;
info.Item.IsSecure = false;
info.Item.Movable = true;
info.Item.SetLastMoved();
}
}
m_Secures.Clear();
}
if ( m_Addons != null )
{
for ( int i = 0; i < m_Addons.Count; ++i )
{
Item item = (Item)m_Addons;
if ( item != null )
{
if( !item.Deleted && item is IAddon )
{
Item deed = ((IAddon)item).Deed;
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
int hue = 0;
if( item is BaseAddon && ((BaseAddon)item).RetainDeedHue ) //There are things that are IAddon which aren't BaseAddon
{
BaseAddon ba = (BaseAddon)item;
retainDeedHue = true;
for( int j = 0; hue == 0 && j < ba.Components.Count; ++j )
{
AddonComponent c = ba.Components[j];
if( c.Hue != 0 )
hue = c.Hue;
}
}
if( deed != null )
{
if( retainDeedHue )
deed.Hue = hue;
deed.MoveToWorld( item.Location, item.Map );
}
}
item.Delete();
}
}
m_Addons.Clear();
}
ArrayList inventories = new ArrayList( VendorInventories );
foreach ( VendorInventory inventory in inventories )
inventory.Delete();
if ( MovingCrate != null )
MovingCrate.Delete();
KillVendors();
m_AllHouses.Remove( this );
}
public static int GetHouseSlots( Mobile m )
{
Account acct = m.Account as Account;
int houses = Convert.ToInt32( acct.GetTag("maxHouses") );
if ( houses < 1 )
houses = 1;
int trueSlots = houses - 5;
return trueSlots;
}
public static bool HasHouse( Mobile m )
{
if ( m == null )
return false;
List<BaseHouse> list = null;
m_Table.TryGetValue( m, out list );
if ( list == null )
return false;
for ( int i = GetHouseSlots( m ); i < list.Count; ++i )
{
BaseHouse h = list;
if ( !h.Deleted )
return true;
}
return false;
}
public static bool HasAccountHouse( Mobile m )
{
Account a = m.Account as Account;
if ( a == null )
return false;
for ( int i = 0; i < a.Length; ++i )
if ( a != null && HasHouse( a ) )
return true;
return false;
}
public bool CheckAccount( Mobile mobCheck, Mobile accCheck )
{
if ( accCheck != null )
{
Account a = accCheck.Account as Account;
if ( a != null )
{
for ( int i = 0; i < a.Length; ++i )
{
if ( a == mobCheck )
return true;
}
}
}
return false;
}
public bool IsOwner( Mobile m )
{
if ( m == null )
return false;
if ( m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster )
return true;
return IsAosRules && CheckAccount( m, m_Owner );
}
public bool IsCoOwner( Mobile m )
{
if ( m == null || m_CoOwners == null )
return false;
if ( IsOwner( m ) || m_CoOwners.Contains( m ) )
return true;
return !IsAosRules && CheckAccount( m, m_Owner );
}
public bool IsGuildMember( Mobile m )
{
if( m == null || Owner == null || Owner.Guild == null )
return false;
return ( m.Guild == Owner.Guild );
}
public void RemoveKeys( Mobile m )
{
if ( m_Doors != null )
{
uint keyValue = 0;
for ( int i = 0; keyValue == 0 && i < m_Doors.Count; ++i )
{
BaseDoor door = m_Doors as BaseDoor;
if ( door != null )
keyValue = door.KeyValue;
}
Key.RemoveKeys( m, keyValue );
}
}
public void ChangeLocks( Mobile m )
{
uint keyValue = CreateKeys( m );
if ( m_Doors != null )
{
for ( int i = 0; i < m_Doors.Count; ++i )
{
BaseDoor door = m_Doors as BaseDoor;
if ( door != null )
door.KeyValue = keyValue;
}
}
}
public void RemoveLocks()
{
if ( m_Doors != null )
{
for (int i=0;i<m_Doors.Count;++i)
{
BaseDoor door = m_Doors as BaseDoor;
if ( door != null )
{
door.KeyValue = 0;
door.Locked = false;
}
}
}
}
public virtual HousePlacementEntry ConvertEntry{ get{ return null; } }
public virtual int ConvertOffsetX{ get{ return 0; } }
public virtual int ConvertOffsetY{ get{ return 0; } }
public virtual int ConvertOffsetZ{ get{ return 0; } }
public virtual int DefaultPrice{ get{ return 0; } }
[CommandProperty( AccessLevel.GameMaster )]
public int Price{ get{ return m_Price; } set{ m_Price = value; } }
public virtual HouseDeed GetDeed()
{
return null;
}
public bool IsFriend( Mobile m )
{
if ( m == null || m_Friends == null )
return false;
return ( IsCoOwner( m ) || m_Friends.Contains( m ) );
}
public bool IsBanned( Mobile m )
{
if ( m == null || m == Owner || m.AccessLevel > AccessLevel.Player || m_Bans == null )
return false;
Account theirAccount = m.Account as Account;
for ( int i = 0; i < m_Bans.Count; ++i )
{
Mobile c = (Mobile)m_Bans;
if ( c == m )
return true;
Account bannedAccount = c.Account as Account;
if ( bannedAccount != null && bannedAccount == theirAccount )
return true;
}
return false;
}
public bool HasAccess( Mobile m )
{
if ( m == null )
return false;
if ( m.AccessLevel > AccessLevel.Player || IsFriend( m ) || ( m_Access != null && m_Access.Contains( m ) ) )
return true;
if ( m is BaseCreature )
{
BaseCreature bc = (BaseCreature)m;
if ( bc.NoHouseRestrictions )
return true;
if ( bc.Controlled || bc.Summoned )
{
m = bc.ControlMaster;
if ( m == null )
m = bc.SummonMaster;
if ( m == null )
return false;
if ( m.AccessLevel > AccessLevel.Player || IsFriend( m ) || ( m_Access != null && m_Access.Contains( m ) ) )
return true;
}
}
return false;
}
public new bool IsLockedDown( Item check )
{
if ( check == null )
return false;
if ( m_LockDowns == null )
return false;
return ( m_LockDowns.Contains( check ) || VendorRentalContracts.Contains( check ) );
}
public new bool IsSecure( Item item )
{
if ( item == null )
return false;
if ( m_Secures == null )
return false;
bool contains = false;
for ( int i = 0; !contains && i < m_Secures.Count; ++i )
contains = ( ((SecureInfo)m_Secures).Item == item );
return contains;
}
public virtual Guildstone FindGuildstone()
{
Map map = this.Map;
if ( map == null )
return null;
MultiComponentList mcl = Components;
IPooledEnumerable eable = map.GetItemsInBounds( new Rectangle2D( X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height ) );
foreach ( Item item in eable )
{
if ( item is Guildstone && Contains( item ) )
{
eable.Free();
return (Guildstone)item;
}
}
eable.Free();
return null;
}
}
public enum DecayType
{
Ageless,
AutoRefresh,
ManualRefresh,
Condemned
}
public enum DecayLevel
{
Ageless,
LikeNew,
Slightly,
Somewhat,
Fairly,
Greatly,
IDOC,
Collapsed,
DemolitionPending
}
public enum SecureAccessResult
{
Insecure,
Accessible,
Inaccessible
}
public enum SecureLevel
{
Owner,
CoOwners,
Friends,
Anyone,
Guild
}
public class SecureInfo : ISecurable
{
private Container m_Item;
private SecureLevel m_Level;
public Container Item{ get{ return m_Item; } }
public SecureLevel Level{ get{ return m_Level; } set{ m_Level = value; } }
public SecureInfo( Container item, SecureLevel level )
{
m_Item = item;
m_Level = level;
}
public SecureInfo( GenericReader reader )
{
m_Item = reader.ReadItem() as Container;
m_Level = (SecureLevel)reader.ReadByte();
}
public void Serialize( GenericWriter writer )
{
writer.Write( m_Item );
writer.Write( (byte) m_Level );
}
}
public class RelocatedEntity
{
private IEntity m_Entity;
private Point3D m_RelativeLocation;
public IEntity Entity
{
get{ return m_Entity; }
}
public Point3D RelativeLocation
{
get{ return m_RelativeLocation; }
}
public RelocatedEntity( IEntity entity, Point3D relativeLocation )
{
m_Entity = entity;
m_RelativeLocation = relativeLocation;
}
}
public class LockdownTarget : Target
{
private bool m_Release;
private BaseHouse m_House;
public LockdownTarget( bool release, BaseHouse house ) : base( 12, false, TargetFlags.None )
{
CheckLOS = false;
m_Release = release;
m_House = house;
}
protected override void OnTargetNotAccessible( Mobile from, object targeted )
{
OnTarget( from, targeted );
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsCoOwner( from ) )
return;
if ( targeted is Item )
{
if ( m_Release )
{
m_House.Release( from, (Item)targeted );
}
else
{
if ( targeted is VendorRentalContract || ( targeted is Container && ((Container)targeted).FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1062392 ); // You must double click the contract in your pack to lock it down.
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501732 ); // I cannot lock this down!
}
else
{
m_House.LockDown( from, (Item)targeted );
}
}
}
else
{
from.SendLocalizedMessage( 1005377 );//You cannot lock that down
}
}
}
public class SecureTarget : Target
{
private bool m_Release;
private BaseHouse m_House;
public SecureTarget( bool release, BaseHouse house ) : base( 12, false, TargetFlags.None )
{
CheckLOS = false;
m_Release = release;
m_House = house;
}
protected override void OnTargetNotAccessible( Mobile from, object targeted )
{
OnTarget( from, targeted );
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsCoOwner( from ) )
return;
if ( targeted is Item )
{
if ( m_Release )
{
m_House.ReleaseSecure( from, (Item)targeted );
}
else
{
if ( targeted is VendorRentalContract || ( targeted is Container && ((Container)targeted).FindItemByType( typeof( VendorRentalContract ) ) != null ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1062392 ); // You must double click the contract in your pack to lock it down.
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501732 ); // I cannot lock this down!
}
else
{
m_House.AddSecure( from, (Item)targeted );
}
}
}
else
{
from.SendLocalizedMessage( 1010424 );//You cannot secure this
}
}
}
public class HouseKickTarget : Target
{
private BaseHouse m_House;
public HouseKickTarget( BaseHouse house ) : base( -1, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsFriend( from ) )
return;
if ( targeted is Mobile )
{
m_House.Kick( from, (Mobile)targeted );
}
else
{
from.SendLocalizedMessage( 501347 );//You cannot eject that from the house!
}
}
}
public class HouseBanTarget : Target
{
private BaseHouse m_House;
private bool m_Banning;
public HouseBanTarget( bool ban, BaseHouse house ) : base( -1, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
m_Banning = ban;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsFriend( from ) )
return;
if ( targeted is Mobile )
{
if ( m_Banning )
m_House.Ban( from, (Mobile)targeted );
else
m_House.RemoveBan( from, (Mobile)targeted );
}
else
{
from.SendLocalizedMessage( 501347 );//You cannot eject that from the house!
}
}
}
public class HouseAccessTarget : Target
{
private BaseHouse m_House;
public HouseAccessTarget( BaseHouse house ) : base( -1, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsFriend( from ) )
return;
if ( targeted is Mobile )
m_House.GrantAccess( from, (Mobile)targeted );
else
from.SendLocalizedMessage( 1060712 ); // That is not a player.
}
}
public class CoOwnerTarget : Target
{
private BaseHouse m_House;
private bool m_Add;
public CoOwnerTarget( bool add, BaseHouse house ) : base( 12, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
m_Add = add;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsOwner( from ) )
return;
if ( targeted is Mobile )
{
if ( m_Add )
m_House.AddCoOwner( from, (Mobile)targeted );
else
m_House.RemoveCoOwner( from, (Mobile)targeted );
}
else
{
from.SendLocalizedMessage( 501362 );//That can't be a coowner
}
}
}
public class HouseFriendTarget : Target
{
private BaseHouse m_House;
private bool m_Add;
public HouseFriendTarget( bool add, BaseHouse house ) : base( 12, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
m_Add = add;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !from.Alive || m_House.Deleted || !m_House.IsCoOwner( from ) )
return;
if ( targeted is Mobile )
{
if ( m_Add )
m_House.AddFriend( from, (Mobile)targeted );
else
m_House.RemoveFriend( from, (Mobile)targeted );
}
else
{
from.SendLocalizedMessage( 501371 ); // That can't be a friend
}
}
}
public class HouseOwnerTarget : Target
{
private BaseHouse m_House;
public HouseOwnerTarget( BaseHouse house ) : base( 12, false, TargetFlags.None )
{
CheckLOS = false;
m_House = house;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
m_House.BeginConfirmTransfer( from, (Mobile)targeted );
else
from.SendLocalizedMessage( 501384 ); // Only a player can own a house!
}
}
public class SetSecureLevelEntry : ContextMenuEntry
{
private Item m_Item;
private ISecurable m_Securable;
public SetSecureLevelEntry( Item item, ISecurable securable ) : base( 6203, 6 )
{
m_Item = item;
m_Securable = securable;
}
public static ISecurable GetSecurable( Mobile from, Item item )
{
BaseHouse house = BaseHouse.FindHouseAt( item );
if ( house == null || !house.IsOwner( from ) || !house.IsAosRules )
return null;
ISecurable sec = null;
if ( item is ISecurable )
{
bool isOwned = house.Doors.Contains( item );
if ( !isOwned )
isOwned = ( house is HouseFoundation && ((HouseFoundation)house).IsFixture( item ) );
if ( !isOwned )
isOwned = house.IsLockedDown( item );
if ( isOwned )
sec = (ISecurable)item;
}
else
{
ArrayList list = house.Secures;
for ( int i = 0; sec == null && list != null && i < list.Count; ++i )
{
SecureInfo si = (SecureInfo)list;
if ( si.Item == item )
sec = si;
}
}
return sec;
}
public static void AddTo( Mobile from, Item item, List<ContextMenuEntry> list )
{
ISecurable sec = GetSecurable( from, item );
if ( sec != null )
list.Add( new SetSecureLevelEntry( item, sec ) );
}
public override void OnClick()
{
ISecurable sec = GetSecurable( Owner.From, m_Item );
if ( sec != null )
Owner.From.SendGump( new SetSecureLevelGump( Owner.From, sec, BaseHouse.FindHouseAt( m_Item ) ) );
}
}
}


Thanks again Tru
 

madron

Wanderer
Tru I figured this out and I am posting for others in case they run into this issue.

My issue was with City Limits, the house was within the city limits, and it was static. I had this for my first level 50; // 200x200 Area, however it did not like that, as soon as I realized my error and changed the line to 100;// 200x200 players were able to purchase static houing using townhouse script and be joined ont he stone without any crashes or errors. This was a tough one as it was pointing to townhouse script, but was in fact my own math calculations... :p *note..never do math on 4 hours of sleep at 10 pm int he evening**

*smiles from ear to ear*

thank you for your help Tru, your always a great help to me :)
 

Avelyn

Sorceror
Sorry, I have been on a UO break for a while, but I figured I would stick this out there for folks using the system :)

See first page for ver 2.21
 

EvilPounder

Wanderer
this is the error that i get... anyone know how to fix it?


Code:
Errors:
 + Custom Scripts/Misc/Player Government System 2[1].21/Government System/PlayerGovernmentSystem.cs:
    CS1502: Line 280: The best overloaded method match for 'System.Collections.Generic.List<Server.Multis.BaseHouse>.AddRange(Sy
stem.Collections.Generic.IEnumerable<Server.Multis.BaseHouse>)' has some invalid arguments
    CS1503: Line 280: Argument '1': cannot convert from 'System.Collections.ArrayList' to 'System.Collections.Generic.IEnumerabl
e<Server.Multis.BaseHouse>'
    CS0029: Line 292: Cannot implicitly convert type 'System.Collections.ArrayList' to 'System.Collections.Generic.List<Server.M
ultis.BaseHouse>'



this is my PlayerGovernmentSystem.cs script

Code:
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Mobiles;
using Server.Regions;
using Server.Accounting;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.IO;
using System.Globalization;

namespace Server
{
	public class PlayerGovernmentSystem
	{
		//System Version
		public static readonly string SystemVersion = "2.21";
		public static string FileName = "Data/GovernmentVersion.xml";
		public static string FileVersion = "0.0";
				
		//Forensics Requirement
		public static bool NeedsForensics = false;
		public static double ForensicsRequirement = 35.0;
		
		// Global Start Timer
		public static readonly TimeSpan StartUpdate = TimeSpan.FromHours( 24.0 ); // Default 1140 = 24 hours

		// City Update Time
		public static readonly TimeSpan CityUpdate = TimeSpan.FromDays( 1.0 ); // Default 10080 = 7 days

		// Mayor Voting Time
		public static readonly TimeSpan VoteUpdate = TimeSpan.FromDays( 120.0 ); // Default 20160 = 14 Days

		// Staring Treasury Amount RECOMMENDED: At least 20k so if player forgets to add, and dont lose on first update.
		public static int TreasuryAmount = 20000; // Default 20000

		// Level 1 City Limit Offset // See Docs On How To Set this.
		public static int L1CLOffset = 25; // 50x50 Area

		// Level 2 City Limit Offset // See Docs On How To Set this.
		public static int L2CLOffset = 38; // 75x75 Area (Is really 76x76)

		// Level 3 City Limit Offset // See Docs On How To Set this.
		public static int L3CLOffset = 50; // 100x100 Area

		// Level 4 City Limit Offset // See Docs On How To Set this.
		public static int L4CLOffset = 75; // 150x150 Area

		// Level 5 City Limit Offset // See Docs On How To Set this.
		public static int L5CLOffset = 88; // 175x175 Area (Is really 176x176)

		// Level 6 City Limit Offset // See Docs On How To Set this.
		public static int L6CLOffset = 100; // 200x200 Area

		// Set the amount of tiles the system checks for cities in range. // See Docs On How To Set This.
		public static int CityRangeOffset = 100; // 200x200 Area

		// Number of Max Lockdowns per City, Per Level
		public static int Level1LD = 10; // Default 10
		public static int Level2LD = 50; // Default 50
		public static int Level3LD = 100; // Default 100
		public static int Level4LD = 200; // Default 200
		public static int Level5LD = 300; // Default 300
		public static int Level6LD = 500; // Default 500

		// Number of citizens needed for each city level.
		public static int Level1 = 12; // Default 20 12
		public static int Level2 = 20; // Default 40 20
		public static int Level3 = 35; // Default 60 35
		public static int Level4 = 45; // Default 80 45
		public static int Level5 = 50; // Default 100 50
		public static int Level6 = 56; // Default 200 55

		/*
		* Member Rules
		*
		* As long as a member has a house withing the city limits they can bacome an member of the city.
		* Member cannot be a member of another city. Unless multi houses per account is enabled.
		* However the same member cannot be a member of 2 differant cities.
		* A member can join as many charactors to the city from thier account as they wish.
		* Each charactor from the members account counts as a member to the citys total population.
		* So in theory one account counts as 6 members to the city. (If 6 chars are enabled.) & if all are joined.
		*/

		// Title for cities at each level.
		public static string Title1 = "outpost";
		public static string Title2 = "village";
		public static string Title3 = "township";
		public static string Title4 = "city";
		public static string Title5 = "metropolis";
		public static string Title6 = "empire";

		// Enable city placement for Ilshenar (Note: need to let players place houses as well in ilsh.)
		public static bool EnableIlshenar = false;

		// Max amounts of cities per map.
		public static int MaxCitiesForFelucca = 25;
		public static int MaxCitiesForTrammel = 25;
		public static int MaxCitiesForIlshenar = 0; //No Housing In Ilshenar.. However can be changed.
		public static int MaxCitiesForMalas = 0;
		public static int MaxCitiesForTokuno = 0;

		//Max number of citizens per city
		public static int MaxCitizensPerCity = 300;

		//Max number of banned players NOTE: if 0 will disable city banning.
		public static int MaxBannedPerCity = 50;
		
		public static void Initialize()
		{
			CheckCitySystemVersion();
		}
		
		
		public static void PlaceCityHall( Mobile from, Point3D p, CityDeed deed )
		{
			if ( CheckPlacement( from, p, deed.MultiID, deed.Offset ) )
			{
				if ( !CheckCitiesInRange( from, p ) )
				{
					deed.FinishPlacement( from, p );
					from.SendGump( new CityWarningGump() );
				}
				else
				{
					int offset = CityRangeOffset * 2;

					from.SendMessage( "Another city is to close to place your city hall here." );
					from.SendMessage( 38, "You must be at least {0} yards (Steps) away from any other city in order to place your city hall.", offset );
				}
			}
		}

		public static void PlaceCivic( Mobile from, Point3D p, CityDeed deed )
		{
			if ( CheckPlacement( from, p, deed.MultiID, deed.Offset ) )
			{
				deed.FinishPlacement( from, p );
			}
		}

		public static bool CheckPlacement( Mobile from, Point3D p, int multiId, Point3D offset )
		{
			ArrayList toMove;
			Point3D center = new Point3D( p.X - offset.X, p.Y - offset.Y, p.Z - offset.Z );
			HousePlacementResult res = HousePlacement.Check( from, multiId, center, out toMove );

			if ( res == HousePlacementResult.Valid )
			{
				return true;
			}
			else if ( res == HousePlacementResult.BadItem || res == HousePlacementResult.BadLand || res == HousePlacementResult.BadStatic || res == HousePlacementResult.BadRegionHidden )
			{
				from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
				return false;
			}
			else if ( res == HousePlacementResult.NoSurface )
			{
				from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
				return false;
			}
			else if ( res == HousePlacementResult.BadRegion )
			{
				from.SendLocalizedMessage( 501265 ); // Housing cannot be created in this area.
				return false;
			}
			else
			{
				return false;
			}
		}

		public static bool CheckIfInIlsh( Mobile from )
		{
			if ( from.Map == Map.Ilshenar && EnableIlshenar == false )
				return true;
			
			return false;
		}

		public static bool CheckIfCanBeMayor( Mobile from )
		{
			if ( NeedsForensics )
				if ( from.Skills[SkillName.Forensics].Base >= 35.0 )
				return true;
				else return false;
			else
				return true;

		}

		public static bool CheckCitiesInRange( Mobile from, Point3D p )
		{
			// Very Speical Thanks To ArteGordon For His Help On This Bool

			Map map = from.Map;

			int offset = CityRangeOffset;
			int offset2 = offset * 3;

			int x1 = p.X - offset;
			int y1 = p.Y - offset;
			int width = offset2;
			int height = offset2;

			int depth = p.Z;

			for( int x = x1; x <= x1 + width; x += Map.SectorSize )
			{
				for( int y = y1; y <= y1 + height; y += Map.SectorSize )
				{
					Sector s = map.GetSector( new Point3D( x, y, depth ) );
		
					foreach ( RegionRect rect in s.RegionRects )
					{
						Region r = rect.Region;
						if ( r is GuardedRegion || r is PlayerCityRegion ) 
							return true;
						
					}
				}
			}	

			return false;
		}

		public static bool CheckIfMayor( Mobile from )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;
					if ( stone.Mayor == from )
						return true;
				}
			}

			return false;
		}

		public static bool CheckIfCitizen( Mobile from )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;
					foreach ( Mobile m in stone.Citizens )
					{
						if ( from == m )
							return true;
					}
				}
			}

			return false;
		}

		public static List<BaseHouse> GetAllHouses( Mobile m ) // thanks to bripbrip
		{
			List<BaseHouse> allHouses = new List<BaseHouse>();
			
			Account a = m.Account as Account;

			if ( a == null )
				return allHouses;
			

			for ( int i = 0; i < a.Length; ++i )
			{
				Mobile mob = a[i];

				if ( mob != null )
					allHouses.AddRange( BaseHouse.GetHouses( mob ) );
			}
			return allHouses;
		}
		
		public static bool CheckIfHouseInCity( Mobile from, Region region )
		{
			if ( from == null )
				return false;

			if ( region == null )
				return false;
			List<BaseHouse> list = BaseHouse.GetHouses( from );
			if ( list != null )
			{
				for ( int i = 0; i < list.Count; i++ )
				{
					BaseHouse h = list[i];
					if ( h != null )
					{
						int X = h.Sign.X;
						int Y = h.Sign.Y + 1;
						int Z = h.Sign.Z;
						
						
						Point3D hsp = new Point3D( X, Y, Z );
						Map hsm = h.Sign.Map;

						Region reg = Region.Find( hsp, hsm );
						
						if( reg == region )
							return true;
						else if ( list.Count > 1 && i < (list.Count - 1) )
							continue;
						else
						{
							
							return false;
						}
					}
				  }
			}
			
			foreach ( BaseHouse h in GetAllHouses( from ) )
			{
				if ( h != null )
				{
					int X = h.Sign.X;
					int Y = h.Sign.Y + 1;
					int Z = h.Sign.Z;
					
					
					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = h.Sign.Map;

					Region reg = Region.Find( hsp, hsm );
					if ( reg == region )
					{
						Mobile owner = h.Owner;
						Account acct = (Account)from.Account;
						Account acct2 = (Account)owner.Account;
						if ( acct == null || acct2 == null )
							return false;
						else if ( acct == acct2 )
							return true;
						else
							continue;
						
					}
					else
						continue;
				}
				else
				{
					
					return false;
				}
			}
			
			return false;
			
			
			
		}

		public static bool CheckMapCityLimit( Mobile from )
		{
			ArrayList count = new ArrayList();

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					if ( item.Map == from.Map )
						count.Add( item );
				}
			}

			if ( from.Map == Map.Felucca )
			{
				if ( count.Count >= MaxCitiesForFelucca )
					return true;
			}
			else if ( from.Map == Map.Trammel )
			{
				if ( count.Count >= MaxCitiesForTrammel )
					return true;
			}
			else if ( from.Map == Map.Ilshenar )
			{
				if ( count.Count >= MaxCitiesForIlshenar )
					return true;
			}
			else if ( from.Map == Map.Malas )
			{
				if ( count.Count >= MaxCitiesForMalas )
					return true;
			}
			else if ( from.Map == Map.Tokuno )
			{
				if ( count.Count >= MaxCitiesForTokuno )
					return true;
			}
			else
			{
				return true;
			}

			return false;
		}

		public static bool CheckCityName( string text )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;

					if ( stone.CityName == text )
						return true;
				}
			}

			return false;
		}

		public static bool CheckIfBanned( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				if ( target.Region is PlayerCityRegion && from.Region is PlayerCityRegion )
				{
					PlayerMobile pm = (PlayerMobile)from;
					CityManagementStone stone = pm.City;

					if ( stone != null )
					{
						if ( stone.PCRegion == target.Region )
						{
							bool isBanned = false;
							bool isMember = false;

							foreach ( Mobile checkBan in stone.Banned )
							{
								if ( target == checkBan )
									isBanned = true;
							}
	
							foreach ( Mobile checkMem in stone.Citizens )
							{
								if ( from == checkMem )
									isMember = true;
							}

							if ( isBanned == true && isMember == true )
								return true;
						}
					}
				}
			}

			return false;
		}

		public static bool CheckBanLootable( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				if ( from.Region is PlayerCityRegion )
				{
					PlayerMobile pm = (PlayerMobile)from;
					CityManagementStone stone = pm.City;

					if ( stone != null )
					{
						bool isBanned = false;

						foreach ( Mobile checkBan in stone.Banned )
						{
							if ( target == checkBan )
								isBanned = true;
						}

						if ( isBanned == true )
							return true;
					}
				}
			}

			return false;
		}

		public static bool CheckAtWarWith( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				PlayerMobile pm1 = (PlayerMobile)from;
				PlayerMobile pm2 = (PlayerMobile)target;
				CityManagementStone fromCity = pm1.City;
				CityManagementStone targCity = pm2.City;

				if ( fromCity != null && targCity != null )
				{
					if ( fromCity.Waring.Contains( targCity ) )
						return true;
				}
			}

			return false;
		}

		public static bool CheckCityAlly( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				PlayerMobile pm1 = (PlayerMobile)from;
				PlayerMobile pm2 = (PlayerMobile)target;
				CityManagementStone fromCity = pm1.City;
				CityManagementStone targCity = pm2.City;

				if ( fromCity != null )
				{
					if ( fromCity.Citizens.Contains( target ) )
						return true;

					if ( fromCity.Allegiances.Contains( targCity ) )
						return true;
				}
			}

			return false;
		}

		public static bool IsCityLevelReached( Mobile from, int level )
		{
			PlayerMobile pm = (PlayerMobile)from;

			if ( pm.City.Mayor == from )
			{
				if ( pm.City.Level >= level )
					return true;
			}

			return false;
		}

		public static bool IsAtCity( Mobile from, Mobile to )
		{
			PlayerMobile pm = (PlayerMobile)from;
			CityManagementStone city = pm.City;
			Region cityreg = Region.Find( from.Location, from.Map );
			Region targregion = Region.Find( to.Location, to.Map );
			
			if ( city != null && cityreg != null && targregion != null )
			{
				if ( ( cityreg == city.PCRegion ) && ( cityreg == targregion ) )
					return true;
			}
			
			return false;

			
		}
		
		
		public static bool IsAtCity( Mobile from )
		{
			PlayerMobile pm = (PlayerMobile)from;
			CityManagementStone city = pm.City;
			Region cityreg = Region.Find( from.Location, from.Map );

			if ( cityreg != null && city != null )
			{
				if ( cityreg == city.PCRegion )
					return true;
			}
				

			return false;
		}
		
		public static bool IsAtCity( Item item )
		{
			Region reg = Region.Find( item.Location, item.Map );
				
			if ( reg != null )
			{
				if ( reg is PlayerCityRegion )
					return true;
				else
					return false;
			}
			return false;
					
		}
		
			
		
		
		public static bool IsMemberOf( Mobile from, CityManagementStone stone )
		{
			PlayerMobile pm = (PlayerMobile)from;
			if ( pm.City == null )
				return false;
			
			foreach ( Mobile mob in stone.Citizens )
			{
				if ( mob == from )
				{
					return true;
					break;
				}
			}
			return false;
		}
		
		public static Rectangle3D[] FormatRegion( Rectangle2D box )
		{
				Rectangle3D area = Server.Region.ConvertTo3D( box );
				List<Rectangle3D> arealist = new List<Rectangle3D>();
				arealist.Add( area );
				Rectangle3D[] regarea = arealist.ToArray();
				return regarea;
		}
		
		public static bool IsIteminCity( Mobile from, Item item )
		{
			PlayerMobile pm = (PlayerMobile)from;
			if ( pm.City == null )
				return false;
			else
			{
				CityManagementStone stone = pm.City;
				Point3D p = new Point3D( item.X, item.Y, item.Z );
				Region target = Region.Find( p, item.Map );
				if ( stone.PCRegion == target )
					return true;
				else
					return false;
			}
			
			
		}
		
		public static bool AreThereVendors( Mobile from )
		{
			
			if ( from == null )
				return false;
			
			foreach ( BaseHouse h in BaseHouse.GetHouses( from ) )
			{
				if ( h != null )
				{
					if ( h.HasPersonalVendors || h.HasRentedVendors )
						return true;
					else 
						return false;
				}
				
			}
			return false;
		}
		
		public static void CheckCitySystemVersion()
		{
		
			 bool SystemUpgrade = false;
			
			if ( !File.Exists( FileName ) )
				SystemUpgrade = true;
			else
			{
				try
				{
					XmlDocument xml = new XmlDocument();
					xml.Load( FileName );
					
					XmlElement system = xml["Version"];
					FileVersion = system.InnerText;
															
					if ( FileVersion == "0.0" )
					{
						Console.WriteLine( "Government System: Error Loading Version Variable!" );
						return;
					}
					if ( FileVersion != SystemVersion )
						SystemUpgrade = true;
					
					
				}
				catch
				{
					Console.WriteLine( "Error Reading City Version File!" );
					return;
				}
				
			}
			if ( SystemUpgrade )
				Console.WriteLine( "The city system needs to be upgraded, please run the [upgradecitysystem command!" );
			else
				Console.WriteLine( "City system current.  Version {0}", SystemVersion );
				
		}
			
	}
}
 

Tru

Knight
EvilPounder;733154 said:
this is the error that i get... anyone know how to fix it?


Code:
Errors:
 + Custom Scripts/Misc/Player Government System 2[1].21/Government System/PlayerGovernmentSystem.cs:
    CS1502: Line 280: The best overloaded method match for 'System.Collections.Generic.List<Server.Multis.BaseHouse>.AddRange(Sy
stem.Collections.Generic.IEnumerable<Server.Multis.BaseHouse>)' has some invalid arguments
    CS1503: Line 280: Argument '1': cannot convert from 'System.Collections.ArrayList' to 'System.Collections.Generic.IEnumerabl
e<Server.Multis.BaseHouse>'
    CS0029: Line 292: Cannot implicitly convert type 'System.Collections.ArrayList' to 'System.Collections.Generic.List<Server.M
ultis.BaseHouse>'



this is my PlayerGovernmentSystem.cs script

Code:
using System;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Multis;
using Server.Mobiles;
using Server.Regions;
using Server.Accounting;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.IO;
using System.Globalization;

namespace Server
{
	public class PlayerGovernmentSystem
	{
		//System Version
		public static readonly string SystemVersion = "2.21";
		public static string FileName = "Data/GovernmentVersion.xml";
		public static string FileVersion = "0.0";
				
		//Forensics Requirement
		public static bool NeedsForensics = false;
		public static double ForensicsRequirement = 35.0;
		
		// Global Start Timer
		public static readonly TimeSpan StartUpdate = TimeSpan.FromHours( 24.0 ); // Default 1140 = 24 hours

		// City Update Time
		public static readonly TimeSpan CityUpdate = TimeSpan.FromDays( 1.0 ); // Default 10080 = 7 days

		// Mayor Voting Time
		public static readonly TimeSpan VoteUpdate = TimeSpan.FromDays( 120.0 ); // Default 20160 = 14 Days

		// Staring Treasury Amount RECOMMENDED: At least 20k so if player forgets to add, and dont lose on first update.
		public static int TreasuryAmount = 20000; // Default 20000

		// Level 1 City Limit Offset // See Docs On How To Set this.
		public static int L1CLOffset = 25; // 50x50 Area

		// Level 2 City Limit Offset // See Docs On How To Set this.
		public static int L2CLOffset = 38; // 75x75 Area (Is really 76x76)

		// Level 3 City Limit Offset // See Docs On How To Set this.
		public static int L3CLOffset = 50; // 100x100 Area

		// Level 4 City Limit Offset // See Docs On How To Set this.
		public static int L4CLOffset = 75; // 150x150 Area

		// Level 5 City Limit Offset // See Docs On How To Set this.
		public static int L5CLOffset = 88; // 175x175 Area (Is really 176x176)

		// Level 6 City Limit Offset // See Docs On How To Set this.
		public static int L6CLOffset = 100; // 200x200 Area

		// Set the amount of tiles the system checks for cities in range. // See Docs On How To Set This.
		public static int CityRangeOffset = 100; // 200x200 Area

		// Number of Max Lockdowns per City, Per Level
		public static int Level1LD = 10; // Default 10
		public static int Level2LD = 50; // Default 50
		public static int Level3LD = 100; // Default 100
		public static int Level4LD = 200; // Default 200
		public static int Level5LD = 300; // Default 300
		public static int Level6LD = 500; // Default 500

		// Number of citizens needed for each city level.
		public static int Level1 = 12; // Default 20 12
		public static int Level2 = 20; // Default 40 20
		public static int Level3 = 35; // Default 60 35
		public static int Level4 = 45; // Default 80 45
		public static int Level5 = 50; // Default 100 50
		public static int Level6 = 56; // Default 200 55

		/*
		* Member Rules
		*
		* As long as a member has a house withing the city limits they can bacome an member of the city.
		* Member cannot be a member of another city. Unless multi houses per account is enabled.
		* However the same member cannot be a member of 2 differant cities.
		* A member can join as many charactors to the city from thier account as they wish.
		* Each charactor from the members account counts as a member to the citys total population.
		* So in theory one account counts as 6 members to the city. (If 6 chars are enabled.) & if all are joined.
		*/

		// Title for cities at each level.
		public static string Title1 = "outpost";
		public static string Title2 = "village";
		public static string Title3 = "township";
		public static string Title4 = "city";
		public static string Title5 = "metropolis";
		public static string Title6 = "empire";

		// Enable city placement for Ilshenar (Note: need to let players place houses as well in ilsh.)
		public static bool EnableIlshenar = false;

		// Max amounts of cities per map.
		public static int MaxCitiesForFelucca = 25;
		public static int MaxCitiesForTrammel = 25;
		public static int MaxCitiesForIlshenar = 0; //No Housing In Ilshenar.. However can be changed.
		public static int MaxCitiesForMalas = 0;
		public static int MaxCitiesForTokuno = 0;

		//Max number of citizens per city
		public static int MaxCitizensPerCity = 300;

		//Max number of banned players NOTE: if 0 will disable city banning.
		public static int MaxBannedPerCity = 50;
		
		public static void Initialize()
		{
			CheckCitySystemVersion();
		}
		
		
		public static void PlaceCityHall( Mobile from, Point3D p, CityDeed deed )
		{
			if ( CheckPlacement( from, p, deed.MultiID, deed.Offset ) )
			{
				if ( !CheckCitiesInRange( from, p ) )
				{
					deed.FinishPlacement( from, p );
					from.SendGump( new CityWarningGump() );
				}
				else
				{
					int offset = CityRangeOffset * 2;

					from.SendMessage( "Another city is to close to place your city hall here." );
					from.SendMessage( 38, "You must be at least {0} yards (Steps) away from any other city in order to place your city hall.", offset );
				}
			}
		}

		public static void PlaceCivic( Mobile from, Point3D p, CityDeed deed )
		{
			if ( CheckPlacement( from, p, deed.MultiID, deed.Offset ) )
			{
				deed.FinishPlacement( from, p );
			}
		}

		public static bool CheckPlacement( Mobile from, Point3D p, int multiId, Point3D offset )
		{
			ArrayList toMove;
			Point3D center = new Point3D( p.X - offset.X, p.Y - offset.Y, p.Z - offset.Z );
			HousePlacementResult res = HousePlacement.Check( from, multiId, center, out toMove );

			if ( res == HousePlacementResult.Valid )
			{
				return true;
			}
			else if ( res == HousePlacementResult.BadItem || res == HousePlacementResult.BadLand || res == HousePlacementResult.BadStatic || res == HousePlacementResult.BadRegionHidden )
			{
				from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
				return false;
			}
			else if ( res == HousePlacementResult.NoSurface )
			{
				from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
				return false;
			}
			else if ( res == HousePlacementResult.BadRegion )
			{
				from.SendLocalizedMessage( 501265 ); // Housing cannot be created in this area.
				return false;
			}
			else
			{
				return false;
			}
		}

		public static bool CheckIfInIlsh( Mobile from )
		{
			if ( from.Map == Map.Ilshenar && EnableIlshenar == false )
				return true;
			
			return false;
		}

		public static bool CheckIfCanBeMayor( Mobile from )
		{
			if ( NeedsForensics )
				if ( from.Skills[SkillName.Forensics].Base >= 35.0 )
				return true;
				else return false;
			else
				return true;

		}

		public static bool CheckCitiesInRange( Mobile from, Point3D p )
		{
			// Very Speical Thanks To ArteGordon For His Help On This Bool

			Map map = from.Map;

			int offset = CityRangeOffset;
			int offset2 = offset * 3;

			int x1 = p.X - offset;
			int y1 = p.Y - offset;
			int width = offset2;
			int height = offset2;

			int depth = p.Z;

			for( int x = x1; x <= x1 + width; x += Map.SectorSize )
			{
				for( int y = y1; y <= y1 + height; y += Map.SectorSize )
				{
					Sector s = map.GetSector( new Point3D( x, y, depth ) );
		
					foreach ( RegionRect rect in s.RegionRects )
					{
						Region r = rect.Region;
						if ( r is GuardedRegion || r is PlayerCityRegion ) 
							return true;
						
					}
				}
			}	

			return false;
		}

		public static bool CheckIfMayor( Mobile from )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;
					if ( stone.Mayor == from )
						return true;
				}
			}

			return false;
		}

		public static bool CheckIfCitizen( Mobile from )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;
					foreach ( Mobile m in stone.Citizens )
					{
						if ( from == m )
							return true;
					}
				}
			}

			return false;
		}

		public static List<BaseHouse> GetAllHouses( Mobile m ) // thanks to bripbrip
		{
			List<BaseHouse> allHouses = new List<BaseHouse>();
			
			Account a = m.Account as Account;

			if ( a == null )
				return allHouses;
			

			for ( int i = 0; i < a.Length; ++i )
			{
				Mobile mob = a[i];

				if ( mob != null )
					allHouses.AddRange( BaseHouse.GetHouses( mob ) );
			}
			return allHouses;
		}
		
		public static bool CheckIfHouseInCity( Mobile from, Region region )
		{
			if ( from == null )
				return false;

			if ( region == null )
				return false;
			List<BaseHouse> list = BaseHouse.GetHouses( from );
			if ( list != null )
			{
				for ( int i = 0; i < list.Count; i++ )
				{
					BaseHouse h = list[i];
					if ( h != null )
					{
						int X = h.Sign.X;
						int Y = h.Sign.Y + 1;
						int Z = h.Sign.Z;
						
						
						Point3D hsp = new Point3D( X, Y, Z );
						Map hsm = h.Sign.Map;

						Region reg = Region.Find( hsp, hsm );
						
						if( reg == region )
							return true;
						else if ( list.Count > 1 && i < (list.Count - 1) )
							continue;
						else
						{
							
							return false;
						}
					}
				  }
			}
			
			foreach ( BaseHouse h in GetAllHouses( from ) )
			{
				if ( h != null )
				{
					int X = h.Sign.X;
					int Y = h.Sign.Y + 1;
					int Z = h.Sign.Z;
					
					
					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = h.Sign.Map;

					Region reg = Region.Find( hsp, hsm );
					if ( reg == region )
					{
						Mobile owner = h.Owner;
						Account acct = (Account)from.Account;
						Account acct2 = (Account)owner.Account;
						if ( acct == null || acct2 == null )
							return false;
						else if ( acct == acct2 )
							return true;
						else
							continue;
						
					}
					else
						continue;
				}
				else
				{
					
					return false;
				}
			}
			
			return false;
			
			
			
		}

		public static bool CheckMapCityLimit( Mobile from )
		{
			ArrayList count = new ArrayList();

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					if ( item.Map == from.Map )
						count.Add( item );
				}
			}

			if ( from.Map == Map.Felucca )
			{
				if ( count.Count >= MaxCitiesForFelucca )
					return true;
			}
			else if ( from.Map == Map.Trammel )
			{
				if ( count.Count >= MaxCitiesForTrammel )
					return true;
			}
			else if ( from.Map == Map.Ilshenar )
			{
				if ( count.Count >= MaxCitiesForIlshenar )
					return true;
			}
			else if ( from.Map == Map.Malas )
			{
				if ( count.Count >= MaxCitiesForMalas )
					return true;
			}
			else if ( from.Map == Map.Tokuno )
			{
				if ( count.Count >= MaxCitiesForTokuno )
					return true;
			}
			else
			{
				return true;
			}

			return false;
		}

		public static bool CheckCityName( string text )
		{

			foreach ( Item item in World.Items.Values )
			{
				if ( item is CityManagementStone )
				{
					CityManagementStone stone = (CityManagementStone)item;

					if ( stone.CityName == text )
						return true;
				}
			}

			return false;
		}

		public static bool CheckIfBanned( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				if ( target.Region is PlayerCityRegion && from.Region is PlayerCityRegion )
				{
					PlayerMobile pm = (PlayerMobile)from;
					CityManagementStone stone = pm.City;

					if ( stone != null )
					{
						if ( stone.PCRegion == target.Region )
						{
							bool isBanned = false;
							bool isMember = false;

							foreach ( Mobile checkBan in stone.Banned )
							{
								if ( target == checkBan )
									isBanned = true;
							}
	
							foreach ( Mobile checkMem in stone.Citizens )
							{
								if ( from == checkMem )
									isMember = true;
							}

							if ( isBanned == true && isMember == true )
								return true;
						}
					}
				}
			}

			return false;
		}

		public static bool CheckBanLootable( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				if ( from.Region is PlayerCityRegion )
				{
					PlayerMobile pm = (PlayerMobile)from;
					CityManagementStone stone = pm.City;

					if ( stone != null )
					{
						bool isBanned = false;

						foreach ( Mobile checkBan in stone.Banned )
						{
							if ( target == checkBan )
								isBanned = true;
						}

						if ( isBanned == true )
							return true;
					}
				}
			}

			return false;
		}

		public static bool CheckAtWarWith( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				PlayerMobile pm1 = (PlayerMobile)from;
				PlayerMobile pm2 = (PlayerMobile)target;
				CityManagementStone fromCity = pm1.City;
				CityManagementStone targCity = pm2.City;

				if ( fromCity != null && targCity != null )
				{
					if ( fromCity.Waring.Contains( targCity ) )
						return true;
				}
			}

			return false;
		}

		public static bool CheckCityAlly( Mobile from, Mobile target )
		{
			if ( from is PlayerMobile && target is PlayerMobile )
			{
				PlayerMobile pm1 = (PlayerMobile)from;
				PlayerMobile pm2 = (PlayerMobile)target;
				CityManagementStone fromCity = pm1.City;
				CityManagementStone targCity = pm2.City;

				if ( fromCity != null )
				{
					if ( fromCity.Citizens.Contains( target ) )
						return true;

					if ( fromCity.Allegiances.Contains( targCity ) )
						return true;
				}
			}

			return false;
		}

		public static bool IsCityLevelReached( Mobile from, int level )
		{
			PlayerMobile pm = (PlayerMobile)from;

			if ( pm.City.Mayor == from )
			{
				if ( pm.City.Level >= level )
					return true;
			}

			return false;
		}

		public static bool IsAtCity( Mobile from, Mobile to )
		{
			PlayerMobile pm = (PlayerMobile)from;
			CityManagementStone city = pm.City;
			Region cityreg = Region.Find( from.Location, from.Map );
			Region targregion = Region.Find( to.Location, to.Map );
			
			if ( city != null && cityreg != null && targregion != null )
			{
				if ( ( cityreg == city.PCRegion ) && ( cityreg == targregion ) )
					return true;
			}
			
			return false;

			
		}
		
		
		public static bool IsAtCity( Mobile from )
		{
			PlayerMobile pm = (PlayerMobile)from;
			CityManagementStone city = pm.City;
			Region cityreg = Region.Find( from.Location, from.Map );

			if ( cityreg != null && city != null )
			{
				if ( cityreg == city.PCRegion )
					return true;
			}
				

			return false;
		}
		
		public static bool IsAtCity( Item item )
		{
			Region reg = Region.Find( item.Location, item.Map );
				
			if ( reg != null )
			{
				if ( reg is PlayerCityRegion )
					return true;
				else
					return false;
			}
			return false;
					
		}
		
			
		
		
		public static bool IsMemberOf( Mobile from, CityManagementStone stone )
		{
			PlayerMobile pm = (PlayerMobile)from;
			if ( pm.City == null )
				return false;
			
			foreach ( Mobile mob in stone.Citizens )
			{
				if ( mob == from )
				{
					return true;
					break;
				}
			}
			return false;
		}
		
		public static Rectangle3D[] FormatRegion( Rectangle2D box )
		{
				Rectangle3D area = Server.Region.ConvertTo3D( box );
				List<Rectangle3D> arealist = new List<Rectangle3D>();
				arealist.Add( area );
				Rectangle3D[] regarea = arealist.ToArray();
				return regarea;
		}
		
		public static bool IsIteminCity( Mobile from, Item item )
		{
			PlayerMobile pm = (PlayerMobile)from;
			if ( pm.City == null )
				return false;
			else
			{
				CityManagementStone stone = pm.City;
				Point3D p = new Point3D( item.X, item.Y, item.Z );
				Region target = Region.Find( p, item.Map );
				if ( stone.PCRegion == target )
					return true;
				else
					return false;
			}
			
			
		}
		
		public static bool AreThereVendors( Mobile from )
		{
			
			if ( from == null )
				return false;
			
			foreach ( BaseHouse h in BaseHouse.GetHouses( from ) )
			{
				if ( h != null )
				{
					if ( h.HasPersonalVendors || h.HasRentedVendors )
						return true;
					else 
						return false;
				}
				
			}
			return false;
		}
		
		public static void CheckCitySystemVersion()
		{
		
			 bool SystemUpgrade = false;
			
			if ( !File.Exists( FileName ) )
				SystemUpgrade = true;
			else
			{
				try
				{
					XmlDocument xml = new XmlDocument();
					xml.Load( FileName );
					
					XmlElement system = xml["Version"];
					FileVersion = system.InnerText;
															
					if ( FileVersion == "0.0" )
					{
						Console.WriteLine( "Government System: Error Loading Version Variable!" );
						return;
					}
					if ( FileVersion != SystemVersion )
						SystemUpgrade = true;
					
					
				}
				catch
				{
					Console.WriteLine( "Error Reading City Version File!" );
					return;
				}
				
			}
			if ( SystemUpgrade )
				Console.WriteLine( "The city system needs to be upgraded, please run the [upgradecitysystem command!" );
			else
				Console.WriteLine( "City system current.  Version {0}", SystemVersion );
				
		}
			
	}
}

Has to do with the version of both RunUo and the version of this script package.

Do a search for your error in the script help section should be easy enough (I'd help but am on limited internet and could lose connection any moment)
 

MaG_PaW

Sorceror
Errors:
+ Government System/PlayerGovernmentSystem.cs:
CS1502: Line 281: The best overloaded method match for 'System.Col
List<Server.Multis.BaseHouse>.AddRange(System.Collections.Generic.IEnu
ltis.BaseHouse>)' has some invalid arguments
CS1503: Line 281: Argument '1': cannot convert from 'System.Collec
to 'System.Collections.Generic.IEnumerable<Server.Multis.BaseHouse>'





Code:
//added  - improved house check
		public static List<BaseHouse> GetAllHouses(Mobile m)
		{
			List<BaseHouse> allHouses = new List<BaseHouse>();
			
			Account a = m.Account as Account;

			if ( a == null )
				return allHouses;
			

			for ( int i = 0; i < a.Length; ++i )
			{
				Mobile mob = a[i];

				if ( mob != null )
					allHouses.AddRange( BaseHouse.GetHouses( mob ) );
			}
			return allHouses;
		}
		//end added
		

		//this method was modified 
		public static bool CheckIfHouseInCity( Mobile from, Region region )
		{
			if ( from == null )
				return false;

			if ( region == null )
				return false;
			
			foreach ( BaseHouse h in GetAllHouses( from ) )
			{
				
				if ( h != null )
				{
					int X = h.Sign.X;
					int Y = h.Sign.Y + 1;
					int Z = h.Sign.Z;

					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = h.Sign.Map;
					
					Region reg = Region.Find( hsp, hsm );
 
 					if( reg == region )
						return true;
 					else 
 						continue; //was return false
				}
			}

			return false;
			/*
			foreach ( Item item in World.Items.Values )
			{
				if ( item is HouseSign )
				{
					HouseSign hs = (HouseSign)item;

					Mobile owner = hs.Owner.Owner;

					if ( owner == null )
						continue; //was return false

					int X = hs.X;
					int Y = hs.Y + 1;
					int Z = hs.Z;

					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = hs.Map;

					Region reg = Region.Find( hsp, hsm );

                        		Account acct = (Account)from.Account;
					Account acct2 = (Account)owner.Account;

					if ( acct == null || acct2 == null || reg == null )
						continue; //was return false
			
					if ( reg == region && acct == acct2 )
						return true;
				}
			}

			return false;*/
		}

whats the problem?
 

zevilz

Wanderer
The script is trying to fill a generic basehouse list with object members. Runuo 2.0 RC1 uses arraylist whereas this script uses generic lists.

I changed the following in PlayerGovernmentSystem.cs

Code:
		public static List<BaseHouse> GetAllHouses( Mobile m ) // thanks to bripbrip
		{
			List<BaseHouse> allHouses = new List<BaseHouse>();
			
			Account a = m.Account as Account;

			if ( a == null )
				return allHouses;
			

			for ( int i = 0; i < a.Length; ++i )
			{
				Mobile mob = a[i];

				if ( mob != null )
					allHouses.AddRange( BaseHouse.GetHouses( mob ) );
			}
			return allHouses;
		}
		
		public static bool CheckIfHouseInCity( Mobile from, Region region )
		{
			if ( from == null )
				return false;

			if ( region == null )
				return false;
			List<BaseHouse> list = BaseHouse.GetHouses( from );
			if ( list != null )
			{
				for ( int i = 0; i < list.Count; i++ )
				{
					BaseHouse h = list[i];
					if ( h != null )
					{
						int X = h.Sign.X;
						int Y = h.Sign.Y + 1;
						int Z = h.Sign.Z;
						
						
						Point3D hsp = new Point3D( X, Y, Z );
						Map hsm = h.Sign.Map;

						Region reg = Region.Find( hsp, hsm );
						
						if( reg == region )
							return true;
						else if ( list.Count > 1 && i < (list.Count - 1) )
							continue;
						else
						{
							
							return false;
						}
					}
				  }
			}
			
			foreach ( BaseHouse h in GetAllHouses( from ) )
			{
				if ( h != null )
				{
					int X = h.Sign.X;
					int Y = h.Sign.Y + 1;
					int Z = h.Sign.Z;
					
					
					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = h.Sign.Map;

					Region reg = Region.Find( hsp, hsm );
					if ( reg == region )
					{
						Mobile owner = h.Owner;
						Account acct = (Account)from.Account;
						Account acct2 = (Account)owner.Account;
						if ( acct == null || acct2 == null )
							return false;
						else if ( acct == acct2 )
							return true;
						else
							continue;
						
					}
					else
						continue;
				}
				else
				{
					
					return false;
				}
			}
			
			return false;
			
			
			
		}

to

Code:
		public static ArrayList GetAllHouses( Mobile m ) // thanks to bripbrip
		{
            ArrayList allHouses = new ArrayList();
			
			Account a = m.Account as Account;

			if ( a == null )
				return allHouses;
			

			for ( int i = 0; i < a.Length; ++i )
			{
				Mobile mob = a[i];
                
				if ( mob != null )
					allHouses.AddRange( BaseHouse.GetHouses( mob ) );
			}
			return allHouses;
		}
		
		public static bool CheckIfHouseInCity( Mobile from, Region region )
		{
			if ( from == null )
				return false;

			if ( region == null )
				return false;
            ArrayList list = BaseHouse.GetHouses(from);
			if ( list != null )
			{
				for ( int i = 0; i < list.Count; i++ )
				{
					BaseHouse h = (BaseHouse)list[i];
					if ( h != null )
					{
						int X = h.Sign.X;
						int Y = h.Sign.Y + 1;
						int Z = h.Sign.Z;
						
						
						Point3D hsp = new Point3D( X, Y, Z );
						Map hsm = h.Sign.Map;

						Region reg = Region.Find( hsp, hsm );
						
						if( reg == region )
							return true;
						else if ( list.Count > 1 && i < (list.Count - 1) )
							continue;
						else
						{
							
							return false;
						}
					}
				  }
			}
			
			foreach ( BaseHouse h in GetAllHouses( from ) )
			{
				if ( h != null )
				{
					int X = h.Sign.X;
					int Y = h.Sign.Y + 1;
					int Z = h.Sign.Z;
					
					
					Point3D hsp = new Point3D( X, Y, Z );
					Map hsm = h.Sign.Map;

					Region reg = Region.Find( hsp, hsm );
					if ( reg == region )
					{
						Mobile owner = h.Owner;
						Account acct = (Account)from.Account;
						Account acct2 = (Account)owner.Account;
						if ( acct == null || acct2 == null )
							return false;
						else if ( acct == acct2 )
							return true;
						else
							continue;
						
					}
					else
						continue;
				}
				else
				{
					
					return false;
				}
			}
			
			return false;
			
			
			
		}

And it works fine for me
 

ThalmagusPL

Wanderer
I have one problem..
Anybody help?

PublicMoongate.cs
Code:
CS0246: Line 413: The type or namespace name 'ArrayList' could not found <are you missing a using directive or an assembly reference??>
 

Tru

Knight
ThalmagusPL;737580 said:
I have one problem..
Anybody help?

PublicMoongate.cs
Code:
CS0246: Line 413: The type or namespace name 'ArrayList' could not found <are you missing a using directive or an assembly reference??>

The post right before this is basically the answer to your question. It has to do with the SVN version you are using.
 

ThalmagusPL

Wanderer
Yea i using svn282.
Please help :(

This is my PublicMoongate.cs
Code:
using System;
using System.Collections.Generic;
using Server;
using Server.Commands;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.Spells;
using Server.Regions;

namespace Server.Items
{
	public class PublicMoongate : Item
	{
		public override bool ForceShowProperties{ get{ return ObjectPropertyList.Enabled; } }

		[Constructable]
		public PublicMoongate() : base( 0xF6C )
		{
			Movable = false;
			Light = LightType.Circle300;
		}

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

		public override void OnDoubleClick( Mobile from )
		{
			if ( !from.Player )
				return;

			if ( from.InRange( GetWorldLocation(), 1 ) )
				UseGate( from );
			else
				from.SendLocalizedMessage( 500446 ); // That is too far away.
		}

		public override bool OnMoveOver( Mobile m )
		{
			// Changed so criminals are not blocked by it.
			if ( m.Player )
				UseGate( m );

			return true;
		}

		public override bool HandlesOnMovement{ get{ return true; } }

		public override void OnMovement( Mobile m, Point3D oldLocation )
		{
			if ( m is PlayerMobile )
			{
				if ( !Utility.InRange( m.Location, this.Location, 1 ) && Utility.InRange( oldLocation, this.Location, 1 ) )
					m.CloseGump( typeof( MoongateGump ) );
			}
		}

		public bool UseGate( Mobile m )
		{
			if ( m.Criminal )
			{
				m.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
				return false;
			}
			else if ( SpellHelper.CheckCombat( m ) )
			{
				m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
				return false;
			}
			else if ( m.Spell != null )
			{
				m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
				return false;
			}
			else
			{
				m.CloseGump( typeof( MoongateGump ) );
				m.SendGump( new MoongateGump( m, this ) );

				if ( !m.Hidden || m.AccessLevel == AccessLevel.Player )
					Effects.PlaySound( m.Location, m.Map, 0x20E );

				return true;
			}
		}

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

			writer.Write( (int) 0 ); // version
		}

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

			int version = reader.ReadInt();
		}

		public static void Initialize()
		{
			CommandSystem.Register( "MoonGen", AccessLevel.Administrator, new CommandEventHandler( MoonGen_OnCommand ) );
		}

		[Usage( "MoonGen" )]
		[Description( "Generates public moongates. Removes all old moongates." )]
		public static void MoonGen_OnCommand( CommandEventArgs e )
		{
			DeleteAll();

			int count = 0;

			count += MoonGen( PMList.Trammel );
			count += MoonGen( PMList.Felucca );
			count += MoonGen( PMList.Ilshenar );
			count += MoonGen( PMList.Malas );
			count += MoonGen( PMList.Tokuno );

			World.Broadcast( 0x35, true, "{0} moongates generated.", count );
		}

		private static void DeleteAll()
		{
			List<Item> list = new List<Item>();

			foreach ( Item item in World.Items.Values )
			{
				if ( item is PublicMoongate )
					list.Add( item );
			}

			foreach ( Item item in list )
				item.Delete();

			if ( list.Count > 0 )
				World.Broadcast( 0x35, true, "{0} moongates removed.", list.Count );
		}

		private static int MoonGen( PMList list )
		{
			foreach ( PMEntry entry in list.Entries )
			{
				Item item = new PublicMoongate();

				item.MoveToWorld( entry.Location, list.Map );

				if ( entry.Number == 1060642 ) // Umbra
					item.Hue = 0x497;
			}

			return list.Entries.Length;
		}
	}

	public class PMEntry
	{
		private Point3D m_Location;
		private int m_Number;

		public Point3D Location
		{
			get
			{
				return m_Location;
			}
		}

		public int Number
		{
			get
			{
				return m_Number;
			}
		}

		public PMEntry( Point3D loc, int number )
		{
			m_Location = loc;
			m_Number = number;
		}
	}

	public class PMList
	{
		private int m_Number, m_SelNumber;
		private Map m_Map;
		private PMEntry[] m_Entries;

		public int Number
		{
			get
			{
				return m_Number;
			}
		}

		public int SelNumber
		{
			get
			{
				return m_SelNumber;
			}
		}

		public Map Map
		{
			get
			{
				return m_Map;
			}
		}

		public PMEntry[] Entries
		{
			get
			{
				return m_Entries;
			}
		}

		public PMList( int number, int selNumber, Map map, PMEntry[] entries )
		{
			m_Number = number;
			m_SelNumber = selNumber;
			m_Map = map;
			m_Entries = entries;
		}

		public static readonly PMList Trammel =
			new PMList( 1012000, 1012012, Map.Trammel, new PMEntry[]
				{
					new PMEntry( new Point3D( 4467, 1283, 5 ), 1012003 ), // Moonglow
					new PMEntry( new Point3D( 1336, 1997, 5 ), 1012004 ), // Britain
					new PMEntry( new Point3D( 1499, 3771, 5 ), 1012005 ), // Jhelom
					new PMEntry( new Point3D(  771,  752, 5 ), 1012006 ), // Yew
					new PMEntry( new Point3D( 2701,  692, 5 ), 1012007 ), // Minoc
					new PMEntry( new Point3D( 1828, 2948,-20), 1012008 ), // Trinsic
					new PMEntry( new Point3D(  643, 2067, 5 ), 1012009 ), // Skara Brae
					new PMEntry( new Point3D( 3563, 2139, 34), 1012010 ), // Magincia
					new PMEntry( new Point3D( 3763, 2771, 50), 1078098 )  // New Haven
				} );

		public static readonly PMList Felucca =
			new PMList( 1012001, 1012013, Map.Felucca, new PMEntry[]
				{
					new PMEntry( new Point3D( 4467, 1283, 5 ), 1012003 ), // Moonglow
					new PMEntry( new Point3D( 1336, 1997, 5 ), 1012004 ), // Britain
					new PMEntry( new Point3D( 1499, 3771, 5 ), 1012005 ), // Jhelom
					new PMEntry( new Point3D(  771,  752, 5 ), 1012006 ), // Yew
					new PMEntry( new Point3D( 2701,  692, 5 ), 1012007 ), // Minoc
					new PMEntry( new Point3D( 1828, 2948,-20), 1012008 ), // Trinsic
					new PMEntry( new Point3D(  643, 2067, 5 ), 1012009 ), // Skara Brae
					new PMEntry( new Point3D( 3563, 2139, 34), 1012010 ), // Magincia
					new PMEntry( new Point3D( 2711, 2234, 0 ), 1019001 )  // Buccaneer's Den
				} );

		public static readonly PMList Ilshenar =
			new PMList( 1012002, 1012014, Map.Ilshenar, new PMEntry[]
				{
					new PMEntry( new Point3D( 1215,  467, -13 ), 1012015 ), // Compassion
					new PMEntry( new Point3D(  722, 1366, -60 ), 1012016 ), // Honesty
					new PMEntry( new Point3D(  744,  724, -28 ), 1012017 ), // Honor
					new PMEntry( new Point3D(  281, 1016,   0 ), 1012018 ), // Humility
					new PMEntry( new Point3D(  987, 1011, -32 ), 1012019 ), // Justice
					new PMEntry( new Point3D( 1174, 1286, -30 ), 1012020 ), // Sacrifice
					new PMEntry( new Point3D( 1532, 1340, - 3 ), 1012021 ), // Spirituality
					new PMEntry( new Point3D(  528,  216, -45 ), 1012022 ), // Valor
					new PMEntry( new Point3D( 1721,  218,  96 ), 1019000 )  // Chaos
				} );

		public static readonly PMList Malas =
			new PMList( 1060643, 1062039, Map.Malas, new PMEntry[]
				{
					new PMEntry( new Point3D( 1015,  527, -65 ), 1060641 ), // Luna
					new PMEntry( new Point3D( 1997, 1386, -85 ), 1060642 )  // Umbra
				} );

		public static readonly PMList Tokuno =
			new PMList( 1063258, 1063415, Map.Tokuno, new PMEntry[]
				{
					new PMEntry( new Point3D( 1169,  998, 41 ), 1063412 ), // Isamu-Jima
					new PMEntry( new Point3D(  802, 1204, 25 ), 1063413 ), // Makoto-Jima
					new PMEntry( new Point3D(  270,  628, 15 ), 1063414 )  // Homare-Jima
				} );

		public static readonly PMList[] UORLists		= new PMList[] { Trammel, Felucca };
		public static readonly PMList[] UORListsYoung	= new PMList[] { Trammel };
		public static readonly PMList[] LBRLists		= new PMList[] { Trammel, Felucca, Ilshenar };
		public static readonly PMList[] LBRListsYoung	= new PMList[] { Trammel, Ilshenar };
		public static readonly PMList[] AOSLists		= new PMList[] { Trammel, Felucca, Ilshenar, Malas };
		public static readonly PMList[] AOSListsYoung	= new PMList[] { Trammel, Ilshenar, Malas };
		public static readonly PMList[] SELists			= new PMList[] { Trammel, Felucca, Ilshenar, Malas, Tokuno };
		public static readonly PMList[] SEListsYoung	= new PMList[] { Trammel, Ilshenar, Malas, Tokuno };
		public static readonly PMList[] RedLists		= new PMList[] { Felucca };
		public static readonly PMList[] SigilLists		= new PMList[] { Felucca };
	}

	public class MoongateGump : Gump
	{
		private Mobile m_Mobile;
		private Item m_Moongate;
		private PMList[] m_Lists;

		public MoongateGump( Mobile mobile, Item moongate ) : base( 100, 100 )
		{
			m_Mobile = mobile;
			m_Moongate = moongate;

			PMList[] checkLists;

			if ( mobile.Player )
			{
				if ( Factions.Sigil.ExistsOn( mobile ) )
				{
					checkLists = PMList.SigilLists;
				}
				else if ( mobile.Kills >= 5 )
				{
					checkLists = PMList.RedLists;
				}
				else
				{
					int flags = mobile.NetState == null ? 0 : mobile.NetState.Flags;
					bool young = mobile is PlayerMobile ? ((PlayerMobile)mobile).Young : false;

					if ( Core.SE && (flags & 0x10) != 0 )
						checkLists = young ? PMList.SEListsYoung : PMList.SELists;
					else if ( Core.AOS && (flags & 0x8) != 0 )
						checkLists = young ? PMList.AOSListsYoung : PMList.AOSLists;
					else if ( (flags & 0x4) != 0 )
						checkLists = young ? PMList.LBRListsYoung : PMList.LBRLists;
					else
						checkLists = young ? PMList.UORListsYoung : PMList.UORLists;
				}
			}
			else
			{
				checkLists = PMList.SELists;
			}

			m_Lists = new PMList[checkLists.Length];

			for ( int i = 0; i < m_Lists.Length; ++i )
				m_Lists[i] = checkLists[i];

			for ( int i = 0; i < m_Lists.Length; ++i )
			{
				if ( m_Lists[i].Map == mobile.Map )
				{
					PMList temp = m_Lists[i];

					m_Lists[i] = m_Lists[0];
					m_Lists[0] = temp;

					break;
				}
			}

			AddPage( 0 );

			AddBackground( 0, 0, 380, 280, 5054 );
			
			AddButton( 10, 185, 4005, 4007, 2, GumpButtonType.Reply, 0 );
			AddHtml( 45, 185, 140, 25, @"Player City Menu", false, false );

			AddButton( 10, 210, 4005, 4007, 1, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 45, 210, 140, 25, 1011036, false, false ); // OKAY

			AddButton( 10, 235, 4005, 4007, 0, GumpButtonType.Reply, 0 );
			AddHtmlLocalized( 45, 235, 140, 25, 1011012, false, false ); // CANCEL

			AddHtmlLocalized( 5, 5, 200, 20, 1012011, false, false ); // Pick your destination:

			for ( int i = 0; i < checkLists.Length; ++i )
			{
				AddButton( 10, 35 + (i * 25), 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf( m_Lists, checkLists[i] ) + 1 );
				AddHtmlLocalized( 30, 35 + (i * 25), 150, 20, checkLists[i].Number, false, false );
			}

			for ( int i = 0; i < m_Lists.Length; ++i )
				RenderPage( i, Array.IndexOf( checkLists, m_Lists[i] ) );
		}

		private void RenderPage( int index, int offset )
		{
			PMList list = m_Lists[index];

			AddPage( index + 1 );

			AddButton( 10, 35 + (offset * 25), 2117, 2118, 0, GumpButtonType.Page, index + 1 );
			AddHtmlLocalized( 30, 35 + (offset * 25), 150, 20, list.SelNumber, false, false );

			PMEntry[] entries = list.Entries;

			for ( int i = 0; i < entries.Length; ++i )
			{
				AddRadio( 200, 35 + (i * 25), 210, 211, false, (index * 100) + i );
				AddHtmlLocalized( 225, 35 + (i * 25), 150, 20, entries[i].Number, false, false );
			}
		}

		public override void OnResponse( NetState state, RelayInfo info )
		{
			if ( info.ButtonID == 0 ) // Cancel
				return;
			else if ( m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null )
				return;
				
			if ( info.ButtonID == 2 )
			{
				ArrayList a = new ArrayList();

				foreach ( Item i in World.Items.Values )
				{
					if ( i is CityManagementStone )
					{
						CityManagementStone s = (CityManagementStone)i;
						
						if ( s.HasMoongate == true && s.IsRegistered == true )
							a.Add( i );
					}
				}

				if ( a.Count == 0 )
				{
					m_Mobile.SendGump( new NoCitiesGump() );
				}
				else
				{
					m_Mobile.SendGump( new PCMoongateGump( m_Moongate, 0, null, null ) );
				}
			}

			int[] switches = info.Switches;

			if ( switches.Length == 0 )
				return;

			int switchID = switches[0];
			int listIndex = switchID / 100;
			int listEntry = switchID % 100;

			if ( listIndex < 0 || listIndex >= m_Lists.Length )
				return;

			PMList list = m_Lists[listIndex];

			if ( listEntry < 0 || listEntry >= list.Entries.Length )
				return;

			PMEntry entry = list.Entries[listEntry];

			if ( !m_Mobile.InRange( m_Moongate.GetWorldLocation(), 1 ) || m_Mobile.Map != m_Moongate.Map )
			{
				m_Mobile.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate.
			}
			else if ( m_Mobile.Player && m_Mobile.Kills >= 5 && list.Map != Map.Felucca )
			{
				m_Mobile.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
			}
			else if ( Factions.Sigil.ExistsOn( m_Mobile ) && list.Map != Factions.Faction.Facet )
			{
				m_Mobile.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
			}
			else if ( m_Mobile.Criminal )
			{
				m_Mobile.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
			}
			else if ( SpellHelper.CheckCombat( m_Mobile ) )
			{
				m_Mobile.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
			}
			else if ( m_Mobile.Spell != null )
			{
				m_Mobile.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment.
			}
			else if ( m_Mobile.Map == list.Map && m_Mobile.InRange( entry.Location, 1 ) )
			{
				m_Mobile.SendLocalizedMessage( 1019003 ); // You are already there.
			}
			else
			{
				CityManagementStone outgoingCity = null;
				Region currentRegion = Region.Find( m_Mobile.Location, m_Mobile.Map );

				if ( currentRegion != null )
				{
					if ( currentRegion is PlayerCityRegion )
					{
						PlayerCityRegion pcr = (PlayerCityRegion)currentRegion;

						outgoingCity = pcr.Stone;
					}
				}

				if ( outgoingCity != null && outgoingCity.TravelTax >= 1 )
				{
					m_Mobile.SendGump( new PCMoongateToll2Gump( m_Moongate, outgoingCity, entry.Location, list.Map ) );
				}
				else
				{
					BaseCreature.TeleportPets( m_Mobile, entry.Location, list.Map );
	
					m_Mobile.Combatant = null;
					m_Mobile.Warmode = false;
					m_Mobile.Hidden = true;

					m_Mobile.MoveToWorld( entry.Location, list.Map );

					Effects.PlaySound( entry.Location, list.Map, 0x1FE );
				}
			}
		}
	}
}
 

MaG_PaW

Sorceror
I have a problem, it turns out that in level 3 of the city, when my players stick being activated the guards, my server is restarted.

Since I can solve it?
 

Amy-

Sorceror
Great system, but we're having problems after the mayor of one town deleted his characters. Every time the city updates, the shard will crash. Tried setting the mayor manually in [props but no go.
Also tried to recreate this on my test shard by deleting a mayor character but wasn't able to get it to crash, any suggestions?

Code:
Server Crash Report
===================

RunUO Version 2.0, Build 2727.20904
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 3/22/2008 8:21:30 AM
Mobiles: 117128
Items: 655078
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Items.CityManagementStone.DoUpdate() in c:\Documents and Settings\user\Desktop\Arc update\Arc update\Scripts\Custom\Systems\Player Government System\Items\Stones\CityManagementStone.cs:line 1166
   at Server.Items.CityManagementStone.CityUpdateTimer.OnTick() in c:\Documents and Settings\user\Desktop\Arc update\Arc update\Scripts\Custom\Systems\Player Government System\Items\Stones\CityManagementStone.cs:line 1601
   at Server.Timer.Slice() in C:\Documents and Settings\owner\Local Settings\Application Data\Temporary Projects\Runuo Arc update\Server\Timer.cs:line 400
   at Server.Core.Main(String[] args) in C:\Documents and Settings\owner\Local Settings\Application Data\Temporary Projects\Runuo Arc update\Server\Main.cs:line 458

Code:
Server Crash Report
===================

RunUO Version 2.0, Build 2727.20904
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 3/22/2008 5:14:16 AM
Mobiles: 117446
Items: 661208
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Items.CityManagementStone.DeadMayor() in c:\Documents and Settings\user\Desktop\Arc update\Arc update\Scripts\Custom\Systems\Player Government System\Items\Stones\CityManagementStone.cs:line 713
   at Server.Items.CityManagementStone.DoUpdate() in c:\Documents and Settings\user\Desktop\Arc update\Arc update\Scripts\Custom\Systems\Player Government System\Items\Stones\CityManagementStone.cs:line 955
   at Server.Items.CityManagementStone.CityUpdateTimer.OnTick() in c:\Documents and Settings\user\Desktop\Arc update\Arc update\Scripts\Custom\Systems\Player Government System\Items\Stones\CityManagementStone.cs:line 1601
   at Server.Timer.Slice() in C:\Documents and Settings\owner\Local Settings\Application Data\Temporary Projects\Runuo Arc update\Server\Timer.cs:line 400
   at Server.Core.Main(String[] args) in C:\Documents and Settings\owner\Local Settings\Application Data\Temporary Projects\Runuo Arc update\Server\Main.cs:line 458
 

Pyro-Tech

Knight
I am getting this error when trying to upgrade...im not sure what version im upgrading from.

is there any new edits i need to have done? or anything i can show that might inform you of what version im using? currently it works, but im trying to update for some of the new features

Code:
 + Custom/New Scripts/Systems/Player Gov System/PlayerGovernmentSystem.cs:
    CS1502: Line 280: The best overloaded method match for 'System.Collections.G
eneric.List<Server.Multis.BaseHouse>.AddRange(System.Collections.Generic.IEnumer
able<Server.Multis.BaseHouse>)' has some invalid arguments
    CS1503: Line 280: Argument '1': cannot convert from 'System.Collections.Arra
yList' to 'System.Collections.Generic.IEnumerable<Server.Multis.BaseHouse>'
    CS0029: Line 292: Cannot implicitly convert type 'System.Collections.ArrayLi
st' to 'System.Collections.Generic.List<Server.Multis.BaseHouse>'
thanks for any help....let me know if you need additional info

EDIT: Nevermind....found the fix a couple of posts up i believe...post #199 has it
 

seanandre

Sorceror
I've gone through this system and this entire thread and corrected everything accordingly, but when I start my server, I keep getting the following errors:

Code:
Errors:
 + Customs/Misc/FS Player Government System/PlayerGovernmentSystem.cs:
    CS0029: Line 292: Cannot implicitly convert type 'System.Collections.Generic
.List<Server.Multis.BaseHouse>' to 'System.Collections.ArrayList'
 + Items/Misc/PlayerVendorDeed.cs:
    CS1525: Line 54: Invalid expression term 'else'
    CS1002: Line 54: ; expected
 + Items/Misc/PublicMoongate.cs:
    CS0246: Line 411: The type or namespace name 'ArrayList' could not be found
(are you missing a using directive or an assembly reference?)
    CS0246: Line 411: The type or namespace name 'ArrayList' could not be found
(are you missing a using directive or an assembly reference?)
Scripts: One or more scripts failed to compile or no script files were found.

Any help would be greatly appreciated.

Thanks,
Sean
 
Top