Doggifast 2 Posted August 11, 2022 So i have a small script that searches for players near the player _position = getPosASL player; _radius = 25; _list = (ASLToAGL _position) nearEntities [["Man"], _radius]; if i put _list after it, it returns... [B Alpha 1-1:1 (Sean Spiegelman),Agent 0xcf352180,O Alpha 1-1:1] It returns players with their names; B before the group name means Blufor and O - Opfor, if an entity isn't a player, there is no name inserted in the array... What i can't wrap my head around is how to remove Opfor/Independent units from said array. Please help Share this post Link to post Share on other sites
deadactionman 10 Posted August 11, 2022 Something like this might help... private ["_radius", "_men","_opfor_men", "_blufor_men", "_ind_men"]; _radius = 25; _opfor_men = []; _blufor_men = []; _ind_men = []; _men = (ASLToAGL getPos player) nearEntities [["Man"], _radius]; { if (side _x == opfor) then {_opfor_men pushBack _x;}; if (side _x == blufor) then {_blufor_men pushBack _x;}; if (side _x == independent) then {_ind_men pushBack _x;}; } forEach _men; hint format["OPFOR List=%1\nBLUFOR List=%2\nIND List=%3", _opfor_men, _blufor_men, _ind_men]; In the above example, I made myself a captive which turned me into a CIVILIAN. private ["_radius", "_nearbyPlayers"]; _radius = 25; _nearbyPlayers = []; { if (side _x == blufor && _x distance player < _radius) then {_nearbyPlayers pushBack _x;}; } forEach AllPlayers; hint format["Nearby Players=%1",_nearbyPlayers]; The above version only returns nearby players within _radius using the AllPlayers (see switchableUnits too) Share this post Link to post Share on other sites
Doggifast 2 Posted August 11, 2022 16 minutes ago, deadactionman said: Something like this might help... private ["_radius", "_men","_opfor_men", "_blufor_men", "_ind_men"]; _radius = 25; _opfor_men = []; _blufor_men = []; _ind_men = []; _men = (ASLToAGL getPos player) nearEntities [["Man"], _radius]; { if (side _x == opfor) then {_opfor_men pushBack _x;}; if (side _x == blufor) then {_blufor_men pushBack _x;}; if (side _x == independent) then {_ind_men pushBack _x;}; } forEach _men; hint format["OPFOR List=%1\nBLUFOR List=%2\nIND List=%3", _opfor_men, _blufor_men, _ind_men]; In this example, I made myself a captive which turned me into a CIVILIAN. Huh???????????? Crap... Uhh... I kinda don't understand... The problem is, i need to execute code using forEach on the blufor array... Crap i don't understand. Does this mean that pushBack removes the selected unit from the _men array??? Share this post Link to post Share on other sites
Doggifast 2 Posted August 11, 2022 Just now, Doggifast said: Huh???????????? Crap... Uhh... I kinda don't understand... The problem is, i need to execute code using forEach on the blufor array... Crap i don't understand. Does this mean that pushBack removes the selected unit from the _men array??? OHHHHHHHH I SEEEEEEEEEEEEEEEEEEEEEE Simply execute the code on the blufor array and discard all the others! You're a genious mate! Share this post Link to post Share on other sites
deadactionman 10 Posted August 11, 2022 pushback just adds _x to another array. _men = all the nearby men, then forEach goes through each one (_x each time), checks to see if it matches the criteria and then adds THAT unit to the new array. Share this post Link to post Share on other sites
Doggifast 2 Posted August 11, 2022 2 minutes ago, deadactionman said: pushback just adds _x to another array. _men = all the nearby men, then forEach goes through each one (_x each time), checks to see if it matches the criteria and then adds THAT unit to the new array. Mate you're a genious. Let me see if that works out for my script. Share this post Link to post Share on other sites
Doggifast 2 Posted August 11, 2022 16 minutes ago, deadactionman said: pushback just adds _x to another array. _men = all the nearby men, then forEach goes through each one (_x each time), checks to see if it matches the criteria and then adds THAT unit to the new array. It works perfectly man, thank you very much! Share this post Link to post Share on other sites
Harzach 2517 Posted August 11, 2022 Or simply: private _position = getPos player; // getPos already returns position AGLS private _radius = 25; private _nearUnits = (_position) nearEntities [["Man"], _radius]; private _westUnits = units blufor; private _list = _nearUnits arrayIntersect _westUnits; // create new array of units only found in both arrays hint str _list; Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted August 12, 2022 If its PvE and all players are on same team then you don't need to worry about group side _list = (allPlayers inAreaArray [_position,_radius,_radius,0,FALSE]) - [player]; If there are players on multiple sides and you're trying to filter down for the players side _list = ((allPlayers inAreaArray [_position,_radius,_radius,0,FALSE]) - [player]) select {(side (group _x)) isEqualTo playerSide}; 2 Share this post Link to post Share on other sites