Mattmad1234 3 Posted December 20, 2018 I'm looking to make a mission end when only one team is left alive. Is there a way to do this either using a trigger, or a script of some sort? Any help on this would be greatly appreciated as I am somewhat new to the editor. 1 Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted December 20, 2018 I guess you want to check if at least one group that contains players is left alive? Condition check returning true when one or less teams containing at least one player is left: count (allGroups select {count (units _x select {isPlayer _x AND alive _x}) > 0}) <= 1 End mission when condition returns true: //initServer.sqf in mission root _endMission = [] spawn { waitUntil {sleep 3;count (allGroups select {count (units _x select {isPlayer _x AND alive _x}) > 0}) <= 1}; "SideScore" call BIS_fnc_endMissionServer; }; Check BIS_fnc_endMissionServer for further parameters. Edit: corrected function condition, thanks for the hint @GEORGE FLOROS GR Cheers 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted December 20, 2018 3 hours ago, Mattmad1234 said: only one team Hello there Mattmad1234 and welcome also to Bis Forums ! 35 minutes ago, Grumpy Old Man said: Condition Grumpy , if you check , this is not working. 3 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted December 20, 2018 I have this working : []spawn { while {true} do { _allGroups = count (allGroups select {count (units _x select {alive _x}) > 0}); hint format ["%1",_allGroups]; if (_allGroups isEqualTo 4) exitwith {[] call BIS_fnc_endMission;}; sleep 1; }; }; 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted December 20, 2018 54 minutes ago, Grumpy Old Man said: Edit: corrected function condition Thank you very much Grumpy , for providing all this codes ! 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted December 20, 2018 (edited) 10 hours ago, Grumpy Old Man said: thanks So this should be for all the groups and not just player : Spoiler []spawn { waitUntil {(count (allGroups select {count (units _x select {alive _x}) > 0})) isEqualTo 4}; [] call BIS_fnc_endMissionServer; }; Since there is this group discussion , i was trying to delete the empty groups and the ai of each group when the group is dead , but after several attempts i didn't succeed in. # I was also searching about but , nothing ! Thanks ! This was my last attempt : {if ( ((count (units _x)) == 0) && (({alive _x} count units _x)== 0) ) then { _group = _x ; {deleteVehicle _x;} forEach units _group; deleteGroup _x; }} forEach allGroups; Edited December 20, 2018 by GEORGE FLOROS GR reedited question 1 Share this post Link to post Share on other sites
Mattmad1234 3 Posted December 21, 2018 Thank you all for the incredibly helpful responses! Grumpy Old Man's script worked perfectly! Thank you all for the help and quick responses that I got! 1 Share this post Link to post Share on other sites
Mattmad1234 3 Posted December 21, 2018 I have a few more questions regarding some scripting with a mission I am trying to make. however, I will start another thread to do so! 1 Share this post Link to post Share on other sites