Cloughy 0 Posted March 12, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _Group = _this select 0 _grUnits = units _Group _grTrig = list lz _i = 0 #LoopStart _Max = count _grUnits _grTrig = list lz ?(((_grUnits select _i) in _grTrig) && (alive (_grUnits select _i))):_i = _i + 1 ~1 ? _Max > _i : goto "LoopStart" ? _Max =< _i : intrig = 1; publicVariable "intrig"; Hint "script finished" Exit Where lz is the trigger where i want to know if all lads are in. Prob is(used to work) I see the hint message, but the variable isnt set. ie my choppers dont go, but if i use my radio trigger to set the var, intrig =1; publicvariable "intrig"; the helos take off. My MP coop is running on arma_server.exe dedi. Is there any issues with global vars being set in scripts, rather than a trigger? Cheers GC Any help. Share this post Link to post Share on other sites
Scillion 0 Posted March 12, 2007 Have you tried this in a trigger. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ({_x in heli1} count units mygroup == {alive _x} count units mygroup) LOOK HERE for more info Share this post Link to post Share on other sites
Cloughy 0 Posted March 12, 2007 Havnt tried that, but forgot to mention that there is 30 lads in my group, spread across 3 Helos. the script runs when i get out of my helo, then the script should wait until all the lads that have survived, are in the LZ trigger. I had it working fine before, but tried to stop it messing up when i got out and some of the lads were dead, but hadnt been reported KIA yet. Cheers GC Share this post Link to post Share on other sites
VictorFarbau 0 Posted March 12, 2007 Cloughy, Quote[/b] ]Is there any issues with global vars being set in scripts, rather than a trigger? No there is not - I use them a lot in my missions. But there's some awkward twists in your "#LoopStart" loop as I see it (correct me if I'm wrong). 1. _i never gets increased unless a unit is in the trigger and is alive. Imagine a unit is dead, _i will never be increased and the loop never ends. 2. When the loop ends, just set intrig and publish it, no more conditions are needed then. This is redundant. Just my 2 cents, Victor Share this post Link to post Share on other sites
Cloughy 0 Posted March 13, 2007 The idea is, that _i will get incremented if the unit is in the trig and alive, if a unit is dead, then it will loop, that it why i count the units in the group and the trig again at the top of the script. so it can adjust the values, _i should end up == to the max no of alive lads in the grp. @Victor, Could you provide an example please? Cheers GC Share this post Link to post Share on other sites
VictorFarbau 0 Posted March 13, 2007 I could show you an example but syntaxwise it would be identical to your statements. If I may advise you to change something: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _Max =< _i : intrig = 1; publicVariable "intrig"; Change this to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> intrig = 1 publicVariable "intrig" Reason 1: no semicolons needed in sqs if you use one line per statement (redundancy) Reason 2: no need to insert another condition once you just left the loop based on a condition (redundancy). Plus, it could be that "=<" is not a valid operator (syntax). Better use "less=" if you need to - but in this case it shouldn't be necessary. Your current code risks to leave "intrig" in an undefined state. Cheers, Victor Share this post Link to post Share on other sites
Big Dawg KS 6 Posted March 14, 2007 Have you tried this in a trigger.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ({_x in heli1} count units mygroup == {alive _x} count units mygroup) LOOK HERE for more info Use the count command like Scillion demonstrated!! It will replace your entire loop. Also, your script is much less effective than using the count command. For one, using incriments is just stupid, if one of the units who was already checked dies or leaves the trigger than you get false results. Also, you're not updating units _Group, so if it changes (for example someone joins or leaves the group) then again it won't work correctly. Just replace the whole thing with this and look up the count command in the biki: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Group = _this select 0 @({alive _X && _X in list lz} count (units _Group) >= {alive _X} count (units _Group)) publicVariable "intrig" Hint "script finished" exit Share this post Link to post Share on other sites
Cloughy 0 Posted March 14, 2007 Thanks, Sorted it now i used ({_x in list lz2} count units group1 == {alive _x} count units group1) Where lz2 is the trigger. Cheers For the Help. GC Share this post Link to post Share on other sites