Jump to content
FunnyCookieEver

Check if all players are in vehicle

Recommended Posts

As the title says, I want to check if all alive players are in the helicopter. Simple evacuation but i don't know how to make helicopter stay on the ground until all players are inside. I figured out, that setting fuel to 0 will make it stay on the ground but how to set it back to 1 when all player are inside? If there is any other way to do it I would be glad to know about it.

Share this post


Link to post
Share on other sites
[] spawn {
	heli setFuel 0;
	private _go = false;

	while {!_go} do {
		_go = true;
		{
			if (alive _x && !(_x in heli)) exitWith {_go = false;};
		} forEach allPlayers;
		sleep 1;
	};
	
	heli setFuel 1;
};

There are undoubtedly better ways of coding this but this should work.  Untested though. 

  • Thanks 1

Share this post


Link to post
Share on other sites
waitUntil {sleep 1; {alive _x} count allPlayers == {_x in _helo} count allPlayers};
_helo doMove (getPos myTarget);

I like this (untested) solution. You could put the condition ({alive _x} count allPlayers == {_x in _helo} count allPlayers) in a trigger or waypoint as well if you don't want to script too much.

 

I noticed this is a little older post, but you might still find the solution useful for this or something else. There is also a special scripting section on the forum that you might find useful.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
20 hours ago, joostsidy said:

waitUntil {sleep 1; {alive _x} count allPlayers == {_x in _helo} count allPlayers};

-> Here! Have a more efficient version.

waitUntil {sleep 1; allPlayers findIf {alive _x && !(_x in _helo)} == -1};

Finds the first player who is alive but not in the helo, if no player was found who is alive and outside the helo (== -1) return true to the waitUntil and continue the script.

  • Like 2
  • Thanks 2

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

×