#include "script_component.hpp"
ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

// Handle responses from server requests
["forge_db_response", {
    params ["_targetUID", "_requestType", "_result", "_requestID"];

    if (_targetUID isEqualTo getPlayerUID player) then {
        if (!isNil QGVAR(pendingCallbacks)) then {
            private _callback = GVAR(pendingCallbacks) getOrDefault [_requestID, {}];
            GVAR(pendingCallbacks) deleteAt _requestID;

            [_result, _requestType] call _callback;
        };
    };
}] call CBA_fnc_addEventHandler;

ADDON = true;