It is a chair that when double clicked, it will give you a PlayerVendor. The script is only for my personal gain. I am not releasing it to the public or anything, I just want to learn some new things.
I am having a problem, or two:
- I need to be able to make the chair detect that there is already a mobile (PlayerVendor) in it.
I need to make it so that when the PlayerVendor is released, the chair becomes active again.
Code: Select all
using System;
using Server;
using Server.Mobiles;
using Server.Multis;
namespace Server.Items
{
[Flipable( 0xB4F, 0xB4E, 0xB50, 0xB51 )]
public class VendorRentalChair : Item
{
// public override int LabelNumber{ get{ return 1041243; } } // a contract of employment
public virtual TimeSpan JoinGameAge{ get{ return TimeSpan.FromDays( 14.0 ); } }
private bool c_InUse = false;
[CommandProperty(AccessLevel.GameMaster)]
public bool InUse
{
get { return c_InUse; }
set { c_InUse = value; InvalidateProperties(); }
}
[Constructable]
public VendorRentalChair() : base( 0xB4F )
{
Weight = 20.0;
Movable = false;
//LootType = LootType.Blessed;
}
public VendorRentalChair( 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();
}
public override void OnDoubleClick( Mobile from )
{
if ( from.InRange( GetWorldLocation(), 2 ) )
SummonVendor ( from );
else
from.SendMessage( "I can't reach that." );
}
public virtual void SummonVendor( Mobile from )
{
if ( InUse )
{
from.SendMessage( "That chair is already in use by another player. Please try another chair." );
}
else if ( ( from.CreationTime + JoinGameAge ) > DateTime.Now )
{
from.SendMessage ( "Your account must be at least two weeks (14 days) old in order to place a vendor here." );
}
else
{
Mobile v = new PlayerVendor( from, BaseHouse.FindHouseAt( from ) );
v.Direction = from.Direction & Direction.Mask;
v.MoveToWorld( this.Location, this.Map );
Item chair = new FancyWoodenChairCushion();
chair.MoveToWorld( this.Location, this.Map );
chair.Hue = this.Hue;
chair.ItemID = this. ItemID;
chair.Movable = false;
this.Visible = false;
this.Z--;
this.InUse = true;
v.SayTo( from, 503246 ); // Ah! it feels good to be working again.
}
}
}
}
If I could get some feedback that would be helpful.
