ACE3/addons/common/functions/fnc_addSyncedEventHandler.sqf

31 lines
747 B
Plaintext
Raw Normal View History

/*
* Author: jaynus
* Register an event handler for an ACE synced event
*
2015-09-18 07:38:19 +00:00
* Arguments:
* 0: Name <STRING>
* 1: Handler <CODE>
* 2: TTL (optional: 0) <NUMBER, CODE>
*
* Return Value:
* Boolean of success <BOOL>
*
2016-04-25 20:48:24 +00:00
* Example:
* ["myEvent", {_this call x}, 0] call ace_common_fnc_addSyncedEventHandler
*
2015-09-18 07:38:19 +00:00
* Public: Yes
*/
#include "script_component.hpp"
2015-09-18 07:38:19 +00:00
params ["_name", "_handler", ["_ttl", 0]];
2015-09-18 07:38:19 +00:00
if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
2016-04-25 20:48:24 +00:00
ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name);
false
};
private _eventId = [_name, FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
private _data = [_handler, [], _ttl, _eventId];
2015-09-18 07:38:19 +00:00
HASH_SET(GVAR(syncedEvents),_name,_data);