Jump to content
atmo

Testing for presence of an Event Handler

Recommended Posts

I probably being stupid again, and I suspect I have missed it already in the forums..

 

How do I test an object for the presence of an event handler? There seem to plenty of commands to add and remove them...

 

I noticed @Larrow  used 

!( isNil { _x getVariable "HitEH" } )

in a post recently.... Is that the same for all EHs?

 

So reloaded would be "ReloadedEH"?

 

I ask because I am transferring objects from servers to clients/HCs and I am not sure if they transfer with some or all of their respective EHs etc.... I am trying to test this but I would like to ask the community for a comprehensive answer before trying to test every single one....

 

Atmo

Share this post


Link to post
Share on other sites
33 minutes ago, atmo said:

I noticed @Larrow  used 


!( isNil { _x getVariable "HitEH" } )

in a post recently.... Is that the same for all EHs?

If you read that code again you will see that I save the event ID on the target when I add the event.

_target setVariable[ "HitEH", _target addEventHandler[ "Hit", { /*BLAH*/ } ] ];

Other than storing the ID there is no way to get a list of ID's for currently active events.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@atmo, use this function to check for presence of event handler of given type:

params [
    ["_object", objNull, [objNull]],
    ["_type", "", [""]]
];

if ((isNull _object) or {_type == ""}) exitWith {false};

private _index = _object addEventHandler [_type, ""];

_object removeEventHandler [_type, _index];

_index > 0

 

  • Like 4

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

×