Alpine_gremlin 13 Posted September 20, 2017 Hey guys so I`m just getting back into scripting missions again. I`m really not that great but I am trying create a script for an IFA3 scenario where the player can call in a P-39 Airacobra for two bombing missions. The plane would ideally spawn in, attack the AO, then leave and despawn. The script is to be called via a radio trigger. I can`t seem to get it to work. Would any of you much more experienced lads be willing to take a look? Cheers! // Check if maximum CAS missions have already been called. if (counter <=2) then { _plane = createVehicle ["LIB_US_P39", getMarkerPos("p39_spawn"), [], 0, "FLY"]; _pilot = [[11301.808, 36955.238, 0.265], IND_F, ["LIB_US_pilot"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; ((units _pilot) select 0) moveInDriver _plane; _wpcas = _pilot addWaypoint [getMarkerPos("bomb_run"), 0]; _wpcas setWaypointBehaviour "SAFE"; _wpcas setWaypointCombatMode "RED"; _wpcas setWaypointCompletionRadius 1500; curator1 addCuratorEditableObjects [[_plane, true]; _wpcas1 = _pilot addWaypoint [getMarkerPos ("p39_spawn"), 0]; _wpcas setWaypointBehaviour "SAFE"; _wpcas setWaypointCombatMode "RED"; _wpcas setWaypointCompletionRadius 1500; _planegone = deleteVehicle _plane; counter = counter + 1; [resistance, "HQ"] sideChat "Aircraft Returning to Rearm. Additional CAS mission available in 10 minutes."; sleep 36000; }else { hint "Command is unable to provide any further CAS missions!"; }; Share this post Link to post Share on other sites
pierremgi 4822 Posted September 21, 2017 did u define counter = 0 somewhere? use direct BIS_fnc_spawnGroup for plane + crew (pilot is already in) _grp_P39 = [[11301.808, 36955.238,150], IND_F, ["LIB_US_P39"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; // or something like that _wp_cas = _grp_P39 addWaypoint ...; _plane = vehicle leader _grp_P39; // add this line for plane object ident. waypoint completion radius is huge! >> that means early completed! // don't mix (perhaps) with placement radius curator1 addCuratorEditableObjects [[_plane], true]; _wpcas1 = _grp_P39 addWaypoint ... _wp_cas1 setWaypointBehaviour... // refer to the last added waypoint (but useless if you don't change anything in behaviour or combat mode) _planegone = deleteVehicle _plane; _plane spawn { sleep 1; waitUntil {_this distance [11301.808, 36955.238,150] < 100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted September 21, 2017 Thanks for the reply! I will give this a try tomorrow. Yes I defined counter as true in the init.sqf and then set counter = 0. I probably did that wrong though :/ Share this post Link to post Share on other sites
pierremgi 4822 Posted September 21, 2017 counter = 0 anywhere running before your script is OK. Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted September 22, 2017 I really appreciate the time that you`re taking to help me! Taking your corrections into account, this is what I have: counter = 0; // Check if maximum CAS missions have already been called. if (counter <= 2) then { _grp_P39 = [[11301.808, 36955.238,150], IND_F, ["LIB_US_P39"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; _wp_cas = _grp_P39 addWaypoint [getMarkerPos("bomb_run1"), 0]; _wp_cas setWaypointType "SAD"; _wp_cas setWaypointBehaviour "SAFE"; _wp_cas setWaypointCombatMode "RED"; _wp_cas setWaypointCompletionRadius 50; _plane = vehicle leader _grp_P39; curator1 addCuratorEditableObjects [[_plane], true]; _wp_cas1 = _pilot addWaypoint [getMarkerPos ("p39_spawn"), 0]; _wp_cas1 setWaypointBehaviour "SAFE"; _wp_cas1 setWaypointCombatMode "RED"; _wp_cas1 setWaypointCompletionRadius 1500; _planespawn { sleep 1; waitUntil {_this distance 11301.808, 36955.238, 150] <100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; counter = counter + 1; [resistance, "HQ"] sideChat "Aircraft Returning to Rearm. Additional CAS mission available in 10 minutes."; sleep 36000; }else { hint "Command is unable to provide any further CAS missions!"; }; Unlike my first attempt, I get no error messages when I activate the script, but the aircraft doesn`t appear to spawn in. I will keep trying! Share this post Link to post Share on other sites
baton1990 30 Posted September 22, 2017 Hellow, try to place marker on map where plane will spawn. And try to use something like: _grp_P39 = [getpos MARKERNAME, IND_F, ["LIB_US_P39"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; Share this post Link to post Share on other sites
pierremgi 4822 Posted September 22, 2017 1 hour ago, baton1990 said: Hellow, try to place marker on map where plane will spawn. And try to use something like: _grp_P39 = [getpos MARKERNAME, IND_F, ["LIB_US_P39"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; getMarkerPos Share this post Link to post Share on other sites
pierremgi 4822 Posted September 22, 2017 6 hours ago, Alpine_gremlin said: I really appreciate the time that you`re taking to help me! Taking your corrections into account, this is what I have: counter = 0; // Check if maximum CAS missions have already been called. if (counter <= 2) then { _grp_P39 = [[11301.808, 36955.238,150], IND_F, ["LIB_US_P39"], [], [], [], [], [], 232] call BIS_fnc_spawnGroup; _wp_cas = _grp_P39 addWaypoint [getMarkerPos("bomb_run1"), 0]; _wp_cas setWaypointType "SAD"; _wp_cas setWaypointBehaviour "SAFE"; _wp_cas setWaypointCombatMode "RED"; _wp_cas setWaypointCompletionRadius 50; _plane = vehicle leader _grp_P39; curator1 addCuratorEditableObjects [[_plane], true]; _wp_cas1 = _pilot addWaypoint [getMarkerPos ("p39_spawn"), 0]; _wp_cas1 setWaypointBehaviour "SAFE"; _wp_cas1 setWaypointCombatMode "RED"; _wp_cas1 setWaypointCompletionRadius 1500; _planespawn { sleep 1; waitUntil {_this distance 11301.808, 36955.238, 150] <100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; counter = counter + 1; [resistance, "HQ"] sideChat "Aircraft Returning to Rearm. Additional CAS mission available in 10 minutes."; sleep 36000; }else { hint "Command is unable to provide any further CAS missions!"; }; Unlike my first attempt, I get no error messages when I activate the script, but the aircraft doesn`t appear to spawn in. I will keep trying! check the position of spawn and the class name of the aircraft (I don't have your mod). Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted September 22, 2017 9 hours ago, pierremgi said: check the position of spawn and the class name of the aircraft (I don't have your mod). Okay I have cleaned everything up a bit and deleted some extra code that was not needed. The classname and spawn position both work. However... counter = 0; // Check if maximum CAS missions have already been called. if (counter <= 2) then { _grp_P39 = [getMarkerPos "p39_spawn", IND_F, ["LIB_US_P39"], [], [], [], [], [], 10] call BIS_fnc_spawnGroup; _wp_cas = _grp_P39 addWaypoint [getMarkerPos("bomb_run1"), 0]; _wp_cas setWaypointType "SAD"; _wp_cas setWaypointBehaviour "SAFE"; _wp_cas setWaypointCombatMode "RED"; _wp_cas setWaypointCompletionRadius 50; _plane = vehicle leader _grp_P39; _wp_cas1 = _grp_P39 addWaypoint [getMarkerPos ("p39_spawn"), 0]; _wp_cas1 setWaypointCompletionRadius 150; _planespawn { sleep 1; waitUntil {_this distance getMarkerPos "p39_spawn" < 100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; counter = counter + 1; [resistance, "HQ"] sideChat "Aircraft Returning to Rearm. Additional CAS mission available in 10 minutes."; sleep 36000; }else { hint "Command is unable to provide any further CAS missions!"; }; I`m a bit confused on the portion that despawns the plane and crew. Since I am using a marker and no longer map coordinates, I have also adjusted the "_planespawn" portion. I get the "error missing ;" here so I`m assuming I wrote something incorrectly. Share this post Link to post Share on other sites
pierremgi 4822 Posted September 22, 2017 _plane spawn { sleep 1; waitUntil {_this distance getMarkerPos "p39_spawn" < 100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; 1 Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted September 22, 2017 25 minutes ago, pierremgi said: _plane spawn { sleep 1; waitUntil {_this distance getMarkerPos "p39_spawn" < 100 && count waypoints group driver _plane < 2}; _plane deleteVehicleCrew driver _plane; deleteVehicle _plane; }; Okay! The plane at least spawns in now though it doesn`t follow any of the waypoints that I assigned. I`ll keep looking for what I`m missing! Share this post Link to post Share on other sites