Title, im trying to make a wall show the current/maxhitpoints on singleclick, no sucess so far.

This is what i have;
Code:
using System;
using Server;
using Server.Network;
using Server.Engines.XmlSpawner2;

namespace Server.Items
{
    
    public class WallWLSUR : Item
    {
        private int m_DestroyedItemID = 0;
  
        [Constructable]
        public WallWLSUR(): base(148)
        {
           Weight = 30.0;
           Name = "Weak wooden wall";
           Movable = true;
       
           XmlAttach.AttachTo(this, new XmlCitySiege(250,1,1,2,0,0)); 
        }

          public override void OnSingleClick( Mobile from )
          {
          XmlSiege siege = (XmlSiege)XmlAttach.FindAttachment(this, typeof(XmlSiege));


if (siege != null)  
{          
 
    bool ascii = true;
    int hue = 1156;
  
    string rankTitle;
    int siege = m_Hits(this);

     if (siege.m_Hits >= 1)
        rankTitle = string.Format("[{1}/{2}]", m_Hits, HitsMax);

    PrivateOverheadMessage(MessageType.Label, hue, ascii, rankTitle, from.NetState);
}
        

    base.OnSingleClick( from );
}
        
      
        public WallWLSUR(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();
        }

    }

Its so wrong, i know :p

i also tried to add somethng like
Code:
private int m_Hits;      
private int m_HitsMax;

Errors:



Errors:
CS0103: Line 34: The name 'm_Hits' does not exist in the current context
CS1061: Line 36: 'int' does not contain a definition for 'm_Hits' and no ext
ension method 'm_Hits' accepting a first argument of type 'int' could be found (
are you missing a using directive or an assembly reference?)
CS0103: Line 38: The name 'm_Hits' does not exist in the current context
CS0103: Line 38: The name 'HitsMax' does not exist in the current context



Thanks servuo
 
Well thats easy to explain.
Code:
private bool m_Hits;        // current hits
private bool m_HitsMax;

both are bool. bool is false or true. Default value is false. Therefor it shows false / false.

If you want hits then you need to use like int, long, float, double ...

Unless you got more Hits variables in the siege attachment. Then you would probably need to use siege.Hits
 
Well these Hitpoints need to be defined somewhere, thats why I said if they are already defined in your siegeattachment then you wouldnt even need the variables in your Item, you would then just display the value of the attachment (with a check if it exists to be save)

If the attachment doesnt have the hitpoints then you would want to define them in your Item or rather in an Interface that you would put on the Item.
 
Well these Hitpoints need to be defined somewhere, thats why I said if they are already defined in your siegeattachment then you wouldnt even need the variables in your Item, you would then just display the value of the attachment (with a check if it exists to be save)

If the attachment doesnt have the hitpoints then you would want to define them in your Item or rather in an Interface that you would put on the Item.

I dont understand what you mean :oops:, want me to post the xmlsiege.cs?
 
What I ment is that at the moment you just declare the Hitpoint variables, the default value of int is 0.
You just let them display the default value right now. You need to do something with them.

BUT in case your attachment, the xmlsiege.cs has Hitpoint variables then you should use these
 
I added the hitpoints in the constructor:
Code:
 XmlAttach.AttachTo(this, new XmlSiege(250,1,1,2,0,0));
///250 hitpoints

When i damage the wall i get a message saying the current hitpoints/hitsmax.

You dealt 25 damage to the structure [ 225/250 ]

But the onsingleclick thing doesnt work
Code:
private int m_Hits;        // current hits
        private int m_HitsMax;



Code:
 public override void OnSingleClick( Mobile from )
          {
          XmlSiege siege = (XmlSiege)XmlAttach.FindAttachment(this, typeof(XmlSiege));


if (siege != null)   
{           
  
    bool ascii = true;
    int hue = 1156;
    string Siegepoints;
 
       
        Siegepoints = string.Format("[{0}/{1}]",m_Hits,m_HitsMax);

    PrivateOverheadMessage(MessageType.Label, hue, ascii, Siegepoints, from.NetState);
}
        
    base.OnSingleClick( from );
}
 
in that case you already answerd me that the siege attachment has separat hitpoint variables.

- Remove the ones in your Item that you declared yourself (m_Hits, m_HitsMax)
- change Siegepoints =string.Format("[{0}/{1}]",m_Hits,m_HitsMax); to something like
Siegepoints =string.Format("[{0}/{1}]", siege.Hits, siege.HitsMax);

I am not sure how these variables are named inside the attachment, it is just a guess at this point. But if you look at it yourself you should be able to find what the variables are named easily
 
Back