Jump to content
Sign in to follow this  
zamani532

how would I go about detecting number of players near a player?

Recommended Posts

I'm completely unsure of how I'd go about doing this, I want to somehow detect if X number of players are near eachother.. serverside.. any clues?

Share this post


Link to post
Share on other sites

{
if(isPlayer _x) then {
	private ["_cnt", "_plr"];
	_plr = _x;
	_cnt = 0;
	{
		if(isPlayer _x) then {
			_cnt = _cnt + 1;
		};
	} forEach nearestObjects [_x, ["Man"], 50];

	hint format ["%1 players around %2", (_cnt - 1), name _plr];
};
} forEach allUnits;

Didn't actually test the code, but it should work. This cycles through all players and counts players around them and puts number into _cnt. It will include player himself (so it is _cnt - 1 players around him). 50 is radius to check around each player.

Edited by SaMatra

Share this post


Link to post
Share on other sites

Thanks for the example :D I'll work with it and see if I can get my script to work!

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
Sign in to follow this  

×