Jump to content
raptor2x

Vehicle fired Event Handler

Recommended Posts

Hello,

So basically I'm trying to do something when a player fires with a mortar.

This is a simple code I made to check if it's working when the player fires with a MK18, and it's working good:

player addEventHandler ["Fired",{	if (_this select 1 == "srifle_EBR_F") then	{            do something here	};}];
So now I'm trying to adapt the code for the mortar, this is what I tried :
player addEventHandler ["Fired",{	if (_this select 1 == "mortar_82mm") then	{            do something here	};}];
It's not working and I probably know why "This EH will not trigger if a unit fires out of a vehicle. For those cases an EH has to be attached to that particular vehicle.", the mortar is a vehicle.

So from what I understand I need to attach the Event Handler to the vehicle and not to the player itself.

Can you explain me how can I do that ?

Thank you !

Share this post


Link to post
Share on other sites

depending of ur scipt this could be a solution:

(vehicle player) addEventHandler ["Fired",{ if (_this select 1 == "mortar_82mm") 
then { do something here };}];

but this is only helpful if the player is inside the mortar at the time the EH is added.

 

 

EDIT

another thing could be to give ur mortar a global variable name in editor or at the time u spawn it.

mortar1 = "mortar_classname" createVehicle mortar_position;

then u could use that variable to add the EH:

mortar1 addEventHandler ["Fired",{ if (_this select 1 == "mortar_82mm") then 
{ do something here };}];

or u try jshocks solution in next post...

Edited by sarogahtyp

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

×