I am using Knives' Town House script instead of the traditional housing system. The script is amazing and runs quite well. My problem is that I want to make BaseDoors lockable for owned/rented houses (rooms) within other buildings (rooms in inns, for example) , but likewise want to avoid potential abuse by allowing them to be opened from within the room/house without the key. I noticed that rooms located within other buildings can be opened from either side without the key due to this code in BaseDoor:

Code:
if ( m_Locked && !m_Open && UseLocks() )
			{
				if ( from.AccessLevel >= AccessLevel.GameMaster )
				{
					from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 502502 ); // That is locked, but you open it with your godly powers.
					//from.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, 0x3B2, 3, 502502, "", "" ) ); // That is locked, but you open it with your godly powers.
				}
				else if ( Key.ContainsKey( from.Backpack, this.KeyValue ) )
				{
					from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501282 ); // You quickly unlock, open, and relock the door
				}				
				else if ( IsInside( from ) )

				{ 	
					from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501280 ); // That is locked, but is usable from the inside.
				}
				else
				{
					if ( Hue == 0x44E && Map == Map.Malas ) // doom door into healer room in doom
						this.SendLocalizedMessageTo( from, 1060014 ); // Only the dead may pass.
					else
						from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 502503 ); // That is locked.

					return;
				}
			}

I attempted a fix (after countless failed attempts) using the following:

Code:
else if ( IsInside( from ) && from.Region != null && from.Region.IsPartOf( "HouseRegion" ) )

				{
					from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501280 ); // That is locked, but is usable from the inside.
				}

Unlike my other attempts, this actually loads. My reasoning was that the only time such interior doors would need to be unlocked on my shard is when they are part of a house, and that, since the region for each house seems to be converted to "HouseRegion" upon purchase, that this would solve the problem. Unfortunately, it merely causes the door to be locked on both sides.

I attempted another fix by creating a region, "InsideRegion" and using it for the area within the building directly outside the door to the room(s):

Code:
else if ( IsInside( from ) && from.Region != null && !from.Region.IsPartOf( "InsideRegion" ) ) 

				{ 	

					from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501280 ); // That is locked, but is usable from the inside.

				}

This likewise resulted in both sides of the door being locked. Does anyone perhaps have any ideas as to what I am doing wrong? Any help would be much appreciated. Thanks in advance.
 
Lock the door first, and then give the keys and set them to relock if the unit is sold or transferred. It's a setting you can change when setting up the town house. That will give the owner of the town house a set of keys. If there are doors that are locked and those keys can be used on them, you could also add an Xmlspawner, that locks the door after X amount of time has passed from the last time the door was unlocked.
 
Lock the door first, and then give the keys and set them to relock if the unit is sold or transferred. It's a setting you can change when setting up the town house. That will give the owner of the town house a set of keys. If there are doors that are locked and those keys can be used on them, you could also add an Xmlspawner, that locks the door after X amount of time has passed from the last time the door was unlocked.

Thanks for the information! I tried setting the doors to relock upon demolish, but for some reason it does not lock the door upon demolishing the house. Likewise, the feature for restricting a house to private does not seem to work. I do not seem to see a setting in the townhouse setup menu for relocking upon sale or transfer.

Locking the doors is not quite what I am trying to accomplish, as they are already lockable (well, most of them) and the locks can be changed, key works, etc. What I am trying to do is have houses located within other buildings be locked on the "outside" ("That is locked."), but able to be opened on the "inside" ("That is locked, but is usable from the inside."), just as with houses not located within a building. The issue is that the character is considered inside when under a roof, so it triggers "That is locked, but is usable from the inside." upon use whichever side of the door the character is on.

My "fix" worked to an extent, in that it made the doors locked on either side of a door inside a building (as well as houses not located inside buildings), but it leaves room for locking oneself or others (accidentally or intentionally) inside the house/room.
 
you could also just add basehousedoor and that way players can set the security levels rather than having to use keys
 
you could also just add basehousedoor and that way players can set the security levels rather than having to use keys

Thanks! I had thought about doing that, and might resort to it, though I rather like the notion of using keys, more for the aesthetic than functionality.
 
Back