ACE3/addons/common/functions/fnc__handleSyncedEvent.sqf
jonpas 742626ff1a
General - Relative script_component.hpp includes (#9378)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-12 20:58:10 +02:00

38 lines
860 B
Plaintext

#include "..\script_component.hpp"
/*
* 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>
*
* Example:
* [bob] call ace_common_fnc__handleSyncedEvent
*
* Public: No
*/
params ["_name", "_args", "_ttl"];
if !(_name in GVAR(syncedEvents)) exitWith {
ERROR_1("Synced event key [%1] not found (_handleSyncedEvent).", _name);
false
};
private _internalData = GVAR(syncedEvents) get _name;
_internalData params ["_eventCode", "_eventLog"];
if (isServer) then {
// Server needs to internally log it for synchronization
if (_ttl > -1) then {
_eventLog pushBack [diag_tickTime, _args, _ttl];
};
};
_args call _eventCode;