There should be no problem with a nested while loop. The following code causes a noticeable jolt of lag, but it works:
private ["_it","_sit","_existencepoints","_return"];
_it = 0;
_existencepoints = 0;
while {_it < 400} do
{
_it = _it + 1;
_sit = 0;
while {_sit < 300} do
{
_sit = _sit + 1;
_existencepoints = _existencepoints + 1;
}
};
if (_existencepoints == 120000) then {hint "I exist"} else {hint "error!"};
_return = _existencepoints;
_return
The function should tell you it exists (isn't that nice?) and return 120000.
I don't really have time to investigate your function in too much detail, but some general tips:
--See if there's a general scripting error. Consult your arma2.rpt or arma2OA.rpt file, or enable in-game scripting error reports using the startup parameter -showScriptErrors .
--Try to isolate the problem. Build in tests (similar to the "I exist!" hint above) to verify that certain values are what you think they should be when they should be.
--Something I noticed from glancing at your script:
_u = _u + (karr_mags0 select _s)
Is (karr_mags0 select _s) an array or a string? If it's a string, the above code is not going to work, because _u is an array. You'll have to write [(karr_mags0 select _s)] instead. I've made that mistake many times.
--You may have to define some local variables BEFORE you use them inside of curly braces {}. Local variables get deleted as soon as the braces end, unless they were defined before they began.
--As haroon says, make sure you've defined all local variables as private at the beginning of the function.