layout, title, description, group, order, parent, mod
layout
title
description
group
order
parent
mod
wiki
Events Framework
Explains how to use CBA event handlers with ACE3 events used to trigger or allow triggering of specific functionality and lists all documented events.
framework
5
wiki
ace
1. Event Handlers
Event handlers in ACE3 are implemented through CBA's Event System. They should be used to trigger or allow triggering of specific functionality.
2. Events List
ACE3 uses many events internally, this is not a complete list; but it should list most publicly usable events.
2.1 Fired Event Handlers (ace_common)
Different events for what type of unit has fired.
E.G.: If you only need to do action when player's weapon fires, this will be faster than adding an XEH for everything.
The vehicle events will also have the following local variables available _gunner (OBJECT), _turret (ARRAY).
Called before a local unit is fully healed, mods can listen and apply their own healing logic
2.15 Medical Status (ace_medical_status)
Event Key
Parameters
Locality
Type
Description
ace_medical_status_getBloodLoss
[_unit, _bloodLoss]
Local
Listen
Called when blood loss is calculated for a unit, mods can listen and modify the blood loss value by modifying the array
2.16 Interaction (ace_interaction)
Event Key
Parameters
Locality
Type
Description
ace_interaction_doorOpeningStarted
[_house, _door, _animations]
Local
Listen
Called when local unit starts interacting with doors
ace_interaction_doorOpeningStopped
[_house, _door, _animations]
Local
Listen
Called when local unit stops interacting with doors
2.17 Headless (ace_headless)
Event Key
Parameters
Locality
Type
Description
ace_headless_groupTransferPre
[_group, _HC (OBJECT), _previousOwner, _idHC]
Target
Listen
Called just before a group is transferred from any machine to a HC. Called where group currently is local and on the HC, where group is going to be local.
Called just after a group is transferred from a machine to a HC. Called where group was local and on the HC, where group is now local. _transferredSuccessfully is passed so mods can actually check if the locality was properly transferred, as ownership transfer is not guaranteed.
2.18 HuntIR (ace_huntir)
Event Key
Parameters
Locality
Type
Description
ace_huntir_monitorOpened
[_unit]
Local
Listen
Called when the monitor is opened
ace_huntir_monitorClosed
[_unit]
Local
Listen
Called when the monitor is closed (may be fired multiple times when the monitor is closed by ACE and not the user)
CBA_fnc_addEventHandler - Adds an event handler with the event name and returns the event handler ID.
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Code block
Code
Required
R
Event ID
Number
Return value
3.1.2 Remove Event
CBA_fnc_removeEventHandler - Removes a specific event handler of the given event name, using the ID returned from CBA_fnc_addEventHandler.
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Event ID
Number
Required
R
None
None
Return value
3.2 Calling Events
3.2.1 Local Event
CBA_fnc_localEvent - Calls an event only on the local machine, useful for inter-module events.
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Arguments
Any
Required
R
None
None
Return value
3.2.2 Target Event
CBA_fnc_targetEvent - Calls an event only on the target machine or list of target machines.
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Arguments
Any
Required
2
Target(s)
Object OR Number OR Array
Required
R
None
None
Return value
3.2.3 Server Event
CBA_fnc_serverEvent - Calls an event only on the server machine (dedicated or self-hosted).
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Arguments
Any
Required
R
None
None
Return value
3.2.4 Global Event
CBA_fnc_globalEvent - Calls an event on all machines - the local machine, and the server machine.
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Arguments
Any
Required
R
None
None
Return value
3.3 Synchronized Events
3.3.1 Add Synchronized Event
Adds a globally synchronized event handler which will expire events after the provided time-to-live, or the code returns true.
ace_common_fnc_addSyncedEventHandler
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Code block
Code
Required
2
Time to live
Number OR Code
Optional (default: 0)
R
Event ID
Number
Return value
3.3.2 Remove Synchronized Event
Removes a specific event handler of the given event name, using the ID returned from ace_common_fnc_addSyncedEventHandler.
ace_common_fnc_removeSyncedEventHandler
Arguments
Type
Optional (default value)
0
Event name
String
Required
R
None
None
Return value
3.3.3 Call Synchronized Event
Calls a globally synchronized event, which will also be run on JIP players unless it has expired. Event will expire after the provided time-to-live, or the code returns true.
ace_common_fnc_syncedEvent
Arguments
Type
Optional (default value)
0
Event name
String
Required
1
Arguments
Any
Required
2
Time to live for this call
Number OR Code
Optional (default: 0)
R
Event ID
Number
Return value
3.4 Example
// Event handler added on a target machine
["ace_interact_tapShoulder", ace_example_fnc_onTapShoulder] call CBA_fnc_addEventHandler;
// Event called on another machine (tapping above target machine)
["ace_interact_tapShoulder", [arguments], [target]] call CBA_fnc_targetEvent;