2015-04-17 17:21:41 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2015-08-26 13:20:11 +00:00
|
|
|
*
|
2015-09-18 07:38:19 +00:00
|
|
|
* Public: Yes
|
2015-04-17 17:21:41 +00:00
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-09-18 07:38:19 +00:00
|
|
|
params ["_name", "_handler", ["_ttl", 0]];
|
2015-04-17 17:21:41 +00:00
|
|
|
|
2015-09-18 07:38:19 +00:00
|
|
|
if (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
2015-08-26 13:20:11 +00:00
|
|
|
ACE_LOGERROR("Duplicate synced event creation.");
|
2015-04-17 17:21:41 +00:00
|
|
|
false
|
|
|
|
};
|
|
|
|
|
2015-09-18 07:38:19 +00:00
|
|
|
private ["_eventId", "_data"];
|
|
|
|
|
2015-04-17 17:21:41 +00:00
|
|
|
_eventId = [_name, FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
|
2015-09-18 07:38:19 +00:00
|
|
|
_data = [_handler, [], _ttl, _eventId];
|
|
|
|
|
2015-08-26 13:20:11 +00:00
|
|
|
HASH_SET(GVAR(syncedEvents),_name,_data);
|