forge/arma/server/addons/garage/functions/fnc_initGarageStore.sqf

67 lines
1.9 KiB
Plaintext

#include "..\script_component.hpp"
/*
* File: fnc_initGarageStore.sqf
* Author: IDSolutions
* Date: 2025-12-17
* Last Update: 2026-01-10
* Public: No
*
* Description:
* Initializes the Garage store for managing player vehicles.
* Provides methods for syncing, saving, and applying vehicles to the player's garage.
*
* Parameter(s):
* N/A
*
* Returns:
* Something [BOOL]
*
* Example(s):
* [parameter] call forge_x_component_fnc_myFunction
*/
#pragma hemtt ignore_variables ["_self"]
private _typeGarage = compileFinal createHashMapFromArray [
["#base", EGVAR(common,BaseStore)],
["#type", "IGarageBase"],
["init", {
params [["_uid", "", [""]], ["_defaultGarage", createHashMap, [createHashMap]]];
private _finalGarage = createHashMap;
["garage:exists", [_uid]] call EFUNC(extension,extCall) params ["_result", "_isSuccess"];
private _exists = _result == "true";
if !(_exists) then {
_finalGarage = _defaultGarage;
["garage:create", [_uid]] call EFUNC(extension,extCall);
["INFO", format ["Created new garage for %1", _uid], nil, nil] call EFUNC(common,log);
} else {
_finalGarage = _self call ["fetch", ["garage:get", _uid]];
["INFO", format ["Found garage for %1", _uid], nil, nil] call EFUNC(common,log);
};
GVAR(GarageRegistry) set [_uid, _finalGarage];
private _player = [_uid] call EFUNC(common,getPlayer);
[CRPC(garage,responseInitGarage), [_finalGarage], _player] call CFUNC(targetEvent);
_finalGarage
}]
];
GVAR(GarageStore) = createHashMapObject [[
["#base", _typeGarage],
["#type", "IGarageStore"],
["#create", {
GVAR(GarageRegistry) = createHashMap;
["INFO", "Garage Store Initialized!", nil, nil] call EFUNC(common,log);
}]
]];
SETMVAR(FORGE_GarageStore,GVAR(GarageStore));
GVAR(GarageStore)