Jump to content
Sign in to follow this  
galzohar

moveInCargo for spawned plane fails for unknown reason

Recommended Posts

*see line in bold

if (!isServer) exitWith {};

waitUntil {!isnil "bis_fnc_init" };

_gPlane1 = createGroup west;

_planePos = [(getMarkerPos "mrkC130J") select 0, (getMarkerPos "mrkC130J") select 1, 200];

plane1 = [_planePos, markerDir "mrkC130J", "C130J", _gPlane1] call BIS_fnc_spawnVehicle;

bDrop=false;

_trgDrop = createTrigger ["EmptyDetector", getMarkerPos "mkrDropTrgPos"];
_trgDrop setTriggerArea [300, 300, 0, false];
_trgDrop triggerAttachVehicle [plane1];
_trgDrop setTriggerActivation ["VEHICLE", "PRESENT", false];
_trgDrop setTriggerStatements ["this", "bDrop=true;", ""];

_rUnits = units (group r1);

_planeWP1 = _gPlane1 addWaypoint [getMarkerPos "mrkWP1", 0];
_planeWP2 = _gPlane1 addWaypoint [getMarkerPos "mrkWP2", 0];
_planeWP3 = _gPlane1 addWaypoint [getMarkerPos "mrkWP3", 0];

_planeWP1 setWaypointSpeed "FULL";
_planeWP2 setWaypointSpeed "LIMITED";
_planeWP3 setWaypointSpeed "FULL";

for [{_i=0}, {_i<(count _rUnits)}, {_i=_i+1}] do
{
[b](_rUnits select _i) moveInCargo [plane1, _i];[/b]
};

waitUntil {bDrop};

_rWP = r1 addWaypoint [getPos trgEnd, 0];
_rWP setWaypointSpeed "NORMAL";
_rWP setWaypointFormation "STAG COLUMN";
_rWP setWaypointBehaviour "AWARE";
_rWP setWaypointCombatMode "RED";

{
_x action ["EJECT", plane1];
unassignVehicle _x;
sleep 1;
} forEach _rUnits;

while {true} do
{
sleep 15;
(group r1) setCurrentWaypoint [group r1, 0];
(group r1) setCurrentWaypoint _rWP;
};

RPT:

Error in expression <i+1}] do
{
[b](_rUnits select _i) moveInCargo [plane1, _i];[/b]
};

waitUntil >
 [b]Error position: <moveInCargo [plane1, _i];[/b]
};

waitUntil >
 [b]Error Type Array, expected Object[/b]
File C:\Documents and Settings\galz\My Documents\ArmA 2\missions\C130J_test.Chernarus\c130jdrop.sqf, line 33

r1 is the leader of the group that's supposed to be moved in the plane's cargo. Plane spawns properly and seems to head to the waypoint, however the sqaud will not get in. Another weird thing is that the script reaches the waitUntil {bDrop} regardless of the error, but again the squad does not get moved in.

I've also had a similar script work perfectly but with an editor-placed plane+waypoints+triggers, and the moveInCargo placed in each soldier's init line.

Share this post


Link to post
Share on other sites

tried add assignAsCargo before moveInCargo ?

Share this post


Link to post
Share on other sites

assignAsCargo gives the same kind of error that moveInCargo gives, and is not needed according to my tests with an editor-placed aircraft. Something seems to be wrong with (_rUnits select _i) but I just don't get what. Printing it out as a hint gives the name of the unit, so it's definitely a unit and not an array, as opposed to what the RPT says.

Share this post


Link to post
Share on other sites

From the function help. :) It returns an array.

Returns:

Array:

0: new vehicle (Object).

1: all crew (Array of Objects).

2: vehicle's group (Group).

plane1 select 0 = the actual unit spawned. That's why you're getting the rpt error that it is getting an array instead of an object. :)

Share this post


Link to post
Share on other sites

Yeah, that seems to be it, thx. Didn't realize the array comment was referring to plane1.

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  

×