Jump to content
Mattmad1234

End a mission when only one group/team is left alive

Recommended Posts

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. 

  • Like 1

Share this post


Link to post
Share on other sites

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

  • Thanks 2

Share this post


Link to post
Share on other sites
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.

 

  • Like 3

Share this post


Link to post
Share on other sites

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;
			};
		};

 

  • Like 2

Share this post


Link to post
Share on other sites
54 minutes ago, Grumpy Old Man said:

Edit: corrected function condition

 

Thank you very much Grumpy ,  for providing all this codes !   :icon14:

  • Like 2

Share this post


Link to post
Share on other sites
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 by GEORGE FLOROS GR
reedited question
  • Like 1

Share this post


Link to post
Share on other sites

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!

  • Like 1

Share this post


Link to post
Share on other sites

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!

  • Like 1

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

×