jstibbsy 54 Posted July 23, 2016 I'm currently working on an execution script and I am wonder if I can put an if, then and else statement inside an else statement.Here's my code so far: //execute hostage script _exec = _this select 0; _player = _this select 1; _id = _this select 2; _hostage = hostage; _list_of_Pistols = [ "hgun_P07_F", "hgun_Pistol_heavy_01_F", "hgun_Pistol_heavy_02_F", "hgun_ACPC2_F", "hgun_Rook40_F" ]; _list_of_Rifles = [ "Weapon_arifle_MX_F", "Weapon_arifle_MXC_F", "Weapon_arifle_MX_SW_F", "Weapon_arifle_MXM_F", "Weapon_arifle_MX_GL_F" ]; _exec removeaction _id; _hostage removeaction _id; _hostage switchmove "Acts_ExecutionVictim_Loop"; _hostage setCaptive true; if ( ( { _x in _list_of_Pistols } count ( weapons _exec ) ) != 0 ) then { //when called _exec doTarget _hostage; _exec switchmove "Acts_Executioner_StandingLoop"; _hostage doTarget _exec; sleep 10; //if unit has a pistol _exec switchmove "Acts_Executioner_kill"; _hostage switchmove "Acts_ExecutionVictim_Kill"; sleep 1.733; _hostage switchmove "Acts_ExecutionVictim_Kill_end"; _hostage setHit ["head", 1]; sleep 1.667; _exec switchmove "Acts_Executioner_kill_end"; sleep 1.333; _hostage switchmove "Acts_ExecutionVictim_Killterminal"; } else { [ if ( ( { _x in _list_of_Rifles } ) ) then { //when called _exec doTarget _hostage; //if unit has a primary _exec doFire _hostage; //_hostage setHit ["head", 1]; } else { _exec switchmove "Acts_CivilIdle_1"; hint "No weapon to kill hostage!"; }; ]; }; exit; I'm getting an error right around the: else { _exec switchmove "Acts_CivilIdle_1"; hint "No weapon to kill hostage!"; }; ]; }; exit; It says I'm missing a ]Thx :) Share this post Link to post Share on other sites
theend3r 83 Posted July 23, 2016 Why do you have [] brackets around the last if-then-else? And the double () brackets? A habit or some magic? Share this post Link to post Share on other sites
jstibbsy 54 Posted July 23, 2016 Ok I removed the [] and the double bracketsI'm getting an error around here: else { if ( error if: Type code expected bool Share this post Link to post Share on other sites
theend3r 83 Posted July 23, 2016 if ( ( { _x in _list_of_Rifles } ) ) then Afaik, the first condition can't be in {} brackets, that's why it says code instead of bool. The next conditions can be in brackets but... read https://community.bistudio.com/wiki/Code_Optimisation#Conditions. Share this post Link to post Share on other sites
jstibbsy 54 Posted July 23, 2016 I solved it, I changed the code into a nested if-then-else statement Share this post Link to post Share on other sites