Jump to content
Kydoimos

Eventhandler in Config

Recommended Posts

Hi all,
 
I'm having a spot of bother trying to get an eventHandler to work from within a vehicle config. Here is what I have in the object's config;

        class EventHandlers
        {
                hitPart = "_unit = this select 0; if (_unit getHitPointDamage ""Named_Selection"" >= 0.2) then {hint ""Working""}";
        };

Essentially, I want to be able to trigger some coding when a certain selection on the object is damaged (but by default, from the config). The above doesn't throw up any errors, but it's not working either. Any ideas, guys?

 

Thanks, as always, in advance!

Share this post


Link to post
Share on other sites

EHs tend to fail silently. Just to make sure, try this:

     class EventHandlers
        {
                hitPart = "_unit = this select 0; if ( (_unit getHitPointDamage 'Named_Selection') >= 0.2) then {hint 'Working'}";
        };
  • Like 1

Share this post


Link to post
Share on other sites

 

EHs tend to fail silently. Just to make sure, try this:

     class EventHandlers

        {

                hitPart = "_unit = this select 0; if ( (_unit getHitPointDamage 'Named_Selection') >= 0.2) then {hint 'Working'}";

        };

 

Thanks mate! Tried that, but still no cigar. When I add a hitPart eventHandler via the debug console, it works fine, but I have to assign the object a global variable. Again, thank you for your suggestion! :)

Share this post


Link to post
Share on other sites

Should be _this instead of this...

As in _this select 0

  • Like 1

Share this post


Link to post
Share on other sites

 

Should be _this instead of this...

As in _this select 0

 

Hi mate! Thanks for that - I've given it a go, but now I'm getting an error message:

Error GetHitPointDamage: Type Array, Expected Object

No doubt I'm missing something really silly, but I can't put my finger on it!

Share this post


Link to post
Share on other sites

Could be as easy as _unit = (_this select 0); :shrug:

 

EDIT:

It's because hitPart returns a nested array so _this select 0 is infact an array.

 

EDIT2:

So you could try _unit = (_this select 0) select 0;

Share this post


Link to post
Share on other sites

 

Could be as easy as _unit = (_this select 0); :shrug:

 

Still getting this error popping up with that too:

Error GetHitPointDamage: Type Array, Expected Object

Thank you for the helpful suggestion though! :) I'll keep trying!

Share this post


Link to post
Share on other sites

Seems I probably ninja-edited the post so check it again :P

(_this select 0) select 0 should work I guess.

 

 

The initial thought was faulty because just assumed it was Arma being picky about brackets which it can sometimes be..

  • Like 1

Share this post


Link to post
Share on other sites

 

So you could try _unit = (_this select 0) select 0;

 

You're a super star -H! It worked like a charm! Thanks!

Share this post


Link to post
Share on other sites

Seems I probably ninja-edited the post so check it again :P

(_this select 0) select 0 should work I guess.

 

 

The initial thought was faulty because just assumed it was Arma being picky about brackets which it can sometimes be..

 

Ah, I remember now, I had a similar issue a while back with hitPart EH because I didn't realised that it returns a nested array.

Share this post


Link to post
Share on other sites

Really - thank you both! :D

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

×