Jump to content
Vyllis Fuhajins

Help, count players near an entity(resolved).

Recommended Posts

Hello, i have trouble and can't finish my mission script. I am newbie into scripting so here is my problem:

 

During a multiplayer game, listen or dedicated server; I want to count players in a given radius around an entity (?, a trigger/marker). Unfortunately i can't get what i have wrote to work and search give me tons of way to count entities/objects/AIs around a player, this is not what i want.

 

I did try these:

 

 

_playerClose = {isPlayer _x && side _x == resistance} count (playableUnits nearEntities ["Mark", 1000]);

and this one

_playerClose = {isPlayer _x} count (_x nearEntities [["Mark"], 500]);

and

_playerClose = {isPlayer _x nearEntities ["Mark", 1000]} count playableUnits;

then

_playerClose = {isPlayer _x} count (position player nearEntities ["Mark", 1000]);

 

 

They all returned 0 or "scalar". I know some of them must be really wrong but i had to try.

I am searching for hours but my scripting level is too weak. If anyone would like to help some. Thank you.

Share this post


Link to post
Share on other sites

_radius = 50;
_numPlayersByEntity = {_x distance enitity < _radius} count allPlayers;
Where entity would be:

getPos object
getMarkerPos "marker"
Or whatever else.

Share this post


Link to post
Share on other sites
_playerClose = [];
{
if (_x distance object) < 1000) then {
_playerClose pushback _x;
};
} foreach allPlayers;
_playerClose;

this is returning an array of  player objects in 1000 meters from some object.

 

you need to count array if you need a number.

_nearplayercount = count _playerClose;

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

×