What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Target nearest friendly player?

stevenr

Member
Joined
Jan 15, 2010
Messages
871
Reaction score
0
Hi,

is there a way to targed the nearest friendly player? I wont to move to him ;)
 
Use the ObjectManager class and filter the lists of objects by friendly players and order the result by the distance.
Then take the first entry and do a .Target().
 
Does anyone have an example for me? Or is there a plugin where I can look?
 
Last edited:
Code:
private WoWPlayer GetClosestFriendly()
        {
            return (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(true, true)
                        orderby unit.Distance ascending
                        where !unit.Dead
                        where !unit.IsGhost
                        where unit.IsFriendly
                        select unit).FirstOrDefault();            
        }

that would return the closest, then use .Target() to target them.
 
Thanks, now it works!

Is it possible to select the second or third?
 
PHP:
private WoWPlayer[] GetClosestFriendly()
        {
            return ObjectManager.GetObjectsOfType(true, false)
                .Where(player =>
                !player.Dead &&
                !player.IsGhost &&
                player.IsFriendly)
                .OrderBy(player => player.Distance)
                .ToArray();
        }

This is it.
</wowplayer>
 
Can I do something like this? Select the second from the list?
Code:
<wowplayer>...
                        select unit).Second();            
        }


And howto untarget a target?

</wowplayer>
 
Last edited:
As developer, you have to know how to search and read a doc List(T) Class

For the target, check the methods of your local player.
 
Can I do something like this? Select the second from the list?



And howto untarget a target?

</wowplayer>

if you do as ZenLulz posted, you can return an array of the players. so...

WoWPlayer[] ClosestFriendlies = GetClosestFriendly();

then you can return 2nd guy buy..
ClosestFriendlies[1]

(zero is the initial, 1 is the 2nd)

You can also use ".ElementAt(index)". If you want to get more, then go ahead and return an array. Its simple.
 
Last edited:
Back
Top