I have a bunch of fixed MG's named MG1...MG8, and I want to check if theirs a gunner in them or if they have been killed and if do replace them from a limited supply. I'm using an array rather than using a format ["MG%1",_var] so I can vary it with differently named objects.
The code is as follows but I get a type string expected error and a missing semicolon error and I can't fathom out where the codes wrong.
_UKNum=100;
_Location=["MG1","MG2","MG3","MG4","MG5","MG6","MG7","MG8"];
_BaseDefenders = createGroup West;
_debug=true;
while {_UKNum>0} do
{
for [{_i=0}, {_i<8}, {_i=_i+1}] do
{
if (_UKNum>1) then
{
_MGString = (_Location select _i);
_MG = call compile _MGString;
if (isNull gunner _MG) then
{
_UKNum=_UKNum-1;
if (_debug) then {hint format["Numbers : %1",_UKNum]};
_gunner= _BaseDefenders ["SoldierWB", position _MG, [], 0, "NONE"];
_gunner moveInGunner _MG;
};
};
};
sleep 30+(random 30);
};
Can anyone point out the error(s) before my head explodes.