1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Check an area for playermobile

Discussion in 'Script Support' started by dmurphy, Feb 12, 2014.

  1. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,011
    Likes Received:
    198
    Publish Number:
    54
    Hey,

    Could use a little help.

    I am trying to check a certain area for playermobiles.

    Right now I have this code

    Code (C#):
    1.  
    2.  
    3. foreach (Mobile m in from.GetMobilesInRange(40)) // TODO: Validate range
    4.  
    5.     {
    6.  
    7.         if (m is PlayerMobile)
    8.           {
    9.                  from.SendMessage("Please Wait For The Current Team To Finish!");
    10.                  return;
    11.           }
    12.     }
    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!
     
  2. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,011
    Likes Received:
    198
    I got it! Man it's always nice when you figure it out yourself
     
    • Like Like x 2
  3. Hank
    Offline

    Hank Active Member

    Joined:
    Nov 14, 2013
    Messages:
    971
    Likes Received:
    153
    Care to share for future generations?
     
  4. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,011
    Likes Received:
    198
    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 (C#):
    1.  
    2.  
    3. foreach (Mobile m in from.GetMobilesInRange(40)) // TODO: Validate range
    4.  
    5.     {
    6.  
    7.        if (m is PlayerMobile && m.Region.Name == "insertRegionName")
    8.           {
    9.                  from.SendMessage("Please Wait For The Current Team To Finish!");
    10.                  return;
    11.           }
    12.     }
     
  5. Marcis
    Offline

    Marcis Member

    Joined:
    Feb 1, 2014
    Messages:
    49
    Likes Received:
    5
    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.
     
Similar Threads: Check area
Forum Title Date
Archived Bug Reports Resist Spell Checks Wednesday at 7:21 AM
Script Support Checking for Skill Cap and preventing use of Mythic Token. May 19, 2018
Archived Bug Reports Camps do not check for valid Z when placing items May 17, 2018
Script Support Xmlspawner checking account tag ? May 3, 2018
Script Support Moongate check issue Apr 16, 2018
Shards Looking For Players Come Check Out The Playground!!! Dec 24, 2017
Script Support Region check is this the correct way? Nov 27, 2017