2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-18 21:51:30 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, Jonpas
|
|
|
|
* Adds a cargo item to the vehicle.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2023-11-17 23:07:28 +00:00
|
|
|
* 0: Item to be loaded <STRING> or <OBJECT>
|
|
|
|
* 1: Holder object (vehicle) <OBJECT>
|
2015-08-18 21:51:30 +00:00
|
|
|
* 2: Amount <NUMBER> (default: 1)
|
2024-05-22 06:32:46 +00:00
|
|
|
* 3: Ignore interaction distance and stability checks <BOOL> (default: false)
|
2015-08-18 21:51:30 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2024-05-22 06:32:46 +00:00
|
|
|
* Objects loaded <NUMBER>
|
2015-08-18 21:51:30 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2023-11-17 23:07:28 +00:00
|
|
|
* ["ACE_Wheel", cursorObject] call ace_cargo_fnc_addCargoItem
|
2015-08-18 21:51:30 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2024-05-22 06:32:46 +00:00
|
|
|
params ["_item", "_vehicle", ["_amount", 1], ["_ignoreInteraction", false]];
|
|
|
|
TRACE_4("params",_item,_vehicle,_amount,_ignoreInteraction);
|
|
|
|
|
|
|
|
private _loaded = 0;
|
2015-08-18 21:51:30 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Get config sensitive case name
|
|
|
|
if (_item isEqualType "") then {
|
|
|
|
_item = _item call EFUNC(common,getConfigName);
|
|
|
|
|
|
|
|
for "_i" from 1 to _amount do {
|
2024-05-22 06:32:46 +00:00
|
|
|
if !([_item, _vehicle, _ignoreInteraction] call FUNC(loadItem)) exitWith {};
|
|
|
|
|
|
|
|
_loaded = _loaded + 1;
|
2023-11-17 23:07:28 +00:00
|
|
|
};
|
|
|
|
} else {
|
2024-05-22 06:32:46 +00:00
|
|
|
_loaded = parseNumber ([_item, _vehicle, _ignoreInteraction] call FUNC(loadItem));
|
2023-11-17 23:07:28 +00:00
|
|
|
|
|
|
|
_item = typeOf _item;
|
2015-08-18 21:51:30 +00:00
|
|
|
};
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2024-05-22 06:32:46 +00:00
|
|
|
TRACE_1("loaded",_loaded);
|
|
|
|
|
2015-09-27 16:19:40 +00:00
|
|
|
// Invoke listenable event
|
2024-06-22 15:18:28 +00:00
|
|
|
if (_loaded > 0) then {
|
|
|
|
["ace_cargoAdded", [_item, _vehicle, _loaded]] call CBA_fnc_globalEvent;
|
|
|
|
};
|
2024-05-22 06:32:46 +00:00
|
|
|
|
|
|
|
_loaded // return
|