aseliot 2 Posted May 12, 2017 This is about changing the gear of units spawned by another script from an addon. I tried using a trigger with ANY and "this" but it doesn't seem to work for units being spawned in? Or maybe the trigger was too big (about 4500,3000). There is an Init EH but is is only for configs. There is also the HandleIdentity EH but then you need a reference to the unit being spawned. So thing is the unit is spawned by an external script that is not mine and I have no handle to the unit. Share this post Link to post Share on other sites
7erra 629 Posted May 12, 2017 Well the best strategy would be to find the script where the unit was spawned. Then execute your own script inside the addon script with 0 = _unit execVM "YOURSCRIPT.sqf"; And then refer to it in your script with _unit = _this; Can you share the addon script? Share this post Link to post Share on other sites
Midnighters 152 Posted May 12, 2017 What were you trying to accomplish with the trigger? Share this post Link to post Share on other sites
aseliot 2 Posted May 12, 2017 27 minutes ago, Midnighters said: What were you trying to accomplish with the trigger? Any unit that would enter the trigger would get a small gear change, but it fired only once for some reason (reapeating was on true) but it must've been a fluke, it doesn't seem to work for units that are spawned in for some reason. 1 hour ago, 7erra said: Well the best strategy would be to find the script where the unit was spawned. Then execute your own script inside the addon script with. Huh? I don't have access to the script, I am not allowed the change it the addon belongs to someone else. (Ravage) Share this post Link to post Share on other sites
7erra 629 Posted May 12, 2017 I guess a while true loop has to do then: _yourLoadout = /*Your loadout however you saved it, preferrably with getUnitLoadout */ while {true} do { { _var = _x getVariable "LoadoutSet"; if (isNil "_var") then { _x setUnitLoadout _yourLoadout; // Or whatever code _x setVariable ["LoadoutSet", true]; }; } forEach allUnits; _unitCount = count allUnits; systemChat "TEST"; waitUntil {_unitCount != count allUnits}; }; This was written in a rush and not tested, but you should get the idea 1 Share this post Link to post Share on other sites
aseliot 2 Posted May 13, 2017 11 hours ago, 7erra said: I guess a while true loop has to do then: -snip- This was written in a rush and not tested, but you should get the idea Yeah that would work, although I don't like the thought of it looping through all the units all the time. I got it work your way. But I would still like to try and use a trigger but it only keeps firing once for some reason... any ideas? _gmasktrg = createTrigger ["EmptyDetector", (getMarkerPos "playablemrk")]; _gmasktrg setTriggerArea [_trgx, _trgy, 0, true]; _gmasktrg setTriggerActivation ["ANY", "PRESENT", true]; _gmasktrg setTriggerStatements ["this", //code etc.. Already checked trgx,y they are something like 4500,3250 and based on playablemrk size. So it should just overlap the marker. It only fires once for some reason although it is set on repeatable. Share this post Link to post Share on other sites
pierremgi 4905 Posted May 13, 2017 0 = [] spawn { while {true} do { _theUnits= allUnits; waitUntil {sleep 0.5; count (allUnits - _theUnits) > 0}; _newbies = allunits - _theUnits; hint str (_newbies); }}; That works because no matter if allunits decreases due to dead men. [a,b,c] - [a,b,c,d] gives []. On the other hand, if one spawns (e) [a,b,e] - [a,b,c,d] gives [e] . Then do what you need on the array of spawned units. Share this post Link to post Share on other sites
aseliot 2 Posted May 13, 2017 I am now doing it like this as all spawned units are also added to the garbage collector. 0 = [] spawn { while {true} do { { if (_x isKindOf "CAmanBase") then { _gasmask = _x getVariable ["_hasGasmask",false]; if (!_gasmask) then { removeGoggles _x; _x addGoggles (selectRandom spawnmasks); _x setVariable ["_hasGasmask",true]; }; }; } forEach rvg_garbage_collector; _gcount = count rvg_garbage_collector; waitUntil { _gcount != count rvg_garbage_collector }; }; }; Share this post Link to post Share on other sites
pierremgi 4905 Posted May 13, 2017 0 = [] spawn { while {true} do { _theUnits= allUnits; waitUntil {sleep 0.5; count (allUnits - _theUnits) > 0}; _newbies = allunits - _theUnits; { removeGoggles _x; sleep 0.2; _x addGoggles (selectRandom spawnmasks) } forEach _newbies }}; Add a short delay between remove something and add same thing; That helps in a forEach loop. Share this post Link to post Share on other sites