2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-05-30 16:37:03 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus
|
|
|
|
* Register an event handler for an ACE synced event
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Name <STRING>
|
|
|
|
* 1: Handler <CODE>
|
|
|
|
* 2: TTL (optional: 0) <NUMBER, CODE>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Boolean of success <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* ["myEvent", {_this call x}, 0] call ace_common_fnc_addSyncedEventHandler
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_name", "_handler", ["_ttl", 0]];
|
|
|
|
|
2016-07-30 10:35:10 +00:00
|
|
|
if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
ERROR_1("Duplicate synced event [%1] creation.",_name);
|
2016-05-30 16:37:03 +00:00
|
|
|
false
|
|
|
|
};
|
|
|
|
|
2016-06-09 12:24:45 +00:00
|
|
|
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
|
2016-05-30 16:37:03 +00:00
|
|
|
private _data = [_handler, [], _ttl, _eventId];
|
|
|
|
|
2016-07-30 10:28:06 +00:00
|
|
|
[GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet;
|