Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:Adds a system event handler.

Multiple event handlers of the same type can be added. Unlike addEventHandler, system events are not tied to a specific object. Instead, they are triggered by global ("system") events, such as opening the OME / RTE.

The code run by the event handler has access to the following variables:

  • _this - Data passed by the event itself (contents vary depending on event type).
  • _index - Index of event handler being run (useful for removing the event).
  • _data - Extra data passed, when this event handler is added.
See VBS Custom Event Handlers for a list of available event handler types. Scripts can create their own custom event handlers using fn vbs fireSysEventHandler.


Syntax:[type, code, params] call fn_vbs_addSysEventHandler
  • type: String - Type of event handler to add.
  • code: Code or String - Code that should be executed once the event occurs.
  • params: Anything - Data to pass to the code in the _data variable
Return Value:Number - Index of added event. Note that the same index can be used again, after the events are removed.


When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.


_idx = ["editorUnload","[_index] execVM 'dialog.sqf'"] call fn_vbs_addSysEventHandler

Additional Information

See also: VBS Custom Event Handlers, fn vbs removeSysEventHandler, fn vbs fireSysEventHandler, addEventHandler