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,009
    Likes Received:
    190
    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,009
    Likes Received:
    190
    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:
    972
    Likes Received:
    152
    Care to share for future generations?
     
  4. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,009
    Likes Received:
    190
    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 Something is still creating bank checks on TOL + shards Aug 6, 2017
Archived Bug Reports [Need check] Command undead May 29, 2017
ServUO Discussion Dynamic Decay - A way to check on it? May 22, 2017
Archived Bug Reports [need check] mysticism damage speed spells Apr 6, 2017
General Discussion Anyone online available to help me check something? Mar 17, 2017
Script Support Checking dropped item IsChildOf(from.backpack) Mar 7, 2017
Script Support Checking account 'age', is this the right way? Feb 13, 2017