99 lines
3.3 KiB
Plaintext
99 lines
3.3 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* File: fnc_initVGStore.sqf
|
|
* Author: IDSolutions
|
|
* Date: 2025-12-17
|
|
* Last Update: 2026-02-13
|
|
* Public: No
|
|
*
|
|
* Description:
|
|
* Initializes the Virtual Garage store for managing player vehicle unlocks.
|
|
* Provides methods for syncing, saving, and applying virtual vehicles to BIS Garage.
|
|
*
|
|
* Arguments:
|
|
* None
|
|
*
|
|
* Return Value:
|
|
* VG store object [HASHMAP OBJECT]
|
|
*
|
|
* Example:
|
|
* call forge_server_garage_fnc_initVGStore
|
|
*/
|
|
|
|
#pragma hemtt ignore_variables ["_self"]
|
|
GVAR(VGarageModel) = compileFinal createHashMapObject [[
|
|
["#type", "VGarageModel"],
|
|
["defaults", compileFinal {
|
|
private _vGarage = createHashMap;
|
|
|
|
_vGarage set ["armor", []];
|
|
_vGarage set ["cars", ["B_Quadbike_01_F"]];
|
|
_vGarage set ["helis", []];
|
|
_vGarage set ["naval", []];
|
|
_vGarage set ["other", []];
|
|
_vGarage set ["planes", []];
|
|
|
|
_vGarage
|
|
}]
|
|
]];
|
|
|
|
GVAR(VGBaseStore) = compileFinal createHashMapFromArray [
|
|
["#base", EGVAR(common,BaseStore)],
|
|
["#type", "VGBaseStore"],
|
|
["#create", compileFinal {
|
|
GVAR(VGRegistry) = createHashMap;
|
|
["INFO", "VGarage Store Initialized!"] call EFUNC(common,log);
|
|
}],
|
|
["init", compileFinal {
|
|
params [["_uid", "", [""]]];
|
|
|
|
private _player = [_uid] call EFUNC(common,getPlayer);
|
|
private _cached = GVAR(VGRegistry) getOrDefault [_uid, nil];
|
|
if !(isNil { _cached }) exitWith {
|
|
[CRPC(garage,responseInitVG), [_cached], _player] call CFUNC(targetEvent);
|
|
_cached
|
|
};
|
|
|
|
["owned:garage:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
|
|
if !(_isSuccess) exitWith {
|
|
["ERROR", format ["Failed to check if virtual garage %1 exists! Using fallback virtual garage.", _uid]] call EFUNC(common,log);
|
|
|
|
private _fallbackVGarage = GVAR(VGarageModel) call ["defaults", []];
|
|
GVAR(VGRegistry) set [_uid, _fallbackVGarage];
|
|
[CRPC(garage,responseInitVG), [_fallbackVGarage], _player] call CFUNC(targetEvent);
|
|
|
|
_fallbackVGarage
|
|
};
|
|
|
|
private _finalVGarage = createHashMap;
|
|
|
|
if (_result == "true") then {
|
|
_finalVGarage = _self call ["fetch", ["owned:garage:fetch", _uid]];
|
|
["INFO", format ["Found virtual garage for %1", _uid]] call EFUNC(common,log);
|
|
} else {
|
|
_finalVGarage = GVAR(VGarageModel) call ["defaults", []];
|
|
|
|
["owned:garage:create", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
|
|
if !(_isSuccess) exitWith {
|
|
["ERROR", format ["Failed to create virtual garage for %1! Using fallback virtual garage.", _uid]] call EFUNC(common,log);
|
|
|
|
GVAR(VGRegistry) set [_uid, _finalVGarage];
|
|
[CRPC(garage,responseInitVG), [_finalVGarage], _player] call CFUNC(targetEvent);
|
|
|
|
_finalVGarage
|
|
};
|
|
|
|
["INFO", format ["Created new virtual garage for %1", _uid]] call EFUNC(common,log);
|
|
};
|
|
|
|
GVAR(VGRegistry) set [_uid, _finalVGarage];
|
|
[CRPC(garage,responseInitVG), [_finalVGarage], _player] call CFUNC(targetEvent);
|
|
|
|
_finalVGarage
|
|
}]
|
|
];
|
|
|
|
GVAR(VGarageStore) = createHashMapObject [GVAR(VGBaseStore)];
|
|
GVAR(VGarageStore)
|