Jump to content
__d0ct0r__

Count number of players in an area.

Recommended Posts

I am making a multiplayer mission. In this mission, I need to count the number of players in an area (inside of a circle marker). Could someone inform me how I can do this. Many thanks.

Share this post


Link to post
Share on other sites
_playerswithincircle = allplayers select { (_x distance2d _centreposofmycircle) < _radiusofmycircle };

 

  • Like 2

Share this post


Link to post
Share on other sites

Tanky's solution also works to get players with a radius of a position/object/etc.

If you are working with other shapes of markers/triggers, use inArea:
 

//marker
_playersInArea = allplayers select {_x inArea "markerName"}; 

//trigger
_playersInArea = allplayers select {_x inArea triggerName}; 

 

  • Like 3

Share this post


Link to post
Share on other sites

Or, if the players are all west and no other west units will be there...

 

_playerswithincircle = (_centreposofmycircle nearentities ["SoldierWB", _radiusofmycircle])

Note this method won't get deads or mounteds.

  • Like 2

Share this post


Link to post
Share on other sites

Lots of options, depending on case!

Share this post


Link to post
Share on other sites
Just now, Harzach said:

Lots of options, depending on case!

Yes. I've run them all of them through the debug timer thingy, there wasn't an appreciable difference in CPU cost.

Share this post


Link to post
Share on other sites

you can even use inArea without marker or trigger, just your data of area...

 

or even:

allPlayers inAreaArray location_1;

 

or the forgotten but very nice:

position inPolygon polygon

  • Like 2

Share this post


Link to post
Share on other sites

Hah, I love it, just like the good old days.

  • Like 3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×