Alert23 215 Posted April 13, 2018 Hi all, i have a little problem i want a script to make only the CIV side explode when hit by a bullet by using Eventhandler Hit, but i cant get it work somehow. maybe someone can help me abit with it please. OnHitExplode.sqf: { if (side _x == CIV) then { _x addEventHandler ["Hit", {bomb = "APERSMine_Range_Ammo" createVehicle (_x modelToWorld [0,0,0]); bomb setdamage 1;}];}; } forEach allUnits; note: im not getting any error msg but it doesnt work somehow. Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted April 13, 2018 2 hours ago, Alert23 said: Hi all, i have a little problem i want a script to make only the CIV side explode when hit by a bullet by using Eventhandler Hit, but i cant get it work somehow. maybe someone can help me abit with it please. OnHitExplode.sqf: { if (side _x == CIV) then { _x addEventHandler ["Hit", {bomb = "APERSMine_Range_Ammo" createVehicle (_x modelToWorld [0,0,0]); bomb setdamage 1;}];}; } forEach allUnits; note: im not getting any error msg but it doesnt work somehow. Almost there, you need to setDamage 1 to the bomb: { _x addEventHandler ["Hit",{ params ["_unit"]; _unit removeEventHandler ["Hit",_thisEventHandler]; _bomb = "APERSMine_Range_Ammo" createVehicle (_unit modelToWorld [0,0,0]); _bomb setDamage 1; }]; } forEach (allUnits select {alive _x AND side _x isEqualTo civilian}); This also removes the eventhandler, so it can't trigger itself, resulting in infinite explosions. Cheers 2 1 Share this post Link to post Share on other sites
Alert23 215 Posted April 13, 2018 Hey, first of all thanks for your help and this does indeed work. 1 Share this post Link to post Share on other sites
HazJ 1289 Posted April 14, 2018 Also change CIV to civilian - Unless CIV is a macro that actually references civilian then it doesn't matter. Share this post Link to post Share on other sites
BeeDeeEss 0 Posted August 5, 2018 Hey, I want a gas canister to explode when they got 1 hit and tried your script but its not working. I made a OnHitExplode.sqf and put it in the mission folder: { _x addEventHandler ["Hit",{ params ["_unit"]; _unit removeEventHandler ["Hit",_thisEventHandler]; _bomb = "APERSMine_Range_Ammo" createVehicle (_unit modelToWorld [0,0,0]); _bomb setDamage 1; }]; } forEach (allUnits select {alive _x AND side _x isEqualTo civilian}); and wrote in the gas canister init : execVM "OnHitExplode.sqf"; and nothing happens when i shot it with my AK, there are no errors. Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted August 5, 2018 4 hours ago, BeeDeeEss said: Hey, I want a gas canister to explode when they got 1 hit and tried your script but its not working. I made a OnHitExplode.sqf and put it in the mission folder: { _x addEventHandler ["Hit",{ params ["_unit"]; _unit removeEventHandler ["Hit",_thisEventHandler]; _bomb = "APERSMine_Range_Ammo" createVehicle (_unit modelToWorld [0,0,0]); _bomb setDamage 1; }]; } forEach (allUnits select {alive _x AND side _x isEqualTo civilian}); and wrote in the gas canister init : execVM "OnHitExplode.sqf"; and nothing happens when i shot it with my AK, there are no errors. Well this snippet only works for all civilian units, you need to adjust it to work for other objects. For canisters, place those gas canisters in the editor, name them gascan1, gascan2 etc: _gasCans = [gascan1,gascan2,gascan3];//put your objects in here { _x addEventHandler ["Hit",{ params ["_unit"]; _unit removeEventHandler ["Hit",_thisEventHandler]; _bomb = "APERSMine_Range_Ammo" createVehicle (_unit modelToWorld [0,0,0]); _bomb setDamage 1; }]; } forEach _gasCans; Cheers 1 Share this post Link to post Share on other sites