ACE3/addons/cargo/functions/fnc_addCargoVehiclesActions.sqf
Dystopian 9f291c86d8 Cargo load menu overhaul (#4871)
* Add submenu with vehicles to cargo load menu

* replace private ARRAY with keyword

* fix ace function macro using

* filter vehicles without cargo

* add Load condition, clean params, fix param reusing

* replace nearEntities with nearestObjects, add macro

* optimize, del magic, replace count with forEach

* del unused functions

* del useless _this parameter
2017-05-31 17:02:24 +02:00

45 lines
1.2 KiB
Plaintext

/*
* Author: Dystopian
* Create actions for nearest vehicles with cargo.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Children actions <ARRAY>
*
* Example:
* [target, player] call ace_cargo_fnc_addCargoVehiclesActions
*
* Public: No
*/
#include "script_component.hpp"
private _statement = {
params ["_target", "_player", "_params"];
_params params ["_vehicle"];
[_player, _target, _vehicle] call FUNC(startLoadIn);
};
private _actions = [];
{
private _config = configFile >> "CfgVehicles" >> typeOf _x;
if (
1 == getNumber (_config >> QGVAR(hasCargo)) &&
{_x != _target}
) then {
private _name = getText (_config >> "displayName");
private _ownerName = [_x, true] call EFUNC(common,getName);
if ("" != _ownerName) then {
_name = format ["%1 (%2)", _name, _ownerName];
};
private _icon = (getText (_config >> "icon")) call BIS_fnc_textureVehicleIcon;
private _action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
};
} forEach (nearestObjects [_player, CARGO_VEHICLE_CLASSES, MAX_LOAD_DISTANCE]);
_actions