Skip to content

Instantly share code, notes, and snippets.

@JoramD0
Last active April 19, 2022 15:16
Show Gist options
  • Save JoramD0/ab3c08e3d4eec612c95aefb2e3df3534 to your computer and use it in GitHub Desktop.
Save JoramD0/ab3c08e3d4eec612c95aefb2e3df3534 to your computer and use it in GitHub Desktop.
Arma 3 variable storing concept
// These should be defind on initPlayerLocal or something:
GVAR(playerVariables) = createHashMap;
GVAR(newData) = false;
// Would be called like `["earplugs", [player] call ACEFUNC(hearing,hasEarPlugsIn)] call FUNC(this)`
params ["_type", "_data"];
GVAR(playerVariables) set [_type, _data];
GVAR(newData) = true;
private _input = // Data from Athena
{
_x params ["_type", "_data"];
switch (_type) do {
case "earplugs": {
if _data then {
player setVariable ["ACE_hasEarPlugsIn", true, true];
[[true]] call ACEFUNC(hearing,updateVolume);
[] call ACEFUNC(hearing,updateHearingProtection);
};
};
case "insignia": {
[player, _data] call BIS_fnc_setUnitInsignia
};
case "medical": {
[player, _data] call ACEFUNC(medical,deserializeState);
};
}
} forEach _input;
[
GVAR(newData),
{
GVAR(playerVariables) call FUNC(saveToAthena); // Obviously function placeholder
GVAR(newData) = false;
}
] call CBA_fnc_waitUntilAndExecute; // Not sure if possible/how but have this execute max once per second or something? If that is even wanted
// Whenver possible have these execute on EH's, if not possible on interval
["earplugs", [player] call ACEFUNC(hearing,hasEarPlugsIn)] call FUNC(collect);
["insignia", [player] call BIS_fnc_getUnitInsignia] call FUNC(collect);
["medical", [player] call ACEFUNC(medical,serializeState)] call FUNC(collect); // Not sure about performance on this one but it could for example be done on `ace_treatmentSucceded` and `ace_unconscious`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment