Hope this helps.
// CreateAndCargo.sqf
// [chopper, side, group unit classes, destination] execVM "CreateAndCargo.sqf";
// group unit classes is an array of soldier classes, one class per each member of the group
// destination is a position where the group will move once unloaded
private["_chopper", "_targetpos", "_group_i", "_i", "_unit", "_wp", "_side"];
_chopper = _this select 0;
_side = _this select 1;
_infantrytypes = _this select 2;
_targetpos = _this select 3;
_group_i = createGroup _side;
_i = 0;
{
if (_i == 0) then
{
_unit = _group_i createUnit [_x,[0,0,30], [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "CORPORAL";
_group_i selectLeader _unit;
}
else
{
_unit = _group_i createUnit [_x,[0,0,30], [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "PRIVATE";
};
_unit setskill 0.5;
_unit moveInCargo _plane;
_i = _i + 1;
} forEach _infantrytypes;
_wp = _group_i addWaypoint [_targetpos, 0];
[_group_i, 1] showWaypoint "NEVER";
[_group_i, 1] setWaypointType "MOVE";