#include "..\script_component.hpp" /* * File: fnc_initLockerStore.sqf * Author: IDSolutions * Date: 2025-12-17 * Last Update: 2026-01-03 * 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. * * Parameter(s): * N/A * * Returns: * vArsenal class object [HASHMAP OBJECT] * * Example(s): * [parameter] call forge_client_locker_fnc_initVAStore; */ #pragma hemtt ignore_variables ["_self"] GVAR(LockerStore) = createHashMapObject [[ ["#base", EGVAR(common,BaseStore)], ["#type", "ILockerStore"], ["#create", { GVAR(LockerRegistry) = createHashMap; _self set ["_registry", GVAR(LockerRegistry)]; _self set ["_extCallPrefix", "locker"]; _self set ["_readMethod", "get"]; _self set ["_storeName", "Locker"]; _self set ["_syncEventName", CRPC(locker,responseSyncLocker)]; ["INFO", "Locker Store Initialized!", nil, nil] call EFUNC(common,log); }], ["init", { params [["_uid", "", [""]], ["_defaultLocker", createHashMap, [createHashMap]]]; private _finalLocker = createHashMap; ["locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"]; private _exists = _result == "true"; if !(_exists) then { _finalLocker = _defaultLocker; ["locker:create", [_uid]] call EFUNC(extension,extCall); ["INFO", format ["Created new locker for %1", _uid], nil, nil] call EFUNC(common,log); } else { _finalLocker = _self call ["fetch", [_uid]]; ["INFO", format ["Found locker for %1", _uid], nil, nil] call EFUNC(common,log); }; GVAR(LockerRegistry) set [_uid, _finalLocker]; private _player = [_uid] call EFUNC(common,getPlayer); [CRPC(locker,responseInitLocker), [_finalLocker], _player] call CFUNC(targetEvent); _finalLocker }], ["set", { params [["_uid", "", [""]], ["_field", "", [""]], ["_value", nil], ["_sync", false, [false]]]; private _existingData = GVAR(LockerRegistry) get _uid; private _finalData = +_existingData; private _hashMap = createHashMap; _finalData set [_field, _value]; _hashMap set [_field, _value]; GVAR(LockerRegistry) set [_uid, _finalData]; if (_sync) then { private _json = _self call ["toJSON", [_finalData]]; ["locker:update", [_uid, _json]] call EFUNC(extension,extCall); }; private _player = [_uid] call EFUNC(common,getPlayer); [CRPC(locker,responseSyncLocker), [_hashMap], _player] call CFUNC(targetEvent); _hashMap }], ["mset", { params [["_uid", "", [""]], ["_fieldValuePairs", createHashMap, [createHashMap]], ["_sync", false, [false]]]; private _existingData = GVAR(LockerRegistry) get _uid; private _finalData = +_existingData; private _hashMap = createHashMap; { _finalData set [_x, _y]; } forEach _fieldValuePairs; { _hashMap set [_x, _y]; } forEach _fieldValuePairs; GVAR(LockerRegistry) set [_uid, _finalData]; if (_sync) then { private _json = _self call ["toJSON", [_finalData]]; ["locker:update", [_uid, _json]] call EFUNC(extension,extCall); }; private _player = [_uid] call EFUNC(common,getPlayer); [CRPC(locker,responseSyncLocker), [_hashMap], _player] call CFUNC(targetEvent); _hashMap }] ]]; SETMVAR(FORGE_LockerStore,GVAR(LockerStore)); GVAR(LockerStore)