Hi Guys,
i am trying to make a script, where type of reinforcement depends on type units which are just around the commander. But the scripts alway fail to memory error and crash
Please, anyone, look at it where have i mistake.................... or tell ..................... it is shit
--- Unit (10) is a commander and reinf: 3005 - panzers, 3100 - gun, mortar, heavy mg, 3200 - support car and medicine, 3300 - infantry
function HijackF1()
local a = GetNUnitsOfType("arm_light",0) + GetNUnitsOfType("arm_medium",0) + GetNUnitsOfType("spg_antitank",0);
local b = GetNUnitsOfType("art_mortar",0) + GetNUnitsOfType("art_heavy_mg",0) + GetNUnitsOfType("art_gun",0);
local c = GetNUnitsOfType("trn_carrier",0) + GetNUnitsOfType("trn_medicine",0) + GetNUnitsOfType("trn_support",0);
local d = GetNUnitsOfType("soldier",0) + GetNUnitsOfType("art_aagun",0);
if GetNUnitsInScriptGroup(10) == 0 then
Suicide();
else
local x,y = GetObjCoord(10);
if GetNUnitsInCircle(a, x, y, 355) > 0 then
LandReinforcement(3005); end;
if GetNUnitsInCircle(b, x, y, 355) > 0 then
LandReinforcement(3100); end;
if GetNUnitsInCircle(c, x, y, 355) > 0 then
LandReinforcement(3200); end;
if GetNUnitsInCircle(d, x, y, 355) > 0 then
LandReinforcement(3300); end;
RunScript("HijackF1", 1000000);
Suicide();
end;
end;
Many thanks Martin