Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(explosives): Selecting a cellphone as an IEDs trigger would throw an error #5963

Merged
merged 2 commits into from
Dec 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 {
Copy link
Member

Choose a reason for hiding this comment

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

Alternative:

private _code = "";
while {true} do {
    _code = [round(random 9999),4] call EFUNC(common,numberToDigitsString);
    if (([_code] call FUNC(getSpeedDialExplosive)) isEqualTo []) exitWith {};
};

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
3 changes: 3 additions & 0 deletions addons/explosives/functions/fnc_onIncapacitated.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
params ["_unit"];
TRACE_1("params",_unit);

// close cellphone if open
closeDialog 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

runs on all local units
if (_unit == ace_player) then {

Copy link
Member Author

@bux bux Dec 23, 2017

Choose a reason for hiding this comment

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

done, thx


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

Expand Down