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


As opposed to Event Handler List, the following event handlers are not associated with a specific objects, but react to system events (e.g. opening the editor).

Also, see


Whether an event is added via a function call or a config class, both can be removed via the fn vbs removeSysEventHandler function.

Available events for either method are listed Event Handlers by Category.

via Function

If an event is added via fn vbs addSysEventHandler, the code segment 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 was added

Be aware that, just like with any other Functions A-Z, in order for this to work, the capitalization is crucial, and the function library must be included in the script: #include "\vbs2\headers\function_library.hpp".

via Config

The class CfgSystemEventHandlers defines the events that should be added.
Events added via this method do not have access to the _data variable.

  • _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)

Example configuration:

class CfgSystemEventHandlers {
  //event handler type 
  class editorLoad {
    // Code that is executed when EH fires
    nul = "_this execVM 'script.sqf'";

  class editorUnload {
    // _this and _index are available, but _data is not (nothing can be passed in the config)
    nul = "hint str [_this, _index, _data]"; 

Custom Events

To handle other events (which aren't in the Event Handlers by Category), follow these steps:

  • Add a new event handler (use any name that isn't already defined) via the Definition.
  • To initiate an event (have it fire), call fn vbs fireSysEventHandler at the appropriate position in your code.

e.g. Fire an event every time a dialog is opened:

#include "\vbs2\headers\function_library.hpp"
["dialogOpened","_nul=[_this] execVM 'dlgopened.sqf'"] call fn_vbs_addSysEventHandler;
In the code that opens a dialog, call:
["dialogOpened", [_ctrl]] call fn_vbs_fireSysEventHandler;
This will fire the "dialogOpened" event, which, in turn, will call the "dlgopened.sqf" script.

Event Handlers by Category

Editor / AAR

These events are run by the editor scripts (OME or RTE) as well as the AAR playback system, and the C2 map (but not the "game" map, as set in the options).

editorLoad, editorUnload

Runs when the editor is opened or closed.

Passed array: [editor mode, map]

  • editor mode: String - Either "RTE", "OME", "C2", or "AAR"
  • map: Control - Editor map control (used in many editor scripting commands)


Runs when switching between Default, First-Person, Bullet & Nose cameras in editor.

Passed array: [camera name]

  • camera name: String - Either "DEFAULT", "FIRSTPERSON", "GUN" or "NOSE"

Inventory / Unit Loadout Editor

These events are run by the inventory scripts (applies to both, the in-game inventory interface, as well as the editor interface used to modify a unit's gear). All inventory events pass the same data in the first element; an array, described below.

Common data: [inventory mode, owner, display]

  • inventory mode: String - Method the inventory dialog is being used. One of:
  "PLAYER" - opened by the player, to modify his own inventory or that of teammates
  "TEMPLATE" - opened in the editor, to create or modify a unit loadout template
  "EDITOR" - opened in the editor, to modify the inventory of an existing unit
  • owner: Object - Unit who's inventory is being modified (shown in the top of the dialog)
  • display: Display - Inventory dialog display

inventoryLoad, inventoryUnload

Runs when the inventory is opened or closed.

Passed array: [common data]

  • common data: Array - Common data used in all events, described above.


Runs when an item is moved using the inventory interface. Only runs on the computer that initiated the move. Note: this does not run when weapons or magazines are moved via other means, such as the AI picking them up, or picking them up using the action menu. Those can be reliably detected using the LoadOutChanged event handler.

Passed array: [common data, old owner, new owner, cfg type, item ID, stack size]

  • common data: Array - Common data used in all events, described above.
  • old owner: Object - object that used to hold the item. For objects on the ground, objNull is used. For weapons/magazines on the ground, a weaponholder is used.
  • new owner: Object - object that now has the item. As above for the ground.
  • cfg type: String - category of item being moved. One of "CfgVehicles" (object), "CfgWeapons" (weapon), or "CfgMagazines" (magazine).
  • item ID: String or Object - item being moved. For weapons / magazines, the classname is provided (string). For objects, the actual object being moved is provided (object).
  • stack size: Number - number of items being moved (for weapons / magazines).



Runs when an IED is placed or picked up.

Passed array: [picked_up, bomb, unit]

  • picked_up: Boolean - If IED is being picked up or not.
  • bomb: Object - The IED.
  • unit: Object - The person placing or picking up the IED.


This packages demonstrates the different methods of using custom event handlers.