ACE3/addons/common/functions/fnc__handleSyncedEvent.sqf

41 lines
977 B
Plaintext
Raw Normal View History

/*
* Author: jaynus
2015-04-18 02:26:27 +00:00
* Handles synced events being received. Server will log them, and server/client will execute them.
*
2015-04-18 02:26:27 +00:00
* Arguments [Client] :
2015-09-18 05:42:10 +00:00
* 0: eventName <STRING>
* 1: arguments <ARRAY>
* 2: ttl <SCALAR>
*
* Return Value:
* Boolean of success <BOOL>
*
2015-09-18 05:42:10 +00:00
* Public: No
*/
#include "script_component.hpp"
2015-09-18 05:42:10 +00:00
params ["_name", "_args", "_ttl"];
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
ACE_LOGERROR("Synced event key not found.");
false
};
2015-09-18 05:42:10 +00:00
private ["_internalData", "_eventCode"];
_internalData = HASH_GET(GVAR(syncedEvents),_name);
2015-09-18 05:42:10 +00:00
if (isServer) then {
// Server needs to internally log it for synchronization
2015-09-18 05:42:10 +00:00
if (_ttl > -1) then {
_internalData = HASH_GET(GVAR(syncedEvents),_name);
2015-09-18 05:42:10 +00:00
private "_eventLog";
_eventLog = _internalData select 1;
_eventLog pushback [ACE_diagTime, _args, _ttl];
};
};
_eventCode = _internalData select 0;
_args call _eventCode;