server/addons/db/functions/fnc_saveGameState.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

78 lines
2.6 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Function: forge_server_db_fnc_saveGameState
* Author: J. Schmidt
*
* Description:
* Collects and saves the current game state to mission namespace
*
* Arguments:
* None
*
* Return Value:
* Success <BOOL>
*/
if (isNil "companyFunds") then { companyFunds = 0 };
if (isNil "companyRating") then { companyRating = 0 };
if (isNil "companyGenerals") then { companyGenerals = [] };
if (isNil "companyGarageUnlocks") then { companyGarageUnlocks = [] };
if (isNil EGVAR(arsenal,armory_unlocks)) then { EGVAR(arsenal,armory_unlocks) = [[],[],[],[]] };
if (isNil EGVAR(arsenal,garage_unlocks)) then { EGVAR(arsenal,garage_unlocks) = [[],[],[],[],[],[]] };
private _companyState = createHashMapFromArray [
["key", "CompanyState"],
["funds", companyFunds],
["rating", companyRating],
["operations", companyGenerals],
["garage_unlocks", companyGarageUnlocks]
];
["companyStore", _companyState, "CompanyState"] call FUNC(saveToMission);
{
if (alive _x) then {
private _playerState = createHashMapFromArray [
["key", getPlayerUID _x],
["armory_unlocks", EGVAR(arsenal,armory_unlocks)],
["garage_unlocks", EGVAR(arsenal,garage_unlocks)],
["locker", GETVAR(_x,FORGE_Locker,[])],
["garage", GETVAR(_x,FORGE_Garage,[])],
["cash", GETVAR(_x,FORGE_Cash,0)],
["bank", GETVAR(_x,FORGE_Bank,0)],
["number", GETVAR(_x,FORGE_Phone_Number,"unknown")],
["email", GETVAR(_x,FORGE_Email,"unknown@spearnet.mil")],
["paygrade", GETVAR(_x,FORGE_Paygrade,"E1")],
["reputation", rating _x],
["loadout", getUnitLoadout _x],
["holster", GETVAR(_x,FORGE_Holster_Weapon,true)],
["position", getPosASLVisual _x],
["direction", getDirVisual _x]
];
if (isNull objectParent _x) then {
_playerState set ["currentWeapon", currentMuzzle _x];
_playerState set ["stance", stance _x];
};
["playerStore", _playerState, getPlayerUID _x] call FUNC(saveToMission);
};
} forEach playableUnits;
private _vehicles = nearestObjects [player, ["LandVehicle"], 50];
{
if (alive _x) then {
private _vehicleState = createHashMapFromArray [
["key", netId _x],
["class", typeOf _x],
["position", getPosATL _x],
["direction", getDir _x],
["health", damage _x]
];
["vehicleStore", _vehicleState, netId _x] call FUNC(saveToMission);
};
} forEach _vehicles;
true