Rebitaay 13 Posted May 18, 2017 Still a bit new to scripting, working on my second mission. Just wanted to know if there is a cleaner way to code this: private _plane; _plane = selectRandom ["O_Plane_Fighter_02_F","O_Plane_CAS_02_F","I_Plane_Fighter_03_F","I_Plane_Fighter_04_F","B_Plane_CAS_01_F","B_Plane_Fighter_01_F"]; if (_plane == "O_Plane_Fighter_02_F") then {_plane = "To-201 Shikra"}; if (_plane == "O_Plane_CAS_02_F") then {_plane = "To-199 Neophron"}; if (_plane == "I_Plane_Fighter_03_F") then {_plane = "A-143 Buzzard"}; if (_plane == "I_Plane_Fighter_04_F") then {_plane = "A-149 Gryphon"}; if (_plane == "B_Plane_CAS_01_F") then {_plane = "A-164 Wipeout"}; if (_plane == "B_Plane_Fighter_01_F") then {_plane = "F/A-181 Black Wasp II"}; I just want to use less lines, but any other optimizations will be appreciated. Share this post Link to post Share on other sites
pierremgi 4898 Posted May 18, 2017 Sure! a waste of code as you select a string at random, to crush it with something else! The good question is: what do you intend to do? Share this post Link to post Share on other sites
Rebitaay 13 Posted May 18, 2017 Just now, pierremgi said: The good question is: what do you intend to do? The other parts of the script aren't complete yet, but the idea is to select a random fixed-wing aircraft using "_plane" and use that randomly chosen string as the classname in createVehicle. The if statements are going to be for an alert, saying "An enemy ____ has been detected", with the blank space being the name that was set. Not sure how confusing that sounds, let me know if I should clarify more. I'd paste the code, but it's not actually written yet. Share this post Link to post Share on other sites
pierremgi 4898 Posted May 18, 2017 _planes = [ "O_Plane_Fighter_02_F", ......]; _plane = selectRandom _planes; _plane createVehicle position...; _planeName = getText (configfile >> "CfgVehicles" >> _plane >> "displayName"); .... hint format ["An enemy %1 has been detected", _planeName]; 1 Share this post Link to post Share on other sites
Rebitaay 13 Posted May 18, 2017 17 minutes ago, pierremgi said: _planes = [ "O_Plane_Fighter_02_F", ......]; _plane = selectRandom _planes; _plane createVehicle position...; _planeName = getText (configfile >> "CfgVehicles" >> _plane >> "displayName"); .... hint format ["An enemy %1 has been detected", _planeName]; Thank you, that works great! Share this post Link to post Share on other sites