Robustcolor   30 Posted October 23, 2019 lol, missed reading that 😄 3 hours ago, Dedmen said: private _activeMarkers = _markers select { private _markerPos = getmarkerpos _x; //Get all players inside circle of _markerdist radius around _markerPos //_markerdist might need to be halfed here, didn't use inAreaArray before private _playersInArea = allPlayers inAreaArray [_markerPos, _markerdist, _markerdist]; count _playersInArea > 0 }; Thanks @Dedmen Share this post Link to post Share on other sites
LSValmont   789 Posted October 23, 2019 3 hours ago, Dedmen said: Get all markers with players in <_markerdist distance to it. private _activeMarkers = _markers select { private _markerPos = getmarkerpos _x; //Get all players inside circle of _markerdist radius around _markerPos //_markerdist might need to be halfed here, didn't use inAreaArray before private _playersInArea = allPlayers inAreaArray [_markerPos, _markerdist, _markerdist]; count _playersInArea > 0 };   Thank you, exactly what I needed! Share this post Link to post Share on other sites
Robustcolor   30 Posted October 23, 2019 Is it possible to make a "allPlayers" check instead of the "player" with this code? Like Allplayers findif etc. _distanceMarkers = _markers apply {[player distance getmarkerpos _x, _x]};  Share this post Link to post Share on other sites
Dedmen   2588 Posted October 24, 2019 17 hours ago, Robustcolor said: Is it possible to make a "allPlayers" check instead of the "player" with this code? Like Allplayers findif etc. _distanceMarkers = _markers apply {[player distance getmarkerpos _x, _x]};  I don't quite know what you want? _distanceMarkers = []; { private _marker = _x; _distanceMarkers append (allPlayers apply {[_x distance getmarkerpos _marker, _marker, _x]}) } forEach _markers; distanceMarkers now contains distances for all players, and all markers. Share this post Link to post Share on other sites
Robustcolor   30 Posted October 24, 2019 1 hour ago, Dedmen said: I don't quite know what you want? _distanceMarkers = []; { private _marker = _x; _distanceMarkers append (allPlayers apply {[_x distance getmarkerpos _marker, _marker, _x]}) } forEach _markers; distanceMarkers now contains distances for all players, and all markers. Thank you @Dedmen  My script looks like this now. _markers = ["A1","A2","A3","A4","A5","A6","A7","A8","A9"]; _markerdist = 400; while {true} do { _distanceMarkers = []; { private _marker = _x; _distanceMarkers append (allPlayers apply {[_x distance getmarkerpos _marker, _marker, _x]}) } forEach _markers; _distanceMarkers sort true; _marker = (_distanceMarkers select 0) select 1; _markerPosition = (_distanceMarkers select 0) select 0; if (_markerPosition < _markerdist) then { [getmarkerpos _marker] call Wise_fnc_Ambushai; waitUntil {sleep 5; allPlayers findIf {(_x distance2d getmarkerpos _marker) < 500} ==-1}; }; sleep 5; };  Share this post Link to post Share on other sites
GEORGE FLOROS GR   4206 Posted October 24, 2019 11 hours ago, Robustcolor said: waitUntil {sleep 5; allPlayers findIf  Just check this a little bit , because , this way it will activate even for the dead players since https://community.bistudio.com/wiki/allPlayers 1 Share this post Link to post Share on other sites
Robustcolor   30 Posted October 24, 2019 11 minutes ago, GEORGE FLOROS GR said:  Just check this a little bit , because , this way it will activate even for the dead players since https://community.bistudio.com/wiki/allPlayers Would you recommend doing something like this?  _ap = allPlayers;  _Aliveplayers = _ap select {alive _x};  Would it work? Share this post Link to post Share on other sites
GEORGE FLOROS GR Â Â 4206 Posted October 24, 2019 _allPlayers = (allPlayers - entities "HeadlessClient_F") select {alive _x}; this can be also with different ways. 1 Share this post Link to post Share on other sites
Robustcolor   30 Posted October 25, 2019 8 hours ago, GEORGE FLOROS GR said: _allPlayers = (allPlayers - entities "HeadlessClient_F") select {alive _x}; this can be also with different ways. Thank you @GEORGE FLOROS GR.  Since i'm using this waitUntil {sleep 5; allPlayers findIf in few more scripts, maybe i should be using this that i found in one of the bohemias mission. onPlayerRespawn.sqf _null = (_this select 1) execVM "Scripts\BuryCorpse.sqf"; BuryCorpse.sqf _body = _this; waitUntil {sleep 1; {(_x distance _body) < 25} count allPlayers == 0}; deleteVehicle _body; That should do it, removing the dead players near those allPlayers findIf positions. I'm rarely using execVM so gonna make it a function instead since it will be activating alot, or if it would work just putting the code inside the onPlayerRespawn.sqf. 1 Share this post Link to post Share on other sites
Dedmen   2588 Posted October 25, 2019 44 minutes ago, Robustcolor said: Since i'm using this waitUntil {sleep 5; allPlayers findIf in few more scripts, maybe i should be using this that i found in one of the bohemias mission. No you shouldn't.  44 minutes ago, Robustcolor said: _null = This is useless and makes no sense.  44 minutes ago, Robustcolor said: {(_x distance _body) < 25} count allPlayers == 0 this always iterates through all players, even if the condition is already true for the first player thats checked. findIf exists at the first hit, thus being way more efficient. 1 Share this post Link to post Share on other sites
Robustcolor   30 Posted October 25, 2019 Thanks for the help @Dedmen Share this post Link to post Share on other sites
GEORGE FLOROS GR   4206 Posted October 25, 2019 14 hours ago, Robustcolor said: onPlayerRespawn.sqf  Try : ( and maybe add some sleep also ) initplayerlocal.sqf player addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; _unit = _this select 0; _pos = getPosATL _unit; _holder = nearestObjects [_pos, ["WeaponHolder", "groundWeaponHolder", "WeaponHolderSimulated"], 2]; { deleteVehicle _x; }forEach _holder + [_unit]; }];  Share this post Link to post Share on other sites
Robustcolor   30 Posted October 29, 2019 This work great @Dedmen I just have one question. Is it possible to make it exclude players in air so it won't activate. private _markers = ["A1","A2","A3","A4","A5","A6","A7","A8","A9"]; private _markerdist = 400; _allPlayers = (allPlayers - entities "HeadlessClient_F") select {alive _x}; while {true} do { _distanceMarkers = []; { private _marker = _x; _distanceMarkers append (_allPlayers apply {[_x distance getmarkerpos _marker, _marker, _x]}) } forEach _markers; _distanceMarkers sort true; _marker = (_distanceMarkers select 0) select 1; _markerPosition = (_distanceMarkers select 0) select 0; if (_markerPosition < _markerdist) then { [getmarkerpos _marker] spawn Ambushai; waitUntil {sleep 5; _allPlayers findIf {(_x distance2d getmarkerpos _marker) < 500} ==-1}; }; sleep 5; };  Share this post Link to post Share on other sites
Dedmen   2588 Posted October 29, 2019 15 minutes ago, Robustcolor said: Is it possible to make it exclude players in air so it won't activate. _allPlayers = (allPlayers - entities "HeadlessClient_F") select {alive _x && (getPos _x select 2 < 20)};  only players below height of 20m Share this post Link to post Share on other sites
Robustcolor   30 Posted October 29, 2019 18 minutes ago, Dedmen said: _allPlayers = (allPlayers - entities "HeadlessClient_F") select {alive _x && (getPos _x select 2 < 20)};  only players below height of 20m Did not work, it still activated fnc if in air and above 100meters. Share this post Link to post Share on other sites
killzone_kid   1326 Posted October 29, 2019 unitsBelowHeight Share this post Link to post Share on other sites
Dedmen   2588 Posted October 29, 2019 39 minutes ago, Robustcolor said: Did not work, it still activated fnc if in air and above 100meters. Ah yeah. I only did that check once, outside of the while loop. Ofc thats not gonna work. I'm too tired to think I shouldn't post here.  As KK said.. But I wonder whether this works.. replacing the _allPlayers variable like this, but not modifying the original (the private is important) while {true} do { private _allPlayers = _allPlayers unitsBelowHeight 20;  2 Share this post Link to post Share on other sites
Robustcolor   30 Posted January 6, 2020 For anyone using this script i added this code at the top, makes it only check for alive players and below height 20.  The isEqualTo stops the script from running if no players is found. So no errors. private _markers = ["A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13","A14","A15"]; private _markerdist = 350; while {true} do { private _allPlayers = (allPlayers - alldeadmen unitsBelowHeight 20); if !(_allPlayers isEqualTo []) then {  Share this post Link to post Share on other sites