twisted 128 Posted July 9, 2014 Tricky question (or probably just tricky to me) how do i reference a multidminsional array using Foreach? for example, say i make an array thats [weaponname, amount] _weaponArray = _weaponArray + [_tempWeap, 1 + floor (random 3)]; and then i want to use foreach to add that to an ammobox. { _ammoPackBox addWeaponCargoGlobal [_x]; } foreach _weaponArray; how is it done? i cannot find any reference on how to do it? its importnat to be able to keep the information in an array format as i regulalry delete the ammobox based on user distance but want to keep the weapon and relevant count constant. Share this post Link to post Share on other sites
barbolani 198 Posted July 9, 2014 I'm not in the editor, but.... for "_i" from 0 to (count _weaponArray) - 1 do { _weapon = _weaponArray (select _i (select 0)); _amount = _weaponArray (select _i (select 1)); _ammoPackBox addWeaponCargoGlobal [_weapon, _amount]; }; Share this post Link to post Share on other sites
Tajin 349 Posted July 9, 2014 Much easier actually: { _ammoPackBox addWeaponCargoGlobal _x; } foreach _weaponArray; Share this post Link to post Share on other sites
barbolani 198 Posted July 9, 2014 Much easier actually: { _ammoPackBox addWeaponCargoGlobal _x; } foreach _weaponArray; Totally true! Just removing the [] will do the trick! Share this post Link to post Share on other sites
twisted 128 Posted July 9, 2014 oh thats pretty sweet. thanks will use it Share this post Link to post Share on other sites