ACE3/addons/cargo/functions/fnc_getSizeItem.sqf

40 lines
843 B
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Get the cargo size of an object.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* 0: Item <OBJECT or STRING>
2015-08-10 21:07:47 +00:00
*
* Return value:
2015-08-16 20:41:35 +00:00
* Cargo size <NUMBER> (default: -1)
*
* Example:
* [object] call ace_cargo_fnc_getSizeItem
2015-08-10 21:07:47 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2015-08-14 16:42:22 +00:00
params ["_item"];
2016-01-19 03:53:48 +00:00
scopeName "return";
2016-01-19 03:53:48 +00:00
private _isVirtual = (_item isEqualType "");
private _itemClass = if (_isVirtual) then {_item} else {typeOf _item};
private _config = (configFile >> "CfgVehicles" >> _itemClass >> QGVAR(size));
2015-08-16 20:41:35 +00:00
if (_isVirtual) then {
if (isNumber _config) then {
(getNumber _config) breakOut "return";
};
} else {
2016-01-19 03:53:48 +00:00
if (!isNil {_item getVariable QGVAR(size)}) then {
(_item getVariable QGVAR(size)) breakOut "return";
};
if (isNumber _config) then {
2016-01-19 03:53:48 +00:00
(getNumber _config) breakOut "return";
};
2015-08-10 21:07:47 +00:00
};
2015-08-16 20:41:35 +00:00
-1