rlex 21 Posted February 21, 2015 Some weird question here, wanted to improve my DUWS fork... I have array of units like that _group = [_position, EAST, ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"],[],[],opfor_ai_skill] call BIS_fnc_spawnGroup; This is called from main script _handle = [_trigger, _size] execvm "createoppatrol.sqf"; So i introduce variable, for example _multiplier = X Where X is, for example, 2. And i need array of ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"] To be multiplied by 2, so the end result will look like ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F","O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"] Is that possible? I have two potential options in my head (but i do not know how to do that and not sure that this is even possible in SQF): 1) Array multiplication, what i described... 2) Run script X times, something like while {a =< _multiplier} do { a = a + 1; _handle = [_trigger, _size] execvm "createoppatrol.sqf"; }; Thanks in advance. Share this post Link to post Share on other sites
jshock 513 Posted February 21, 2015 (edited) _someArray = ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"]; _multipliedArray = []; _multiplier = 2; if (_multiplier < 0) then {_multiplier = 1}; for "_i" from 0 to (_multiplier - 1) step 1 do { _multipliedArray = _multipliedArray + _someArray; }; Edited February 21, 2015 by JShock Share this post Link to post Share on other sites
rlex 21 Posted February 21, 2015 _someArray = ["O_Soldier_TL_F","O_Soldier_AR_F","O_Soldier_LAT_F","O_Soldier_GL_F"]; _multipliedArray = []; _multiplier = 2; if (_multiplier < 0) then {_multiplier = 1}; for "_i" from 0 to (_multiplier - 1) step 1 do { _multipliedArray = _multipliedArray + _someArray; }; Thank you very much! Can i use reference of _multipliedArray in another array, ie _group = [_position, EAST, _multipliedArray],[],[],opfor_ai_skill] call BIS_fnc_spawnGroup; ? Share this post Link to post Share on other sites
jshock 513 Posted February 21, 2015 Yep, and you have an extra "]" in there, fixed below :): _group = [_position, EAST, _multipliedArray,[],[],opfor_ai_skill] call BIS_fnc_spawnGroup; Share this post Link to post Share on other sites
rlex 21 Posted February 22, 2015 Yep, and you have an extra "]" in there, fixed below :): _group = [_position, EAST, _multipliedArray,[],[],opfor_ai_skill] call BIS_fnc_spawnGroup; Thank you again. Coded that into DUWS and it's working now. Wasn't great idea after i saw amount of units... But still fun. Share this post Link to post Share on other sites
dreadedentity 278 Posted February 22, 2015 Coded that into DUWS and it's working now Did you make DUWS? If so, I had a great time playing it Share this post Link to post Share on other sites
iConic-21 13 Posted February 22, 2015 thanks was looking for something like this Share this post Link to post Share on other sites
rlex 21 Posted February 22, 2015 Did you make DUWS? If so, I had a great time playing it No, i maintain my own fork since original was abandoned. Share this post Link to post Share on other sites