From 87dd340176d378ba57635c5c02bfd860e5910988 Mon Sep 17 00:00:00 2001 From: A Man Date: Sat, 4 Jun 2022 11:18:23 +0200 Subject: [PATCH] Update fn_fillTurrets to prevent out of index error --- SQF/dayz_code/compile/fn_fillTurrets.sqf | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/SQF/dayz_code/compile/fn_fillTurrets.sqf b/SQF/dayz_code/compile/fn_fillTurrets.sqf index e35ff4469..dbdccc3b4 100644 --- a/SQF/dayz_code/compile/fn_fillTurrets.sqf +++ b/SQF/dayz_code/compile/fn_fillTurrets.sqf @@ -30,10 +30,11 @@ local _findRecurse = { if (!(["Horn",_type] call fnc_inString) && (_type != "")) then { local _turret = _x select 1; - local _mags = getArray(configFile >> "CfgWeapons" >> _type >> "magazines"); - local _mag = _mags select 0; + local _mags = getArray(configFile >> "CfgWeapons" >> _type >> "magazines"); - if (!isNil "_mag")then { + if (count _mags > 0) then { + local _mag = _mags select 0; + for "_i" from 1 to _countMags do { _obj addMagazineTurret[_mag,_turret]; }; @@ -45,10 +46,11 @@ local _findRecurse = { local _weapon = _x; if !(["Horn",_weapon] call fnc_inString) then { - local _mags = getArray(configFile >> "CfgWeapons" >> _weapon >> "magazines"); - local _mag = _mags select 0; - - if (!isNil "_mag")then { + local _mags = getArray(configFile >> "CfgWeapons" >> _weapon >> "magazines"); + + if (count _mags > 0) then { + local _mag = _mags select 0; + for "_i" from 1 to _countMags do { _obj addMagazine _mag; };