Jump to content
Alert23

On HIT Explode (script help)

Recommended Posts

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
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

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Hey,

first of all thanks for your help and this does indeed work.

  • Like 1

Share this post


Link to post
Share on other sites

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

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
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

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×