Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ PREP(swayLoop);
PREP(switchAttachmentMode);
PREP(switchPersistentLaser);
PREP(switchToGroupSide);
PREP(temporaryBlockFire);
PREP(throttledPublicVariable);
PREP(toBin);
PREP(toBitmask);
Expand Down
34 changes: 34 additions & 0 deletions addons/common/functions/fnc_temporaryBlockFire.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Temporarily blocks firing of a weapon for player for a specified duration.
*
* Arguments:
* 0: Duration (seconds) <NUMBER> (default: 1)
*
* Return Value:
* None
*
* Example:
* [1] call ace_common_fnc_temporaryBlockFire
*
* Public: Yes
*/

params [["_duration", 1, [0]]];

if (!alive ace_player) exitWith {};
if (!isNil QGVAR(temporaryBlockFireEH)) exitWith {}; // if in-progress temporary block already exists, don't create another one
Comment on lines +20 to +21
Copy link
Copy Markdown
Contributor

@DartRuffian DartRuffian Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this can be simplified but don't have brain power rn

Suggested change
if (!alive ace_player) exitWith {};
if (!isNil QGVAR(temporaryBlockFireEH)) exitWith {}; // if in-progress temporary block already exists, don't create another one
// If in-progress temporary block already exists, don't create another one
if (!alive ace_player || !isNil QGVAR(temporaryBlockFireEH)) exitWith {};


private _firedEH = [ACE_player, "DefaultAction", {true}, {true}] call FUNC(addActionEventHandler);
GVAR(temporaryBlockFireEH) = [ace_player, _firedEH];
TRACE_2("Blocking fire",ace_player,_firedEH);

[{
GVAR(temporaryBlockFireEH) params ["_player", "_firedEH"];
TRACE_2("Unblocking fire",_player,_firedEH);
if (isNull _player) exitWith {};
[_player, "DefaultAction", _firedEH] call FUNC(removeActionEventHandler);
GVAR(temporaryBlockFireEH) = nil;
}, [], _duration] call CBA_fnc_waitAndExecute;

2 changes: 2 additions & 0 deletions addons/medical_gui/functions/fnc_menuPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if !(

[[ELSTRING(medical,DistanceToFar), GVAR(target) call EFUNC(common,getName)], 2] call EFUNC(common,displayTextStructured);
};

[0.5] call EFUNC(common,temporaryBlockFire); // prevent firing from sudden menu closure
};

// Get the Medical Menu display
Expand Down
Loading