ACE3/addons/common/functions/fnc__handleSyncedEvent.sqf

38 lines
913 B
Plaintext
Raw Normal View History

2016-05-30 16:37:03 +00:00
/*
* Author: jaynus
* Handles synced events being received. Server will log them, and server/client will execute them.
*
* Arguments [Client] :
* 0: eventName <STRING>
* 1: arguments <ARRAY>
* 2: ttl <NUMBER>
*
* Return Value:
* Boolean of success <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
params ["_name", "_args", "_ttl"];
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
ACE_LOGERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name);
false
};
private _internalData = HASH_GET(GVAR(syncedEvents),_name);
if (isServer) then {
// Server needs to internally log it for synchronization
if (_ttl > -1) then {
_internalData = HASH_GET(GVAR(syncedEvents),_name);
_internalData params ["", "_eventLog"];
_eventLog pushBack [ACE_diagTime, _args, _ttl];
};
};
_internalData params ["_eventCode"];
_args call _eventCode;