#include "..\script_component.hpp" /* * File: fnc_initLockerStore.sqf * Author: IDSolutions * Date: 2025-12-17 * Last Update: 2026-02-13 * Public: No * * Description: * Initializes the Locker store for managing player locker items. * Provides methods for syncing, saving, and applying locker items to the player's locker. * * Arguments: * None * * Return Value: * Locker store object [HASHMAP OBJECT] * * Example: * call forge_server_locker_fnc_initLockerStore */ #pragma hemtt ignore_variables ["_self"] GVAR(LockerBaseStore) = compileFinal createHashMapFromArray [ ["#base", EGVAR(common,BaseStore)], ["#type", "LockerBaseStore"], ["#create", compileFinal { GVAR(Registry) = createHashMap; ["INFO", "Locker Store Initialized!"] call EFUNC(common,log); }], ["init", compileFinal { params [["_uid", "", [""]]]; private _player = [_uid] call EFUNC(common,getPlayer); private _cached = GVAR(Registry) getOrDefault [_uid, nil]; if !(isNil { _cached }) exitWith { [CRPC(locker,responseInitLocker), [_cached], _player] call CFUNC(targetEvent); _cached }; ["locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"]; if !(_isSuccess) exitWith { ["ERROR", format ["Failed to check if locker %1 exists! Using fallback locker.", _uid]] call EFUNC(common,log); private _fallbackLocker = createHashMap; GVAR(Registry) set [_uid, _fallbackLocker]; [CRPC(locker,responseInitLocker), [_fallbackLocker], _player] call CFUNC(targetEvent); _fallbackLocker }; private _finalLocker = createHashMap; if (_result == "true") then { _finalLocker = _self call ["fetch", ["locker:get", _uid]]; ["INFO", format ["Found locker for %1", _uid]] call EFUNC(common,log); } else { ["locker:create", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"]; if !(_isSuccess) exitWith { ["ERROR", format ["Failed to create locker for %1! Using fallback locker.", _uid]] call EFUNC(common,log); GVAR(Registry) set [_uid, _finalLocker]; [CRPC(locker,responseInitLocker), [_finalLocker], _player] call CFUNC(targetEvent); _finalLocker }; ["INFO", format ["Created new locker for %1", _uid]] call EFUNC(common,log); }; GVAR(Registry) set [_uid, _finalLocker]; [CRPC(locker,responseInitLocker), [_finalLocker], _player] call CFUNC(targetEvent); _finalLocker }] ]; GVAR(LockerStore) = createHashMapObject [GVAR(LockerBaseStore)]; GVAR(LockerStore)