i want to make it were when u connect yourself to the cannons there is a range were u have to be short distance from the cannon. the bug im finding it is were my players are connecting them threw walls and such. anybody got any ideas
 

Attachments

  • SiegeComponent.cs
    10.5 KB · Views: 5
  • SiegeCannon.cs
    7.9 KB · Views: 3
A simple

Code:
if (from.InRange(GetWorldLocation(), 1))
            {
                    Do OnDblClick stuff in here.
            }

Within the OnDoubleClick should work. The "1" means they have to be within 1 tile to click it, you can adjust that to how close you want them to be.
 
its already on click theres no double clicking i tried it but not working

Code:
public override void OnClick()
  {
  if (from.InRange(GetWorldLocation(), 1))
  {
  this.m_weapon.PlaceWeapon(this.m_from, this.m_from.Location, this.m_from.Map);
  }

TO

Code:
public override void OnClick()
            {
              if (this.m_from.InRange(GetWorldLocation(), 1))
                {
                    this.m_weapon.PlaceWeapon(this.m_from, this.m_from.Location, this.m_from.Map);
                }

and i get this
Code:
Errors:
+ Services/XmlSpawner 2/XmlEngines/XmlSiege/SiegeComponent.cs:
    CS0038: Line 316: Cannot access a non-static member of outer type 'Server.It
em' via nested type 'Server.Items.SiegeComponent.SetupEntry'
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Last edited:
thanks to hank this is solved :) thank you hank your the best here is the fix

Code:
if (weapon.IsDraggable)
                {
                    // does it support dragging?
                    XmlDrag a = (XmlDrag)XmlAttach.FindAttachment(weapon, typeof(XmlDrag));
                    if (a != null)
                    {
                        // is it currently being dragged?
                        if (a.DraggedBy != null && !a.DraggedBy.Deleted)
                        {
                            list.Add(new ReleaseEntry(from, a));
                        }
                        if (!from.InRange(GetWorldLocation(), 1))
						{
							from.SendMessage( "That is too far away to connect to." );
						}
						else
                        {
                            list.Add(new ConnectEntry(from, a));
                        }
                    }
                }
 
Back