From a894fc78c3a1d49ed335634f92fddc578922b615 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:33:40 +0200 Subject: [PATCH] Safemode - Fix safemode being broken after respawning (#10260) * Fix safemode being broken when respawning * Update addons/safemode/XEH_postInit.sqf Co-authored-by: PabstMirror * Update XEH_postInit.sqf --------- Co-authored-by: PabstMirror --- addons/safemode/XEH_postInit.sqf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index 79064789d5..fa6649aa9f 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -27,3 +27,19 @@ if (!hasInterface) exitWith {}; // Player HUD !_weaponSafe call FUNC(setSafeModeVisual); }] call CBA_fnc_addPlayerEventHandler; + +// Variables are transferred from corpse to new body and EH above triggers on respawn, which desyncs safeties +// Therefore, clear variables and remove mouse button input blocking upon respawn +[QUOTE(ADDON), "Respawn", { + params ["_unit"]; + + _unit setVariable [QGVAR(safedWeapons), nil]; + + private _ehID = _unit getVariable QGVAR(actionID); + + if (isNil "_ehID") exitWith {}; + + [_unit, "DefaultAction", _ehID] call EFUNC(common,removeActionEventHandler); + + _unit setVariable [QGVAR(actionID), nil]; +}] call EFUNC(common,addPlayerEH);