mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
108ff4f644
Regex used: \[(.+?),(.+?),(.+?)\]\s+call\s+E?FUNC\((common,)?(target|object)Event\) [$1,$3,$2] call CBA_fnc_targetEvent E?FUNC\((common,)?(server|global|local)Event\) CBA_fnc_$2Event E?FUNC\((common,)?(add|remove)EventHandler\) CBA_fnc_$2EventHandler
31 lines
749 B
Plaintext
31 lines
749 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 (HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
|
ACE_LOGERROR_1("Duplicate synced event [%1] creation.",_name);
|
|
false
|
|
};
|
|
|
|
private _eventId = [_name, FUNC(_handleSyncedEvent)] call CBA_fnc_addEventHandler;
|
|
private _data = [_handler, [], _ttl, _eventId];
|
|
|
|
HASH_SET(GVAR(syncedEvents),_name,_data);
|