Jump to content
Sign in to follow this  
kittycat

eventhandler hit

Recommended Posts

How to setup a "hit" eventhandler correctly? I want the car that is hit to report the damage based on the below condition.

Quote[/b] ]?( getdammage (_this select 0) > 0.01): t1 exec "dammage_check.sqs"

exit

Share this post


Link to post
Share on other sites

I wrote some stuff back in the day on eventHandlers for ofp here.

You'll want to substitue comref with biki, but other than that, pretty much all the information in that thread is still relevent word for word in arma today.

There's also a few very informative posts by others in there too, so be sure and look at them as well.

BTW, I wouldn't go replying in that old thread. It's long dead and should probably stay that way wink_o.gif.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit addEventHandler ["hit",{if(getdammage (_this select 0) > 0.01)then{t1 exec "dammage_check.sqs"}}];

You should probably take advantage the rest of the '_this' array (there are 3 items for hit; the unit that was hit, the unit that fired the round (if nobody fired it then this is just the unit that was hit again), and the damage the hit causes).

Share this post


Link to post
Share on other sites

I have tried this

in init.sqs

Quote[/b] ]t1 addEventHandler ["hit",{[t1] exec "truck_blast.sqs"}]

*******

_unit = _this slect 0

_shooter = _this slect 1

_damage = _this slect 2

player globalChat format["Unit Firing: ""%1""", _unit]

player globalChat format["weapon: ""%1""" , _shooter ]

player globalChat format["muzzle: ""%1""" , _damage ]

exit

wont work

Share this post


Link to post
Share on other sites

oh id does actaually work on soldiers. However I want it to work on cars. looks like hit eventhandlers wont react on cars getting fired at with rifles

Share this post


Link to post
Share on other sites

Out of curiosity, does it work with cars getting hit by say, an rpg? Probably not, if rifles don't.

That's interesting though. Wonder if it's a bug?

Share this post


Link to post
Share on other sites
_unit = _this slect 0

_shooter = _this slect 1

_damage = _this slect 2

I guess thats a direct copy paste, so might wanna fix the typo.

slect != select

Share this post


Link to post
Share on other sites
oh id does actaually work on soldiers. However I want it to work on cars. looks like hit eventhandlers wont react on cars getting fired at with rifles

Rifles don't cause enough damage on cars is why. The hit EH only fires when significant damage is done.

Share this post


Link to post
Share on other sites
oh id does actaually work on soldiers. However I want it to work on cars. looks like hit eventhandlers wont react on cars getting fired at with rifles

Rifles don't cause enough damage on cars is why. The hit EH only fires when significant damage is done.

Ohh, nm. I misread what you said. Thought you said "Rifles don't cause damage on cars is why".

---------------------------

Will the "dammaged" event handler work in place of the "hit" event handler? The difference is slight, but the information passed is different.

Depends on what you're needing to do.

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
Sign in to follow this  

×