Kydoimos 916 Posted May 12, 2016 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
R3vo 2654 Posted May 12, 2016 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'}"; }; 1 Share this post Link to post Share on other sites
Kydoimos 916 Posted May 12, 2016 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
h - 169 Posted May 12, 2016 Should be _this instead of this... As in _this select 0 1 Share this post Link to post Share on other sites
Kydoimos 916 Posted May 12, 2016 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
h - 169 Posted May 12, 2016 Could be as easy as _unit = (_this select 0); 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
Kydoimos 916 Posted May 12, 2016 Could be as easy as _unit = (_this select 0); 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
h - 169 Posted May 12, 2016 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.. 1 Share this post Link to post Share on other sites
Kydoimos 916 Posted May 12, 2016 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
R3vo 2654 Posted May 12, 2016 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
Kydoimos 916 Posted May 12, 2016 Really - thank you both! :D Share this post Link to post Share on other sites