#include "..\script_component.hpp" /* * File: fnc_initVAStore.sqf * Author: IDSolutions * Date: 2025-12-17 * Last Update: 2026-02-13 * Public: No * * Description: * Initializes the Virtual Arsenal store for managing player arsenal unlocks. * Provides methods for syncing, saving, and applying virtual items to BIS Arsenal. * * Arguments: * None * * Return Value: * VA store object [HASHMAP OBJECT] * * Example: * call forge_server_locker_fnc_initVAStore */ #pragma hemtt ignore_variables ["_self"] GVAR(VArsenalModel) = compileFinal createHashMapObject [[ ["#type", "VArsenalModel"], ["defaults", compileFinal { private _vArsenal = createHashMap; _vArsenal set ["backpacks", ["B_AssaultPack_rgr"]]; _vArsenal set ["items", ["FirstAidKit", "G_Combat", "H_Cap_blk_ION", "H_HelmetB", "ItemCompass", "ItemGPS", "ItemMap", "ItemRadio", "ItemWatch", "U_IG_Guerrilla_6_1", "V_TacVest_oli"]]; _vArsenal set ["magazines", ["16Rnd_9x21_Mag", "30Rnd_65x39_caseless_black_mag", "Chemlight_blue", "Chemlight_green", "Chemlight_red", "Chemlight_yellow", "HandGrenade", "SmokeShell", "SmokeShellBlue", "SmokeShellGreen", "SmokeShellOrange", "SmokeShellPurple", "SmokeShellRed", "SmokeShellYellow"]]; _vArsenal set ["weapons", ["arifle_MX_F", "hgun_P07_F"]]; _vArsenal }] ]]; GVAR(VABaseStore) = compileFinal createHashMapFromArray [ ["#base", EGVAR(common,BaseStore)], ["#type", "VABaseStore"], ["#create", compileFinal { GVAR(VARegistry) = createHashMap; ["INFO", "VArsenal Store Initialized!"] call EFUNC(common,log); }], ["init", compileFinal { params [["_uid", "", [""]]]; private _player = [_uid] call EFUNC(common,getPlayer); private _cached = GVAR(VARegistry) getOrDefault [_uid, nil]; if !(isNil { _cached }) exitWith { [CRPC(locker,responseInitVA), [_cached], _player] call CFUNC(targetEvent); _cached }; ["owned:locker:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"]; if !(_isSuccess) exitWith { ["ERROR", format ["Failed to check if virtual arsenal %1 exists! Using fallback virtual arsenal.", _uid]] call EFUNC(common,log); private _fallbackVArsenal = GVAR(VArsenalModel) call ["defaults", []]; GVAR(VARegistry) set [_uid, _fallbackVArsenal]; [CRPC(locker,responseInitVA), [_fallbackVArsenal], _player] call CFUNC(targetEvent); _fallbackVArsenal }; private _finalVArsenal = createHashMap; if (_result == "true") then { _finalVArsenal = _self call ["fetch", ["owned:locker:fetch", _uid]]; ["INFO", format ["Found virtual arsenal for %1", _uid]] call EFUNC(common,log); } else { _finalVArsenal = GVAR(VArsenalModel) call ["defaults", []]; ["owned:locker:create", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"]; if !(_isSuccess) exitWith { ["ERROR", format ["Failed to create virtual arsenal for %1! Using fallback virtual arsenal.", _uid]] call EFUNC(common,log); GVAR(VARegistry) set [_uid, _finalVArsenal]; [CRPC(locker,responseInitVA), [_finalVArsenal], _player] call CFUNC(targetEvent); _finalVArsenal }; ["INFO", format ["Created new virtual arsenal for %1", _uid]] call EFUNC(common,log); }; GVAR(VARegistry) set [_uid, _finalVArsenal]; [CRPC(locker,responseInitVA), [_finalVArsenal], _player] call CFUNC(targetEvent); _finalVArsenal }] ]; GVAR(VAStore) = createHashMapObject [GVAR(VABaseStore)]; GVAR(VAStore)