Moon_chilD 200 Posted February 24, 2019 Hey, I want to have a Module in my mission that when its placed adds an eventhandler to every unit in a specific faction. So far that shouldn't be to hard, however what I don't manage to think of right now is, how do I make sure that even units placed by Zeus get this Eventhandler? So the code should be something like this: if ((faction _unit) in _factionList) then { CODE TO ADD EVENTHANDLER }; Does anyone have an idea how I could make it so that even units placed by Zeus that are in a faction found in _factionList get this eventhandler. If it helps: CBA is an option. Thanks in advance Moony Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted February 24, 2019 40 minutes ago, Moon_chilD said: even units placed by Zeus Hello there Moon_chilD ! This is an example on how to make your code work also with the spawned units , with an exlude list. -add a unique Var (variable ) GF_ARL = { code , your eventhandler }; [] spawn { while {true} do { { if ( ((alive _x)) && (!(_x getVariable ["Var_GF_ARL",false])) && (!((typeOf _x) in GF_ARL_Exclude_List)) /* //________________ You can filter the side here ________________ && {((side group _x) == west || (side group _x) == east || (side group _x) == independent || (side group _x) == civilian)} */ // && (side group _x == playerSide) // && (!(side group _x == playerSide)) ) then { _x spawn GF_ARL; }; _x setVariable ["Var_GF_ARL",true]; {waitUntil {!alive _x}; _x setVariable ["Var_GF_ARL",false]; }; }forEach allUnits; sleep 5; }; }; Share this post Link to post Share on other sites
Moon_chilD 200 Posted February 24, 2019 I thought of a while loop but I always forget that I can assign a Variable @.@ Thank you @GEORGE FLOROS GR 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted February 24, 2019 1 hour ago, Moon_chilD said: Thank you @GEORGE FLOROS GR Just check if there is a MissionEventHandler available , instead of spawning the code : https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler to avoid the loops . Share this post Link to post Share on other sites
Larrow 2822 Posted February 24, 2019 On 2/24/2019 at 5:23 PM, Moon_chilD said: how do I make sure that even units placed by Zeus get this Eventhandler? MCD_factionsList = [ /*...*/ ]; { //Add event to curator module for when an object is placed _x addEventHandler [ "CuratorObjectPlaced", { params[ "", "_object" ]; if ( typeOf _object isKindOf "CAManBase" && { faction _object in MCD_factionsList } ) then { //CODE TO ADD EVENTHANDLER }; //CuratorObjectPlaced does not fire for crewed units //If its a vehicle if ( _object in vehicles ) then { //Add event for each crew member { //CODE TO ADD EVENTHANDLER }forEach ( crew _object select { faction _x in MCD_factionsList } ); }; }]; }forEach allCurators; 1 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted February 24, 2019 Thanks Larrow ! This is only for the spawned units with zeus right ? It's not also about the scripted spawns , is it ? Share this post Link to post Share on other sites
Larrow 2822 Posted February 24, 2019 2 hours ago, GEORGE FLOROS GR said: This is only for the spawned units with zeus right ? Correct. 1 Share this post Link to post Share on other sites
Moon_chilD 200 Posted February 25, 2019 Thank you aswell @Larrow. In my case though a universal approach was actually a good idea since I also wanted script spawned units to be affected. (Though I never knew there was a eventhandler for Zeus Spawned units, so....the more you know xD) Share this post Link to post Share on other sites