dmurphy

Administrator
Hey,

Could use a little help.

I am trying to check a certain area for playermobiles.

Right now I have this code

Code:
foreach (Mobile m in from.GetMobilesInRange(40)) // TODO: Validate range

    {

        if (m is PlayerMobile)
          {
                 from.SendMessage("Please Wait For The Current Team To Finish!");
                 return;
          }
    }
The problem is that while it works it also checks way more area than needed and it will cause erratic behaviour.

What I would like some help with is checking a specific region for playermobile or to check specific coordinates.

Thanks for any help you can provide!
 
Care to share for future generations?
Sure, I just added a region check, was very simple actually. It still checks 40 squares around but wont do anything unless the playermobile is in the region i specify.

If anyone has a better method I am all ears though!

Code:
foreach (Mobile m in from.GetMobilesInRange(40)) // TODO: Validate range

    {

       if (m is PlayerMobile && m.Region.Name == "insertRegionName")
          {
                 from.SendMessage("Please Wait For The Current Team To Finish!");
                 return;
          }
    }
 
Sure, I just added a region check, was very simple actually. It still checks 40 squares around but wont do anything unless the playermobile is in the region i specify.

If anyone has a better method I am all ears though!

Code:
foreach (Mobile m in from.GetMobilesInRange(40)) // TODO: Validate range

    {

       if (m is PlayerMobile && m.Region.Name == "insertRegionName")
          {
                 from.SendMessage("Please Wait For The Current Team To Finish!");
                 return;
          }
    }

If all you want is the player mobiles from within a region just use the Region function that returns all the mobiles within the region.
public List<Mobile> GetPlayers()

which could be made like

if(yourRegion.GetPlayers().Count>0)
// no avail to enter or whatever

I don't understand where you are using your code though.
 
Back