Skip to content

Commit

Permalink
Merge pull request #3924 from voiperr/remove_attached_chemlights
Browse files Browse the repository at this point in the history
On Detach, Delete Used Chemlights
  • Loading branch information
thojkooi authored Jun 16, 2016
2 parents 66450ad + b69aa85 commit fc24147
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions addons/attach/functions/fnc_detach.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params ["_attachToVehicle","_unit"],
TRACE_2("params",_attachToVehicle,_unit);

private ["_attachedList", "_itemDisplayName", "_attachedObject", "_attachedIndex", "_itemName", "_minDistance"];
private ["_attachedList", "_itemDisplayName", "_attachedObject", "_attachedIndex", "_itemName", "_minDistance", "_isChemlight"];

_attachedList = _attachToVehicle getVariable [QGVAR(attached), []];

Expand All @@ -44,13 +44,18 @@ _minDistance = 1000;
// Check if unit has an attached item
if (isNull _attachedObject || {_itemName == ""}) exitWith {ERROR("Could not find attached object")};

// Check if item is a chemlight
_isChemlight = _attachedObject isKindOf "Chemlight_base";

// Exit if can't add the item
if !(_unit canAdd _itemName) exitWith {
if (!(_unit canAdd _itemName) && {!_isChemlight}) exitWith {
[localize LSTRING(Inventory_Full)] call EFUNC(common,displayTextStructured);
};

// Add item to inventory
_unit addItem _itemName;
// Add item to inventory (unless it's a chemlight)
if (!_isChemlight) then {
_unit addItem _itemName;
};

if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then {
// Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle
Expand All @@ -60,6 +65,7 @@ if (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) then
[{deleteVehicle (_this select 0)}, [_attachedObject], 2] call CBA_fnc_waitAndExecute;
} else {
// Delete attached item
detach _attachedObject;
deleteVehicle _attachedObject;
};

Expand Down

0 comments on commit fc24147

Please sign in to comment.