Skip to content

Commit

Permalink
Fix(explosives): Selecting a cellphone as an IEDs trigger would throw…
Browse files Browse the repository at this point in the history
… an error (#5963)

* move code var to outer scope

* run closeDialog only for the player
  • Loading branch information
bux authored and PabstMirror committed Dec 26, 2017
1 parent fe531d7 commit 54320eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion addons/explosives/functions/fnc_addCellphoneIED.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,30 @@ private _config = (_this select 3) select (count (_this select 3) - 1);
private _requiredItems = getArray(_config >> "requires");
private _hasRequired = true;
private _detonators = [_unit] call FUNC(getDetonators);

{
if !(_x in _detonators) exitWith{
_hasRequired = false;
};
} count _requiredItems;

private _code = "";
private _codeSet = false;

while {!_codeSet} do {
private _code = str(round (random 9999));
_code = str(round (random 9999));
_count = 4 - count (toArray _code);
while {_count > 0} do {
_code = "0" + _code;
_count = _count - 1;
};
_codeSet = (count ([_code] call FUNC(getSpeedDialExplosive))) == 0;
};

if (isNil QGVAR(CellphoneIEDs)) then {
GVAR(CellphoneIEDs) = [];
};

private _count = GVAR(CellphoneIEDs) pushBack [_explosive,_code,GetNumber(ConfigFile >> "CfgMagazines" >> _magazineClass >> "ACE_Triggers" >> "Cellphone" >> "FuseTime")];
_count = _count + 1;
publicVariable QGVAR(CellphoneIEDs);
Expand Down
5 changes: 5 additions & 0 deletions addons/explosives/functions/fnc_onIncapacitated.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
params ["_unit"];
TRACE_1("params",_unit);

if (_unit == ace_player) then {
// close cellphone if open
closeDialog 0;
};

// Exit if no item:
if (({_x == "ACE_DeadManSwitch"} count (items _unit)) == 0) exitWith {};

Expand Down

0 comments on commit 54320eb

Please sign in to comment.