2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2021-10-12 22:42:38 +00:00
|
|
|
/*
|
|
|
|
* Author: JasperRab
|
|
|
|
* Gets the name of the item, and alternatively the custom name if requested and available.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2023-11-17 23:07:28 +00:00
|
|
|
* 0: Item <STRING> or <OBJECT> (default: "")
|
|
|
|
* 1: Add custom name <BOOL> (default: false)
|
2021-10-12 22:42:38 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2023-11-17 23:07:28 +00:00
|
|
|
* Item name <STRING>
|
2021-10-12 22:42:38 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2023-11-17 23:07:28 +00:00
|
|
|
* cursorObject call ace_cargo_fnc_getNameItem
|
2021-10-12 22:42:38 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
params [["_item", "", [objNull, ""]], ["_addCustomName", false, [false]]];
|
2021-10-12 22:42:38 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
private _displayName = if (_item isEqualType "") then {
|
|
|
|
getText (configFile >> "CfgVehicles" >> _item >> "displayName")
|
2022-01-30 18:12:52 +00:00
|
|
|
} else {
|
2023-11-17 23:07:28 +00:00
|
|
|
getText (configOf _item >> "displayName")
|
2022-01-30 18:12:52 +00:00
|
|
|
};
|
2021-10-12 22:42:38 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
if (_addCustomName && {_item isEqualType objNull}) then {
|
|
|
|
private _customName = _item getVariable [QGVAR(customName), ""];
|
2021-10-12 22:42:38 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
if (_customName isNotEqualTo "") then {
|
|
|
|
_displayName = _displayName + " [" + _customName + "]";
|
2021-10-12 22:42:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
_displayName
|