ACE3/addons/cargo/functions/fnc_startUnload.sqf

52 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Start unload action.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* None
*
* Return value:
* None
*
2015-08-16 20:41:35 +00:00
* Example:
* [] call ace_cargo_fnc_startUnload
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
2016-01-19 03:53:48 +00:00
private _display = uiNamespace getVariable QGVAR(menuDisplay);
if (isNil "_display") exitWith {};
2015-08-16 20:41:35 +00:00
2016-01-19 03:53:48 +00:00
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
if (_loaded isEqualTo []) exitWith {};
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _ctrl = _display displayCtrl 100;
2015-08-10 21:07:47 +00:00
2016-01-19 03:53:48 +00:00
private _selected = (lbCurSel _ctrl) max 0;
2015-08-10 21:07:47 +00:00
2015-08-16 20:41:35 +00:00
if (count _loaded <= _selected) exitWith {};
2016-01-19 03:53:48 +00:00
private _item = _loaded select _selected; //This can be an object or a classname string
// Start progress bar
2016-01-27 00:01:01 +00:00
if ([_item, GVAR(interactionVehicle), ACE_player] call FUNC(canUnloadItem)) then {
2016-01-19 03:53:48 +00:00
private _size = [_item] call FUNC(getSizeItem);
[
5 * _size,
[_item, GVAR(interactionVehicle), ACE_player],
2016-05-24 13:13:11 +00:00
{["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent},
{},
localize LSTRING(UnloadingItem),
{true},
["isNotSwimming"]
] call EFUNC(common,progressBar);
} else {
2016-01-19 03:53:48 +00:00
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
private _displayName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
[[LSTRING(UnloadingFailed), _displayName], 3.0] call EFUNC(common,displayTextStructured);
};