Jump to content
Sign in to follow this  
Hoot1988

detecting player has entered vehicle?

Recommended Posts

how can i get it so that a trigger is set off when certain units have got in a vehicle in order to complete a objective?

Share this post


Link to post
Share on other sites

You can look how it is done in a simple function groupInVehicle, which is available for download from http://www.ofpec.com/ and I also copy&paste it below.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// ******************************************************************************************

// groupInVehicle.sqf

// There are two possible ways how to use this function:

// #1: You pass only group to the function. In this case, the function returns true if all

// group members are in any vehicle, false if at least 1 member is not in any vehicle.

//     The vehicle isn't necessarily the same vehicle for all.

// #2: You pass group and vehicle to the function. In this case, all group members

// need to be in the vehicle passed to the function for true to be returned,

// otherwise the function returns false.

// USAGE:

// init: groupInVehicle = preprocessFile "groupInVehicle.sqf"

// calling #1: [<group>] call groupInVehicle

// calling #2: [<group>, <vehicle>] call groupInVehicle

// returns: <boolean>

// example #1:

// if ( [grpWest1] call groupInVehicle ) then { hint "All are in vehicles!" }

// example #2:

// if ( [grpWest1, truck] call groupInVehicle ) then { hint "All are in truck!" }

// Credits: bardosy, bedges, THobson (inspired by their forum posts)

// Baddo 2005

// You can contact me through www.ofpec.com

// ******************************************************************************************

private "_grpInVehicle";

_grpInVehicle = true;

if ( count _this > 1 ) then

{

if ( {vehicle _x != _this select 1} count units (_this select 0) > 0  ) then

{

_grpInVehicle = false;

};

}

else

{

if ( {_x == vehicle _x} count units (_this select 0) > 0 ) then

{

_grpInVehicle = false;

};

};

_grpInVehicle

Just save the function into your mission directory and use it. Look from Biki for more instructions about using functions. If your units do not form a group then I am sure you are able to adjust this to your situation.

I recommend to always check the functions/scripts available at http://www.ofpec.com/ as there can already be what you need.

Share this post


Link to post
Share on other sites

Depends what your trying to do. A simple way is.

Add this to your init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">GAMEEND_UNITS=[MYUnit01,MYUnit02];

Then for the trigger condition:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(Count (GAMEEND_UNITS-(Crew MyVehicle))==0)

Share this post


Link to post
Share on other sites

basically im trying to configure the differnet endings of my mission

1st is if the hostages are alive and the helicopter survived

2nd is if your team got to the helicopter but one or more hostages is dead

3rd are if the helicopter is destroyed but you and the hostages make it to the secondary extraction

4th is if chopper and hostages are dead and you make it to the second extraction.

For the helicopter survives i have one condition that has to be true, and the same for the hosages.

so if heli dies its false and hostages die its false.

for the first 2 ends i need a mission completed for the objective to reach the extraction, and a condition to be activated for the all the group boarding the heli.

Share this post


Link to post
Share on other sites

no need worked out a way arround where i added a objective completed command after the pickup script then added a command. thanks for the help anyway guys.

admin feel free to delete

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
Sign in to follow this  

×