2015-08-18 21:51:30 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, Jonpas
|
|
|
|
* Adds a cargo item to the vehicle.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Item Classname <STRING>
|
|
|
|
* 1: Vehicle <OBJECT>
|
|
|
|
* 2: Amount <NUMBER> (default: 1)
|
2015-09-26 22:31:23 +00:00
|
|
|
* 3: Show Hint <BOOL> (default: false)
|
2015-08-18 21:51:30 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-08-22 14:45:50 +00:00
|
|
|
* ["item", vehicle] call ace_cargo_fnc_addCargoItem
|
2015-08-18 21:51:30 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_position", "_item", "_i"];
|
2015-09-26 22:31:23 +00:00
|
|
|
params ["_itemClass", "_vehicle", ["_amount", 1], ["_showHint", false, [false]] ];
|
2015-08-18 21:51:30 +00:00
|
|
|
TRACE_3("params",_itemClass,_vehicle,_amount);
|
|
|
|
|
|
|
|
_position = getPos _vehicle;
|
|
|
|
_position set [1, (_position select 1) + 1];
|
|
|
|
_position set [2, (_position select 2) + 7.5];
|
|
|
|
|
|
|
|
for "_i" from 1 to _amount do {
|
|
|
|
_item = createVehicle [_itemClass, _position, [], 0, "CAN_COLLIDE"];
|
2015-08-18 21:59:01 +00:00
|
|
|
|
|
|
|
// Load item or delete it if no space left
|
2015-09-26 22:31:23 +00:00
|
|
|
if !([_item, _vehicle, _showHint] call FUNC(loadItem)) exitWith {
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_1("no room to load item - deleting",_item);
|
2015-08-18 21:51:30 +00:00
|
|
|
deleteVehicle _item;
|
|
|
|
};
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_1("Item Loaded",_item);
|
2015-09-26 21:16:05 +00:00
|
|
|
|
2015-08-18 21:59:01 +00:00
|
|
|
// Invoke listenable event
|
2015-08-22 14:45:50 +00:00
|
|
|
["cargoAddedByClass", [_itemClass, _vehicle, _amount]] call EFUNC(common,globalEvent);
|
2015-08-18 21:51:30 +00:00
|
|
|
};
|