mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
e2ac18a05d
* advanced_ballistics * advanced_fatigue * advanced_throwing * ai * aircraft * arsenal * atragmx * attach * backpacks * ballistics * captives * cargo * chemlights * common * concertina_wire * cookoff * dagr * disarming * disposable * dogtags * dragging * explosives * fastroping * fcs * finger * frag * gestures * gforces * goggles * grenades * gunbag * hearing * hitreactions * huntir * interact_menu * interaction * inventory * kestrel4500 * laser * laserpointer * logistics_uavbattery * logistics_wirecutter * magazinerepack * map * map_gestures * maptools * markers * medical * medical_ai * medical_blood * medical_menu * microdagr * minedetector * missileguidance * missionmodules * mk6mortar * modules * movement * nametags * nightvision * nlaw * optics * optionsmenu * overheating * overpressure * parachute * pylons * quickmount * rangecard * rearm * recoil * refuel * reload * reloadlaunchers * repair * respawn * safemode * sandbag * scopes * slideshow * spectator * spottingscope * switchunits * tacticalladder * tagging * trenches * tripod * ui * vector * vehiclelock * vehicles * viewdistance * weaponselect * weather * winddeflection * yardage450 * zeus * arsenal defines.hpp * optionals * DEBUG_MODE_FULL 1 * DEBUG_MODE_FULL 2 * Manual fixes * Add SQF Validator check for #include after block comment * explosives fnc_openTimerUI * fix uniqueItems
71 lines
1.8 KiB
Plaintext
71 lines
1.8 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: 654wak654
|
|
* Removes a cargo item from the vehicle.
|
|
*
|
|
* Arguments:
|
|
* 0: Item <STRING> or <OBJECT>
|
|
* 1: Vehicle <OBJECT>
|
|
* 2: Amount <NUMBER> (default: 1)
|
|
*
|
|
* Return Value:
|
|
* Number of items removed <NUMBER>
|
|
*
|
|
* Example:
|
|
* ["ACE_Wheel", vehicle, 2] call ace_cargo_fnc_removeCargoItem
|
|
* [crate_7, truck] call ace_cargo_fnc_removeCargoItem
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params ["_item", "_vehicle", ["_amount", 1]];
|
|
TRACE_3("params",_item,_vehicle,_amount);
|
|
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
|
|
private _addedSpace = 0;
|
|
private _itemClass = _item;
|
|
private _itemsRemoved = 0;
|
|
|
|
private _continue = if (_item isEqualType objNull) then {
|
|
if !(_item in _loaded) exitWith {false};
|
|
_addedSpace = [_item] call FUNC(getSizeItem);
|
|
_loaded deleteAt (_loaded find _item);
|
|
_itemClass = typeOf _item;
|
|
deleteVehicle _item;
|
|
_itemsRemoved = 1;
|
|
true
|
|
} else {
|
|
{
|
|
if (_itemsRemoved == _amount) exitWith {};
|
|
|
|
if (
|
|
(_x isEqualType "" && {_x == _item}) || // Check for classname, case-insensitive
|
|
{_x isEqualType objNull && {typeOf _x isEqualTo _item}}
|
|
) then {
|
|
INC(_itemsRemoved);
|
|
ADD(_addedSpace,[_x] call FUNC(getSizeItem));
|
|
|
|
if (_x isEqualType objNull) then {
|
|
deleteVehicle _x;
|
|
};
|
|
_loaded set [_forEachIndex, nil];
|
|
};
|
|
} forEach _loaded;
|
|
|
|
FILTER(_loaded,_x != nil);
|
|
true
|
|
};
|
|
|
|
if (!_continue) exitWith {0};
|
|
|
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
|
|
|
private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
|
_vehicle setVariable [QGVAR(space), _space + _addedSpace, true];
|
|
|
|
// Invoke listenable event
|
|
["ace_cargoRemoved", [_itemClass, _vehicle, _amount, _itemsRemoved]] call CBA_fnc_globalEvent;
|
|
|
|
_itemsRemoved
|