nelo_riot 8 Posted October 21, 2017 Hi Guys, I have written a HoldAddaction script (below) which returns all the dead Opfor units and applies the action, this is in the init.sqf. It functions as intended for SP&MP use for placed Units. If any units are dynamically spawned via other scripts/mods then this will not function on these units. Is this because the If/Then script has only initialised once when server is created and then for each player? I have tried using a While/Do loop but due to the tick time if will continuously add a new HoldAddAction for each time it ticks which obviously kills the frames, I'm looking for a way for this to loop every so often to ensure the newly spawned units inherit this HoldAddAction. Spoiler While {true} do { { if (side _x isEqualTo EAST) then { _x addEventHandler ["Killed", {[ (_this select 0), "Search Body", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "(!alive _target) && ((_this distance _target) < 3)", "_caller distance _target < 3", {}, {}, {execvm "Fncs_Looting\EastLoot.sqf"}, {}, [], 3, 6, true, false ] remoteExec ["BIS_fnc_holdActionAdd"]; }]; }; } forEach allUnits;}; Share this post Link to post Share on other sites
pierremgi 4826 Posted October 21, 2017 You need to addAction once, checking a true/false variable, but better use the MEH with no more loop! in init.sqf addMissionEventHandler ["entityKilled", { params ["_killed", "_killer", "_instigator"]; if (getNumber (configFile >> "cfgVehicles" >> typeof _killed >> "side") == 0 && local _killed) then { [ _killed, "Search Body", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {execvm "Fncs_Looting\EastLoot.sqf"}, {}, [], 3, 6, true, false ] remoteExec ["BIS_fnc_holdActionAdd",[0,-2] select (isdedicated),_killed]; } }]; 1 Share this post Link to post Share on other sites
nelo_riot 8 Posted October 22, 2017 Thanks Pier, I will test it later on, would that be more efficient then doing an InitPost? Share this post Link to post Share on other sites