Results 1 to 7 of 7

Thread: Eventhandler "hit" doesnt work on some objects??

  1. #1

    Eventhandler "hit" doesnt work on some objects??

    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

  2. #2
    "Hit" doesn't activate because the object doesn't get enough damage. Some objects just don't get damage from projectiles.
    Last edited by Celery; Jun 4 2011 at 14:36.

  3. #3
    Staff Sergeant
    Join Date
    Nov 10 2009
    Location
    Denmark
    Posts
    307
    Author of the Thread
    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?

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

  5. #5
    Staff Sergeant
    Join Date
    Nov 10 2009
    Location
    Denmark
    Posts
    307
    Author of the Thread
    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}];

  6. #6
    Great! Happy speaker shooting. heh

  7. #7
    Staff Sergeant
    Join Date
    Nov 10 2009
    Location
    Denmark
    Posts
    307
    Author of the Thread
    hehe thank you and thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •