Search the Community
Showing results for tags 'countallunits'.
Found 1 result
-
Restricting a while loop count, but not exiting complete.
GuyJ posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi all. I have been playing since flashy and did very basic editing over the years (triggers and a lot of borrowing from others), but at 36 now I seemingly have the urge to slowly learn how to do more complex stuff, but that also means I have limited time between watch repair and normal life! Anyway, the issue I'd appreciate some help with is something I'm sure is very simple, or whatever it is could someone be kind enough to explain their process a little or what I'm doing wrong. I don't want to just copy and paste if you know what I mean, but this is something I have tried to understand from Fockers Arma Scripting tutorial. I have a civilian playable with allowDamage false; I am watching a while loop spawn individual soldiers for both sides and then just kill each other. The while loop does this while my variable of _total <20 is being assessed. I have countAllUnits as the defined variable for _total, but it doesn't count the actual amount of units being created. Why is that, please? My issue I'd like to sort is that once I trigger the while loop from my civi player addAction and I see the units spawn, I don't want to have to repeat the addAction to 'top-up' the _total. I'd like it somewhat dynamic, so some kind of sleep before repeating the process is all my unaware script mind can think of! Hope someone can guide me. Cheers. _total = count allUnits; hint format ["Total units in game:%1",_total]; sleep 4; _grp = createGroup West; _grp2 = createGroup East; _blds = nearestBuilding AmmoSups; while {_total <20} do { sleep 1; _newsoldier = "B_Soldier_GL_F" createUnit [getPos _blds,_grp]; hint format ["Units in game:%1", _total]; _newsoldier2 = "O_support_MG_F" createUnit [getPos AmmoSups,_grp2]; hint format ["Units in game:%1", _total]; sleep 1; _grp setFormation "STAG COLUMN"; _grp setBehaviour "AWARE"; _wp = _grp addWaypoint [position AmmoSups,0]; _total = _total +1; sleep 0.5; }; hint "while loop complete."; if I local exec the hint for the total I get the actual amount which I don't want it to be so high (above 20), but I also don't want it to drop below 20 alive players at any point. A perpetual war if you will... :)