Jump to content
Sign in to follow this  
JacobJ

Eventhandler "hit" doesnt work on some objects??

Recommended Posts

Hey

I have created an loudspeaker object from the small objects menu. The problem is, that a addeventhandler hit, doesnt work on it. Here is my code:

this addEventHandler ["hit", {[] execVM "speakerhit.sqf"}];

in the speakerhit.sqf I just have a hint "hey";

Ive tried putting this eventhandler on a soldier and it works. I have tried a barrel and a road cone and both work, but not on objects, where they not have an icon in the editor, but just a question mark.

Can it be true that it doesnt work with those question mark objects?

Can I somehow simulate this? Maybe make a road cone invisible (but still hit-able), so that when the invisible road cone gets hit it hideObject's the loudspeaker?

I have tried hideObject on the road cone, but it can't be hit by bullets.

Any suggestions?

/Jacob

Share this post


Link to post
Share on other sites

"Hit" doesn't activate because the object doesn't get enough damage. Some objects just don't get damage from projectiles.

Edited by Celery

Share this post


Link to post
Share on other sites

Ahh okay, but I still can't get it working. I have tried this code:

this addEventHandler ["HandleDamage",{[] execVM "speakerhit.sqf"}]

But it still wont run the script..

---------- Post added at 15:18 ---------- Previous post was at 14:46 ----------

Okay, ive found out that the loudspeaker can't take any damage. I tried with the same loudspeaker, just from the EU misc folder and that can take damage.

Now I just need to increase the damage that a bullet does to the speaker. I have found this, but it reports and error back that I can't see a solution for. This is the code:

this addEventHandler ["HandleDamage",{if (_this select 3=="") then {damage (_this select 0)+(_this select 2)*10}}]

The error should be here (_this select 3(ERROR)=="")

Can you help me out here Celery?

Share this post


Link to post
Share on other sites

If you want the speaker to be damaged by just one shot, simply have the HandleDamage EH destroy the object once it triggers maybe?

Share this post


Link to post
Share on other sites

And how would I do that? I have tried to run a script that setdamage 1 to the speaker, but that doesnt seem to work.

---------- Post added at 15:31 ---------- Previous post was at 15:25 ----------

Okay got it working. This code did the trick:

this addEventHandler ["Handledamage",{_this select 0 setdammage 1}];

Share this post


Link to post
Share on other sites

hehe thank you and thanks for the help!

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  

×