bangabob 41 Posted August 19, 2013 I have a trivial problem with setting a group name My mission involves a group of 5 playable BLUFOR units. The team leader has in his init field runners = group this; Now this is fine 80% of the time. However if no one joins as the Team leader slot then the runners = group this; isn't initialized and the runners group doesn't exist. Any help appreciated. Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 19, 2013 I had the same problem. Put a check to see if the unit nil or not. If it is nil then do nothing if not then add your code. Share this post Link to post Share on other sites
bangabob 41 Posted August 19, 2013 I had the same problem. Put a check to see if the unit nil or not. If it is nil then do nothing if not then add your code. Thanks. Sorry for being a bit lazy but since you have already being through this how did you code that exactly? Share this post Link to post Share on other sites
Larrow 2779 Posted August 19, 2013 If the five BLUFOR are the only players in this mission. init.sqf runners = group (playableUnits select 0); else name your five BLUFOR units e.g u1,u2,u3,u4,u5 init.sqf runners = { if (_x in [u1,u2,u3,u4,u5]) exitwith { group _x};}foreach playableUnits; Share this post Link to post Share on other sites
Johnson11B2P 3 Posted August 20, 2013 I would use the runners = group (playableUnits select 0); because if for instance no one joined the "u2" slot during multiplayer you would get and error because technically that unit doesn't exist because it wasn't initialized. Share this post Link to post Share on other sites
bangabob 41 Posted August 20, 2013 (edited) Thanks that works. runners = { if (_x in [s1,s2,s3]) exitwith { group _x};}foreach allUnits; Next question. Each runner unit is given an event handler which removes them from 'runners' group after they are 'killed'. { _x addEventHandler ["killed", {_this execVM "RunnerDead.sqf"}]; }foreach units runners; RunnerDead.sqf _runnerName=_this select 0; _runnerName removeEventHandler ["killed", 0]; [_runnerName] join grpNull; The problem arises when the 'killed runner' re-joins the game. He is then added again into the runners which messes up all my triggers. I have tried using publicvariables to stop the script adding the unit back into the group after the mission has started with no success. For example init.sqf if (isnil "MissionLaunched") then { MissionLaunched=false;publicvariable "MissionLaunched"; }; if (!MissionLaunched) then { runners = { if (_x in [s1,s2,s3]) exitwith { group _x};}foreach allUnits; { _x addEventHandler ["Fired", {_this execVM "RunnerDead.sqf"}];}foreach units runners; };}; sleep 5; MissionLaunched=true;publicvariable "MissionLaunched"; There has to be a way to stop this. Thanks for reading Edited August 20, 2013 by BangaBob Share this post Link to post Share on other sites
cuel 25 Posted August 20, 2013 You could also just put runners = group this; in all of the group unit's init fields. Share this post Link to post Share on other sites
Larrow 2779 Posted August 21, 2013 Thanks that works. runners = { if (_x in [s1,s2,s3]) exitwith { group _x};}foreach allUnits; Sorry but as Johnson picked up on, i was brainfarting that night and that will throw an undefined error at you if someone is not in a slot.If the first option i wrote is not suitable because you have other playable units that are not in this group then do it the way cuel suggests. Just out of interest why are you using allUnits? Your OP says this is for catching a group consisting of players so why the need to loop around every unit in the mission? Share this post Link to post Share on other sites
bangabob 41 Posted August 21, 2013 Yeah i know it could give a undefined error if all slots weren't taken. However i want full control over when the unit can be added to the runner group. Refer to my last question in post #6. Why am i using 'allunits' over 'playableunits'. Playable units Doesn't work in the editor and allunits does Share this post Link to post Share on other sites
byrgesen 1 Posted August 21, 2013 You could also just put runners = group this; in all of the group unit's init fields. This is exactly what i did and it works perfectly fine :) Share this post Link to post Share on other sites
bangabob 41 Posted August 21, 2013 You could also just put runners = group this; in all of the group unit's init fields. Yeah i think i will just end up using this. No need to over complicate matters ;) Share this post Link to post Share on other sites