One of the biggest concerns for me and many other scripters when writing event-handler-oriented codes is that if someone removes our EHs by mistake (e.g. using incorrect ID, like how many newbies just remove 0) or intentionally (many newbies doing removeAllXXXEventHandlers), our design could fail entirely.
Thus, I would like to ask for scripting commands that allow us to detect and counter these problems.
This command checks if the event handler still exists and has not been removed yet:
isEventHandlerValid [entity, "name", ID]
entity: can be NAMESPACE (maybe only missionNamespace? for mission/user EHs)/OBJECT/GROUP/CONTROL/DISPLAY
name: event handler name
ID: number: EH ID
returns: number:
1: Still exists
0: Was removed
-1: Invalid (never added, which happens if ID >= nextID, or ID is negative)
Alternatively, for mission/user EHs the syntax can be:
isEventHandlerValid ["name", ID]
or
"name" isEventHandlerValid ID