bspendlove 10 Posted August 20, 2015 Currently I have: { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "formation2",["B_Soldier_02_f"],25]; I want to create a list of vehicles in my Heli/Plane spawn script and delete all vehicles around my marker in this list -> (MH-9, AH-9, A-10, etc...) I am not up to scripting knowledge but this is my view: _currentSpawns = ["AH-9". "MH-9", "Other class names... etc..."] { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "formation2",[_currentSpawns],25]; I am currently not in my house and can't try this, but would something like this work??? Share this post Link to post Share on other sites
jshock 513 Posted August 21, 2015 Should just need: _currentSpawns = ["AH-9", "MH-9", "Other class names... etc..."] { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "formation2",_currentSpawns,25]; 1 Share this post Link to post Share on other sites
bspendlove 10 Posted August 21, 2015 Should just need: _currentSpawns = ["AH-9", "MH-9", "Other class names... etc..."] { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "formation2",_currentSpawns,25]; Thank you, now how about if I wanted to pull a certain class out of _currentSpawns? Like.... _currentSpawns[0] will pull the AH-9? Share this post Link to post Share on other sites
Schatten 291 Posted August 21, 2015 how about if I wanted to pull a certain class out of _currentSpawns? Like.... _currentSpawns[0] will pull the AH-9? _currentSpawns = ["AH-9", "MH-9", "Other class names... etc..."] { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "formation2", [_currentSpawns select 0],25]; 1 Share this post Link to post Share on other sites
bspendlove 10 Posted August 21, 2015 Hmmm, fnc_spawn_ah9 = { { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "heli_spawn",[_vehicleNames],15]; sleep 1; _spawnHeli = "B_Heli_Light_01_armed_F" createVehicle getMarkerPos "heli_spawn"; _spawnHeli setDir _direction; _spawnHeli lock 0; player moveInDriver _spawnHeli; [] exec "Scripts\PilotTraining\heli_functions.sqf"; }; _s addAction ["<t color='#00FFFF'>Spawn AH-9</t>",{call fnc_spawn_ah9;}]; Doesn't seem to delete the vehicle before spawning in a new one? I obviously forgot something! xD Share this post Link to post Share on other sites
Schatten 291 Posted August 21, 2015 _vehicleNames is array! { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "heli_spawn",_vehicleNames,15]; But if you select item from array using select, you should place it into square brackets: { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "heli_spawn",[_vehicleNames select 0],15]; 1 Share this post Link to post Share on other sites
bspendlove 10 Posted August 21, 2015 -snip- Thank you a ton. :D Share this post Link to post Share on other sites
bspendlove 10 Posted August 21, 2015 The array list with the Classnames don't seem to work: _vehicleNames = ["B_Heli_Light_01_armed_F","B_Heli_Light_01_F","B_Heli_Attack_01_F","B_Heli_Transport_01_F", "O_Heli_Light_02_F","O_Heli_Light_02_unarmed_F","O_Heli_Attack_02_F","O_Heli_Attack_02_black_F","I_Heli_Transport_02_F","I_Heli_light_03_F","I_Heli_light_03_unarmed_F"]; fnc_spawn_ah9 = { { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "heli_spawn",_vehicleNames, 50]; sleep 1; _spawnHeli = "B_Heli_Light_01_armed_F" createVehicle getMarkerPos "heli_spawn"; _spawnHeli setDir _direction; _spawnHeli lock 0; player moveInDriver _spawnHeli; [] exec "Scripts\PilotTraining\heli_functions.sqf"; }; so I could change the createVehicle to select from the array but I will do that later, I want to make sure all vehicles around the heli_spawn are being deleted (only classes in the _vehicleNames list) but it won't delete them. I've tried to create a separate function to delete vehicles: fnc_delete_all = { { deleteVehicle _x; } forEach nearestObjects [getMarkerPos "helistudent",[_vehicleNames select 0], 10]; }; But that doesn't seem to work when used in addAction. Instead of using _vehicleNames and actually writing the classname of the vehicle, it works perfectly but I thought it would tidy things up a tiny bit :P Share this post Link to post Share on other sites
Schatten 291 Posted August 21, 2015 Script don't work because _vehicleNames is local variable and it's undefined in fnc_delete_all. Do it global variable by deleting underscore. 1 Share this post Link to post Share on other sites
SilentSpike 84 Posted August 21, 2015 For a better understanding of local/global variables in arma see here: https://community.bistudio.com/wiki/Variables#Namespace 1 Share this post Link to post Share on other sites
bspendlove 10 Posted August 21, 2015 Thank you both a ton, it is working now. I will have a long read, thank you for that link. :) Share this post Link to post Share on other sites