BEAKSBY 11 Posted September 26, 2014 ...yet this works for the NATO side? I've created a script that spawns Helos based on your side. But if you're CSAT the, only one Helo is spawned then crashes into the ground? //Side related group creation: switch(side player)do{ case WEST:{ _center = createCenter west; _grp = createGroup west; _planeType = "B_Heli_Light_01_armed_F"; }; case EAST:{ _center = createCenter east; _grp = createGroup east; _planeType = "O_Heli_Light_02_F" ; }; }; // SPAWN PLANES for "_i" from 0 to 2 do { sleep .05; _spos = [(getPosATL player select 0) - (sin _planeDirection) * _planeDistance, (getPosATL player select 1) - (cos _planeDirection) * _planeDistance , 50]; if (_i == 1) then { _plane1Pos = [_spos, _planeSpread,_planeDirection -90] call bis_fnc_relpos; _plane1Pos set [2,_flyHeight]; _spos = _plane1Pos; }; if (_i == 2) then { _plane1Pos = [_spos, _planeSpread,_planeDirection +90] call bis_fnc_relpos; _plane1Pos set [2,_flyHeight]; _spos = _plane1Pos; }; _plane = createVehicle [_planeType, _spos, [], 0, "FLY"]; _plane setRank "LIEUTENANT"; if (_i == 1) then { _plane setRank "SERGEANT"; }; if (_i == 2) then { _plane setRank "SERGEANT"; }; //_grp setSpeedMode "FULL"; _plane setDir _planeDirection; _plane flyInHeight _flyHeight; // PRESET VELOCITY /* _vel = velocity _plane; _plane setVelocity [ (_vel select 0) + (sin _planeDirection * _speed), (_vel select 1) + (cos _planeDirection * _speed), (_vel select 2) ]; */ (side player == WEST) then {_plane setAmmo ["missiles_DAR", 0]} else {_plane setAmmo ["missiles_DAGR", 0]}; _plane allowDamage _allowDamage; _plane setSkill 1; // MAY HAVE TO REMOVE CREW FIRST _crew = crew _plane; {deletevehicle _x} foreach _crew; _crew = [_plane,_grp] call bis_fnc_spawncrew; _grp setFormation "VEE"; _planeArray = _planeArray + [_plane]; _plane sideChat "Air Cav on it's way!"; }; Share this post Link to post Share on other sites
dreadedentity 278 Posted September 26, 2014 Not sure what your problem is at first-glance, but I did change a bit of code and add a lot of comments with suggestions/changes. _opCenter = createCenter west; //move to init.sqf west setFriend [east, 0]; //move to init.sqf _bluCenter = createCenter east; //move to init.sqf east setFriend [west, 0]; //move to init.sqf //Not sure if the above code is actually necessary at all, I have spawned opfor units with scripts in empty missions before without having problems. Either way, you only want this code to run once, because each side only needs one Center. _planePilots = []; //for testing purposes switch(side player)do { case WEST:{ _planeType = "B_Heli_Light_01_armed_F"; }; case EAST:{ _planeType = "O_Heli_Light_02_F" ; }; }; _grp = createGroup (side player); for "_i" from 0 to 2 do { sleep .05; _spos = [(getPosATL player select 0) - (sin _planeDirection) * _planeDistance, (getPosATL player select 1) - (cos _planeDirection) * _planeDistance , 50]; if (_i == 1) then { _plane1Pos = [_spos, _planeSpread,_planeDirection -90] call bis_fnc_relpos; _plane1Pos set [2,_flyHeight]; _spos = _plane1Pos; }; if (_i == 2) then { _plane1Pos = [_spos, _planeSpread,_planeDirection +90] call bis_fnc_relpos; _plane1Pos set [2,_flyHeight]; _spos = _plane1Pos; }; _plane = createVehicle [_planeType, _spos, [], 0, "FLY"]; if (_i == 0) then { _plane setRank "LIEUTENANT"; }else { _plane setRank "SERGEANT"; }; /* if (_i == 1) then { _plane setRank "SERGEANT"; }; if (_i == 2) then { _plane setRank "SERGEANT"; }; */ //can be done with one "if" statement //_grp setSpeedMode "FULL"; _plane setDir _planeDirection; _plane flyInHeight _flyHeight; // PRESET VELOCITY /* _vel = velocity _plane; _plane setVelocity [ (_vel select 0) + (sin _planeDirection * _speed), (_vel select 1) + (cos _planeDirection * _speed), (_vel select 2) ]; */ if (side player == WEST) then //forgot to put "if" at the beginning. { _plane setAmmo ["missiles_DAR", 0] } else { _plane setAmmo ["missiles_DAGR", 0] }; _plane allowDamage _allowDamage; //_allowDamage not defined in posted code _plane setSkill 1; //maximum skill? // MAY HAVE TO REMOVE CREW FIRST {deletevehicle _x} foreach (crew _plane); //no need to assign a new variable _crew = [_plane,_grp] call bis_fnc_spawncrew; _grp setFormation "VEE"; _planeArray = _planeArray + [_plane]; //_planeArray will only be available in the current script. Also, not necessary to do this when you can use (units _grp) to get an array with all units in the group. _plane sideChat "Air Cav on it's way!"; //message will be sent 3 times _planePilots pushBack (driver _plane); //puts each pilot into an array }; [] spawn //will display all helicopter pilots. Used for testing. { while {true} do { hintSilent format["%1", _planePilots]; }; }; Also, I'm not sure what you mean by it spawns and then crashes into the ground. Does it tilt downward and to the right? This is a sign that there's no pilot (I added code already to easily check that). Share this post Link to post Share on other sites
BEAKSBY 11 Posted September 27, 2014 Thanks DreadedEntity, I missed a lot of code efficiencies you pointed out. I'm trying to keep my helos all in formation but it's not working with setFormation. Thread: How do I keep my Helicopters in Formation? Share this post Link to post Share on other sites