ACE3/addons/common/functions/fnc_addSyncedEventHandler.sqf
commy2 05d30c5573 convert log macros to cba versions (#4282)
* convert log macros to cba versions

* Add changes to AB

* remove obsolete macro
2016-10-02 12:55:31 +02:00

31 lines
741 B
Plaintext

/*
* 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
*/
#include "script_component.hpp"
params ["_name", "_handler", ["_ttl", 0]];
if ([GVAR(syncedEvents), _name] call CBA_fnc_hashHasKey) exitWith {
ERROR_1("Duplicate synced event [%1] creation.",_name);
false
};
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
private _data = [_handler, [], _ttl, _eventId];
[GVAR(syncedEvents), _name, _data] call CBA_fnc_hashSet;