ACE3/addons/cargo/functions/fnc_loadItem.sqf

43 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Load object into vehicle.
* Objects loaded via classname remain virtual until unloaded.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* 0: Item <OBJECT or STRING>
2015-08-10 21:07:47 +00:00
* 1: Vehicle <OBJECT>
* 2: Show Hint <BOOL> (default: true)
2015-08-10 21:07:47 +00:00
*
* Return value:
* 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"
params [["_item","",[objNull,""]], ["_vehicle",objNull,[objNull]]];
2015-08-10 21:07:47 +00:00
private ["_loaded", "_space", "_itemSize"];
2015-08-16 20:41:35 +00:00
if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {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
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
if (_item isEqualType objNull) then {
detach _item;
_item attachTo [_vehicle,[0,0,-100]];
["hideObjectGlobal", [_item, true]] call EFUNC(common,serverEvent);
};
true