2015-08-10 21:07:47 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
2015-08-16 20:41:35 +00:00
|
|
|
* Load object into vehicle.
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Object <OBJECT>
|
|
|
|
* 1: Vehicle <OBJECT>
|
2015-09-26 21:16:05 +00:00
|
|
|
* 2: Show Hint <BOOL> (default: true)
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
2015-08-16 20:48:52 +00:00
|
|
|
* Object loaded <BOOL>
|
2015-08-10 21:07:47 +00:00
|
|
|
*
|
2015-08-16 20:41:35 +00:00
|
|
|
* Example:
|
|
|
|
* [object, vehicle] call ace_cargo_fnc_loadItem
|
|
|
|
*
|
2015-08-10 21:07:47 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_loaded", "_space", "_itemSize"];
|
2015-08-16 20:41:35 +00:00
|
|
|
|
2015-09-26 21:16:05 +00:00
|
|
|
params ["_item", "_vehicle", ["_showHint", true, [true]] ];
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_2("params",_item,_vehicle);
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-09-20 15:05:34 +00:00
|
|
|
if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {
|
|
|
|
TRACE_2("canLoadItemIn failed",_item,_vehicle);
|
|
|
|
false
|
|
|
|
};
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-08-16 20:41:35 +00:00
|
|
|
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
2015-08-10 21:07:47 +00:00
|
|
|
_loaded pushback _item;
|
2015-08-16 20:41:35 +00:00
|
|
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-09-20 15:05:34 +00:00
|
|
|
TRACE_1("added to loaded array",_loaded);
|
|
|
|
|
2015-08-10 21:07:47 +00:00
|
|
|
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
|
|
|
_itemSize = [_item] call FUNC(getSizeItem);
|
2015-08-16 20:41:35 +00:00
|
|
|
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];
|
2015-08-10 21:07:47 +00:00
|
|
|
|
|
|
|
detach _item;
|
|
|
|
_item attachTo [_vehicle,[0,0,100]];
|
2015-08-18 16:19:18 +00:00
|
|
|
["hideObjectGlobal", [_item, true]] call EFUNC(common,serverEvent);
|
2015-08-10 21:07:47 +00:00
|
|
|
|
2015-09-17 11:43:55 +00:00
|
|
|
// show hint
|
|
|
|
private ["_itemName", "_vehicleName"];
|
|
|
|
|
|
|
|
_itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName");
|
|
|
|
_vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
|
|
|
|
|
2015-09-26 21:16:05 +00:00
|
|
|
if (_showHint) then {
|
|
|
|
["displayTextStructured", [[localize LSTRING(LoadedItem), _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent);
|
|
|
|
};
|
2015-09-17 11:43:55 +00:00
|
|
|
|
2015-08-18 16:48:21 +00:00
|
|
|
// Invoke listenable event
|
2015-08-22 14:45:50 +00:00
|
|
|
["cargoLoaded", [_item, _vehicle]] call EFUNC(common,globalEvent);
|
2015-08-18 16:48:21 +00:00
|
|
|
|
2015-08-16 20:48:52 +00:00
|
|
|
true
|