Robustcolor 30 Posted October 19, 2019 Hi, i need help to make these three codes become a findIf instead of count. My attempts have failed so far. waitUntil {sleep 5; ({(_x distance2d getMarkerpos "Marker1") < 1000} count allPlayers > 0)}; waitUntil {sleep 5; east countSide allUnits <= 2;}; waitUntil {sleep 5; {!isPlayer _x} count allUnits <= 2;}; Share this post Link to post Share on other sites
pierremgi 4739 Posted October 19, 2019 waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000} > -1}; For the others, findIf will not return a count, just the Zero-based position of the first array element for which the code evaluate to true. And no more. Use findIf to detect 0 or some unit(s) satisfying the conditions. 1 Share this post Link to post Share on other sites
Robustcolor 30 Posted October 19, 2019 26 minutes ago, pierremgi said: waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000} > -1}; For the others, findIf will not return a count, just the Zero-based position of the first array element for which the code evaluate to true. And no more. Use findIf to detect 0 or some unit(s) satisfying the conditions. Thanks @pierremgi Is it possible to exclude players if in air in this waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000} > -1}; Does findif work in this code below, how would it look like? waitUntil {sleep 5; {alive _x} count units _grp01 == 0}; Share this post Link to post Share on other sites
pierremgi 4739 Posted October 19, 2019 waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && isTouchingGround _x} > -1}; or waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && (ASLToAGL getPosASL _x)#2 < 2} > -1}; waitUntil {sleep 5; units _grp0 findIf {alive _x} == -1}; 1 Share this post Link to post Share on other sites
LSValmont 789 Posted October 19, 2019 33 minutes ago, pierremgi said: waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && isTouchingGround _x} > -1}; or waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && (ASLToAGL getPosASL _x)#2 < 2} > -1}; waitUntil {sleep 5; units _grp0 findIf {alive _x} == -1}; @pierremgi If I have "marker1", "marker2", "marker3"..... "markerx" in my mission. And I wanted to check every 10 seconds if a player has stepped in range of one of them (using findIf ) and then spawn units at that marker and delete the marker (so the loop does not check that anymore). What would be the best way to do it? This is the loop as example: Spoiler checkMarkers = { _markersArray = ["marker1","marker2","marker3","marker4","marker5"]; if (allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && (ASLToAGL getPosASL _x)#2 < 2} > -1) then { private _spawnPos = markerPos "markerOne"; _spawnPos call fnc_spawnEnemies; deleteMarker "markerOne"; _markersArray = ["marker1","marker2","marker3","marker4","marker5"] - ["marker1"]; }; // loop [ checkMarkers, _markersArray, 10 ] call CBA_fnc_waitAndExecute; }; I need to somehow add a forEach _markersArray; otherwise the script is too long and "manual" but don't know which is the best way to do this. Share this post Link to post Share on other sites
pierremgi 4739 Posted October 20, 2019 If you have less than a hundred markers, 🙂 just add some triggers on them (anyPlayer Present, non repeatable). You will not see a loss in performance, even in MP. I'd rather don't add CBA for nut. Share this post Link to post Share on other sites
Robustcolor 30 Posted October 20, 2019 10 hours ago, pierremgi said: waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && isTouchingGround _x} > -1}; This does not seem to work as intended, it does not exclude air. But this one works, thanks @pierremgi waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000 && (ASLToAGL getPosASL _x)#2 < 2} > -1}; How would it look like if it's made to a if then code? waitUntil {sleep 5; allPlayers findIf {(_x distance2d getMarkerpos "Marker1") < 1000} > -1}; Share this post Link to post Share on other sites