I made a function to do that
/* SYNTAX: [group_leader, vehicle] call compile preprocessFileLineNumbers "detectUnits.sqf"
ARGUMENTS: group_leader: The leader of the group mounted on the vehicle
vehicle: The vehicle itself
*/
//setting local variables
_leader = _this select 0;
_vehicle = _this select 1;
//unit array
_unitArray = units group _leader;
//get all the units mounted in the vehicle
_crew = crew _vehicle;
//function returning value
_isInVehicle = false;
//array used to count the unit inside the vehicle
_vehicleUnits = [];
//check if every unit in leader group is in the vehicle
{
//if the crew unit is a member of the leader group add it to the vehicle array
if (_x in (units group _leader)) then
{
_vehicleUnits = _vehicleUnits + [_x];
};
}
forEach _crew;
/*if the number of units in the vehicle that are members of the original group
is equal to the number of units in the orinal group then all units are in the
vehicle and the returning value is set to true*/
if ((count _vehicleUnits) == (count _unitArray)) then {_isInVehicle = true};
//function returned value
_isInVehicle
This is a function, that means you can use it in trigger or waypoint condition field. To launch the function, since the group you want to check is also the player group, you can use the following code in a trigger condition field:
[leader player, infantryCarrier] call compile preprocessFileLineNumbers "detectCargo.sqf"
where infantryCarrier is the vehicle they have to board (use the name you chose in your mission since you didn't write it) and "detectCargo.sqf" is the script name (insert your script file name if it's different from mine). I tested the script with a small ambush and it works.