Jump to content
Sign in to follow this  

Recommended Posts

Hi Guys,

this script has had me tearing my hair out for the last few hours.

What I'm trying to do is spawn three C-130 at the south end of Chernarus and have them fly to a waypoint in the north where they will be deleted by a trigger which will also cause the script to run again hence creating another three to fly north and be deleted and so on etc etc.

However I keep getting a 'generic error' when the script runs and it says there is an "invalid number in express" on line 22 - _crew2 doMove (getMarkerPos "exit2");.

If anyone could help me get this working it would be much appreciated and also tips on how to improve my scripting/coding is always welcomed!

//Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)


private ["_herc1","_herc2","_herc3","_plane1","_plane2","_plane3","_crew1","_crew2","_crew3"];
_herc1 = [getMarkerPos "hercspawn1", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc2 = [getMarkerPos "hercspawn2", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc3 = [getMarkerPos "hercspawn3", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;

_plane1 = _herc1 select 0;
_plane2 = _herc2 select 0;
_plane3 = _herc3 select 0;

_plane1 flyInHeight 170;
_plane2 flyInHeight 150;
_plane3 flyInHeight 170;

_crew1 = _herc1 select 1;
_crew2 = _herc2 select 1;
_crew3 = _herc3 select 1;

_crew1 doMove (getMarkerPos "exit1");
_crew2 doMove (getMarkerPos "exit2"); 
_crew3 doMove (getMarkerPos "exit3");

hint: "spawn Active";

PS - I have the function module included in the editor

Share this post


Link to post
Share on other sites

Your crew is composed of several units, but domove is intended to work with individual units. Try

{_x doMove (getMarkerPos "exit2")} foreach _crew;

Share this post


Link to post
Share on other sites
Your crew is composed of several units, but domove is intended to work with individual units. Try

{_x doMove (getMarkerPos "exit2")} foreach _crew;

Just gave it a try, unfortunately it didn't work and gave me the same errors. Thanks for the suggestion though :) much appreciated!

Share this post


Link to post
Share on other sites

you could try - driver _plane1 domove (getMarkerPos "exit1");

have you tried it with just one plane?

Share this post


Link to post
Share on other sites
you could try - driver _plane1 domove (getMarkerPos "exit1");

have you tried it with just one plane?

Gave the code you suggested a try and still getting the exact same error. Also tried to spawn just one plane etc and yet again the same error :( this one has me scratching my head :confused:

Share this post


Link to post
Share on other sites

Although you have the function module have you given it enough time to start?

Also you will need a unit of that side on the map or the plane won't show.

//Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)
waitUntil {not(isNil "BIS_fnc_init")};

private ["_herc1","_herc2","_herc3","_plane1","_plane2","_plane3","_crew1","_crew2","_crew3"];
_herc1 = [getMarkerPos "hercspawn1", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc2 = [getMarkerPos "hercspawn2", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc3 = [getMarkerPos "hercspawn3", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;

_plane1 = _herc1 select 0;
_plane2 = _herc2 select 0;
_plane3 = _herc3 select 0;

_plane1  setpos [(getpos _plane1 select 0),(getpos _plane1 select 1),(getpos _plane1 select 2)+170];
_plane2  setpos [(getpos _plane2 select 0),(getpos _plane2 select 1),(getpos _plane2 select 2)+150];
_plane3  setpos [(getpos _plane3 select 0),(getpos _plane3 select 1),(getpos _plane3 select 2)+170];


_plane1 flyInHeight 170;
_plane2 flyInHeight 150;
_plane3 flyInHeight 170;

_crew1 = _herc1 select 1;
_crew2 = _herc2 select 1;
_crew3 = _herc3 select 1;

_crew1 doMove (getMarkerPos "exit1");
_crew2 doMove (getMarkerPos "exit2"); 
_crew3 doMove (getMarkerPos "exit3");

hint "spawn Active";

This works for me, I also added some height or they don't start on the ground.

Also I'd do it slightly differently so you don't have to script each aircraft, you just change the code in the call everytime you call the script.

//Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

// null= ["C130J_US_EP1","hercspawn1",005,170,"exit1",WEST] execvm "spawn1.sqf";
waitUntil {not(isNil "BIS_fnc_init")};
_unit = _this select 0;
_start = _this select 1;
_dir   = _this select 2;
_height = _this select 3;
_exit = _this select 4;
_side  = _this select 5;

private ["_herc1","_plane1","_crew1"];

_herc1 = [getMarkerPos _start,_dir,_unit, WEST] call bis_fnc_spawnvehicle;
_plane1 = _herc1 select 0;
_plane1  setpos [(getpos _plane1 select 0),(getpos _plane1 select 1),(getpos _plane1 select 2)+170];
_plane1 flyInHeight 170;
_crew1 = _herc1 select 1;

_crew1 doMove (getMarkerPos _exit);

hint "spawn Active";

Share this post


Link to post
Share on other sites
Although you have the function module have you given it enough time to start?

Also you will need a unit of that side on the map or the plane won't show.

//Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)
waitUntil {not(isNil "BIS_fnc_init")};

private ["_herc1","_herc2","_herc3","_plane1","_plane2","_plane3","_crew1","_crew2","_crew3"];
_herc1 = [getMarkerPos "hercspawn1", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc2 = [getMarkerPos "hercspawn2", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;
_herc3 = [getMarkerPos "hercspawn3", 005, "C130J_US_EP1", WEST] call bis_fnc_spawnvehicle;

_plane1 = _herc1 select 0;
_plane2 = _herc2 select 0;
_plane3 = _herc3 select 0;

_plane1  setpos [(getpos _plane1 select 0),(getpos _plane1 select 1),(getpos _plane1 select 2)+170];
_plane2  setpos [(getpos _plane2 select 0),(getpos _plane2 select 1),(getpos _plane2 select 2)+150];
_plane3  setpos [(getpos _plane3 select 0),(getpos _plane3 select 1),(getpos _plane3 select 2)+170];


_plane1 flyInHeight 170;
_plane2 flyInHeight 150;
_plane3 flyInHeight 170;

_crew1 = _herc1 select 1;
_crew2 = _herc2 select 1;
_crew3 = _herc3 select 1;

_crew1 doMove (getMarkerPos "exit1");
_crew2 doMove (getMarkerPos "exit2"); 
_crew3 doMove (getMarkerPos "exit3");

hint "spawn Active";

This works for me, I also added some height or they don't start on the ground.

Also I'd do it slightly differently so you don't have to script each aircraft, you just change the code in the call everytime you call the script.

//Array - 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group)

// null= ["C130J_US_EP1","hercspawn1",005,170,"exit1",WEST] execvm "spawn1.sqf";
waitUntil {not(isNil "BIS_fnc_init")};
_unit = _this select 0;
_start = _this select 1;
_dir   = _this select 2;
_height = _this select 3;
_exit = _this select 4;
_side  = _this select 5;

private ["_herc1","_plane1","_crew1"];

_herc1 = [getMarkerPos _start,_dir,_unit, WEST] call bis_fnc_spawnvehicle;
_plane1 = _herc1 select 0;
_plane1  setpos [(getpos _plane1 select 0),(getpos _plane1 select 1),(getpos _plane1 select 2)+170];
_plane1 flyInHeight 170;
_crew1 = _herc1 select 1;

_crew1 doMove (getMarkerPos _exit);

hint "spawn Active";

Fantastic, that works!

Thank you very much indeed, all of you for your help!

I do have one last question though, with regards to the working code. Why does

waitUntil {not(isNil "BIS_fnc_init")}; 

make the script work?

Edited by Fumbles88

Share this post


Link to post
Share on other sites

Modules can take a little time to start so the script can run before the module is initialised. If you'd tried to run the script from a trigger it would probably have worked. Also just a simple sleep at the top of the could can be enough but you still run a little risk of it failing if the module hasn't kicked in.

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  

×