ACE3/documentation/development/ace3-events-system.md
2015-05-04 13:43:33 +02:00

7.0 KiB

layout title group parent order
wiki ACE3 Events System development wiki 3

1. Event Handlers

Event handlers in ACE3 are implemented through our event system. They should be used to trigger or allow triggering of specific functionality.

The commands are listed below.

  • [eventName, eventCodeBlock] call ace_common_fnc_addEventHandler
    adds an event handler with the event name and returns the event handler id.
  • [eventName, args] call ace_common_fnc_globalEvent
    calls an event with the listed args on all machines, the local machine, and the server.
  • [eventName, args] call ace_common_fnc_serverEvent
    calls an event just on the server computer (dedicated or self-hosted).
  • [eventName, targetObject(s), args] call ace_common_fnc_targetEvent
    calls an event just on the targeted object or list of objects.
  • [eventName, args] call ace_common_fnc_localEvent
    calls an event just on the local machine, useful for inter-module events.

Events can be removed or cleared with the following commands.

  • [eventName, eventHandlerId] call ace_common_fnc_removeEventHandler
    will remove a specific event handler of the event name, using the ID returned from ace_common_fnc_addEventHandler.
  • [eventName] call ace_common_fnc_removeAllEventHandlers
    will remove all event handlers for that type of event.

1.1 Synchronized Events

  • [eventName, eventCodeBlock, ttlNumberOrCodeBlock] call ace_common_fnc_addSyncedEventHandler
    adds a globally synchronized event handler which will expire events after the provided TTL, or the code returns true.
  • [eventName] call ace_common_fnc_removeSyncedEventHandler
    will remove a specific event handler of the event name, using the ID returned from ace_common_fnc_addSyncedEventHandler.
    • [eventName, args, ttlNumberOrCodeBlock] call ace_common_fnc_syncedEvent
      calls a global synchronized event, which will also be run on JIP players unless it has expired; event will expire after the provided TTL, or the code returns true.

1.2 Pattern:

// tapper machine
["tapShoulder", [_target], [otherArguments]] call EFUNC(common,targetEvent);

// target machine XEH_preInit.sqf
PREP(onTapShoulder);
["tapShoulder", FUNC(onTapShoulder) ] call EFUNC(common,addEventHandler);

1.3 Listenable Event List:

Event Key Description Source(s) Passed Parameter(s) (_this) Locality
"playerChanged" `player` changed (zeus/respawn) common [_newPlayer, _oldPlayer] local
"PlayerJIP" Player was a JIP player, and `player` object is now created. common [_player] local
"playerInventoryChanged" Inventory changed common getAllGear-Array local
"playerVisionModeChanged" Vision mode changed (e.g. NVG on) common [_unit, _newVisionMode] local
"inventoryDisplayChanged" Inventory display opened/closed common [_unit, _isOpen] local
"zeusDisplayChanged" Zeus display opened/closed common [_unit, _isOpen] local
"cameraViewChanged" Camera view changed common [_unit, _newCameraView] local
"playerVehicleChanged" Player vehicle changed common [_unit, _newVehicle] local
"playerTurretChanged" Player turret changed common [_unit, _newTurretIndexArray] local
"infoDisplayChanged" On info box change (e.g. entering and leaving a vehicle) common [_display, _type] local
"inventoryDisplayLoaded" On opening the inventory display common [_display] local
"mapDisplayLoaded" On loading the map (briefing and mission start) common [_display, _mapType] local
"interactionMenuOpened" Interaction Menu Opened interaction local
"killedByFriendly" On TK/Civilian Killed respawn local
"drawing_requestMarkers" Request Drawing Markers map target
"drawing_sendbackMarkers" Send Drawing Markers map target
"drawing_addLineMarker" Line Drawn map global
"drawing_removeLineMarker" Line Deleted map global
"flashbangExplosion" Flashbang Goes Bang grenades target

1.4 Callable Event List:

Event Key Description Parameters Owner Locality
"ace_fcs_forceChange" force FCS updates fcs fcs local