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!

Where can I look to find an item equipped (on paperdoll) check?

jdatch

Wanderer
What I'm looking to do is include a check to see if a particular item is equipped. So, if a player tries to access a gate/teleporter, it checks to see if they have an item equipped on their paperdoll first before allowing access.

Thanks for your help!
 

Soteric

Knight
You can check specific Layer
Code:
Item item = mobile.FindItemOnLayer( Layer.Ring );
Or check mobile items and see if its parent is mobile itself (i.e. the item is equiped)
Code:
foreach( Item item in mobile.Items )
    if( ... && item.Parent == mobile )
where ... is some condition that identifies your item.
 

jdatch

Wanderer
You can check specific Layer
Code:
Item item = mobile.FindItemOnLayer( Layer.Ring );
Or check mobile items and see if its parent is mobile itself (i.e. the item is equiped)
Code:
foreach( Item item in mobile.Items )
    if( ... && item.Parent == mobile )
where ... is some condition that identifies your item.


Awesome! Thank you, that is exactly what I was looking for.
 

jayates

Sorceror
What I'm looking to do is include a check to see if a particular item is equipped. So, if a player tries to access a gate/teleporter, it checks to see if they have an item equipped on their paperdoll first before allowing access.

Thanks for your help!


I'm trying to implement this idea into a teleporter, but mine was originally finding the item in backpack. I've tried deleting lines here and there but can't figure this out. Can someone help me?

Code:
    public class DarkSigniaTele : BaseTeleporter
    {
        private Point3D m_DestLoc;
        private Map    m_DestMap;
        private bool    m_AllowCreatures;
        private bool    m_TelePets;
 
        [CommandProperty( AccessLevel.GameMaster )]
        public Point3D Location
        {
            get { return m_DestLoc; }
            set { m_DestLoc = value; InvalidateProperties(); }
        }
 
        [CommandProperty( AccessLevel.GameMaster )]
        public Map Map
        {
            get { return m_DestMap; }
            set { m_DestMap = value; InvalidateProperties(); }
        }
 
        [CommandProperty( AccessLevel.GameMaster )]
        public bool AllowCreatures
        {
            get { return m_AllowCreatures; }
            set { m_AllowCreatures = value; InvalidateProperties(); }
        }
 
        [CommandProperty( AccessLevel.GameMaster )]
        public bool TelePets
        {
            get { return m_TelePets; }
            set { m_TelePets = value; InvalidateProperties(); }
        }
       
        [Constructable]
        public DarkSigniaTele()
        {
            Visible = false;
            Hue = 56;
            Movable = false;
            Weight = 1.0;
            Name = "Dark Signia Teleporter";
        }
 
        public DarkSigniaTele( Serial serial ) : base( serial )
        {
        }
 
        public override bool OnMoveOver( Mobile m )
        {
            Container pack = m.Backpack;
           
            if (pack == null)
            return true;
           
            if( !m_AllowCreatures && !m.Player )
            return true;
           
           
            Item items = m.FindItemOnLayer( Layer.Talisman );
 
            if (items != null && items.Length > 0)
                {
                    foreach (Item item in items)
  
 
                    if( m_TelePets )
                        {
                            Server.Mobiles.BaseCreature.TeleportPets( m, m_DestLoc, m_DestMap );
                        }
                    m.PlaySound(0x1F7);
                   
                    m.MoveToWorld( m_DestLoc, m_DestMap );
 
                    return false;
                }
            m.SendMessage( " You must have a Dark Signia to enter!" );
           
            return true;
        }
 
 
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );
            writer.Write( (int) 0 ); // version
 
            writer.Write( m_DestLoc );
            writer.Write( m_DestMap );
            writer.Write( m_AllowCreatures );
            writer.Write( m_TelePets );
        }
 
 
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();
 
            m_DestLoc = reader.ReadPoint3D();
            m_DestMap = reader.ReadMap();
            m_AllowCreatures = reader.ReadBool();
            m_TelePets = reader.ReadBool();
        }
    }
}
 
Top