server/addons/db/functions/fnc_loadGameState.sqf
Jacob Schmidt bec0adcdbf feat: Update build environment and add XEH PREP
This commit includes the following changes:

-   Updates the build environment in the GitHub Actions workflow to use `ubuntu-latest` instead of `ubuntu-22.04`.
-   Adds `playerGroup2Server` to the XEH_PREP.hpp file.
-   Updates the picture path in CfgMods.hpp to include the file extension.
2025-03-28 09:46:08 -05:00

64 lines
2.5 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: forge_server_db_fnc_loadGameState
* Author: J. Schmidt
*
* Description:
* Loads game state from mission namespace and sets appropriate variables
*
* Arguments:
* None
*
* Return Value:
* Success <BOOL>
*/
private _companyState = ["companyStore", "CompanyState", nil] call FUNC(loadFromMission);
if (!isNil "_companyState") then {
companyFunds = _companyState getOrDefault ["funds", 0];
companyRating = _companyState getOrDefault ["rating", 0];
companyGenerals = _companyState getOrDefault ["operations", []];
companyGarageUnlocks = _companyState getOrDefault ["garage_unlocks", []];
};
private _playerUID = getPlayerUID player;
private _playerState = ["playerStore", _playerUID, nil] call FUNC(loadFromMission);
if (!isNil "_playerState") then {
private _armory_unlocks = _playerState getOrDefault ["armory_unlocks", [[],[],[],[]]];
private _garage_unlocks = _playerState getOrDefault ["garage_unlocks", [[],[],[],[],[],[]]];
private _locker = _playerState getOrDefault ["locker", []];
private _garage = _playerState getOrDefault ["garage", []];
private _cash = _playerState getOrDefault ["cash", 0];
private _bank = _playerState getOrDefault ["bank", 0];
private _number = _playerState getOrDefault ["number", "unknown"];
private _email = _playerState getOrDefault ["email", "unknown@spearnet.mil"];
private _paygrade = _playerState getOrDefault ["paygrade", "E1"];
private _holster = _playerState getOrDefault ["holster", true];
EGVAR(arsenal,armory_unlocks) = _armory_unlocks;
EGVAR(arsenal,garage_unlocks) = _garage_unlocks;
SETPVAR(player,FORGE_Locker,_locker);
SETPVAR(player,FORGE_Garage,_garage);
SETPVAR(player,FORGE_Cash,_cash);
SETPVAR(player,FORGE_Bank,_bank);
SETPVAR(player,FORGE_Phone_Number,_number);
SETPVAR(player,FORGE_Email,_email);
SETPVAR(player,FORGE_Paygrade,_paygrade);
SETPVAR(player,FORGE_Holster_Weapon,_holster);
if (isNull objectParent player) then {
player setUnitLoadout (_playerState getOrDefault ["loadout", []]);
if (_playerState getOrDefault ["currentWeapon", ""] != "") then {
player selectWeapon (_playerState get "currentWeapon");
};
player setPosASL (_playerState getOrDefault ["position", getPosASL player]);
player setDir (_playerState getOrDefault ["direction", 0]);
if (_playerState getOrDefault ["stance", ""] != "") then {
[player, _playerState get "stance"] call ace_common_fnc_setStance;
};
};
};
true