ACE3/addons/cargo/functions/fnc_getSizeItem.sqf
SilentSpike f65f6e9b72 Add support for virtual cargo
Allows cargo objects to be added via classname and reduces simulation/synchronization overhead. Objects become physical upon unloading and cannot be re-made virtual, only scripts can add such virtual objects.

Also separates the player feedback from the loading/unloading code and adds a progress bar.
2015-09-27 17:34:37 +01:00

39 lines
860 B
Plaintext

/*
* Author: Glowbal
* Get the cargo size of an object.
*
* Arguments:
* 0: Item <OBJECT or STRING>
*
* Return value:
* Cargo size <NUMBER> (default: -1)
*
* Example:
* [object] call ace_cargo_fnc_getSizeItem
*
* Public: No
*/
#include "script_component.hpp"
params ["_item"];
private ["_isVirtual","_itemClass","_config"];
scopeName "return";
_isVirtual = (typeName _item == "STRING");
_itemClass = if (_isVirtual) then {_item} else {typeOf _item};
_config = (configFile >> "CfgVehicles" >> _itemClass >> QGVAR(size));
if (_isVirtual) then {
if (isNumber _config) then {
(getNumber _config) breakOut "return";
};
} else {
_config = (configFile >> "CfgVehicles" >> typeOf _item >> QGVAR(size));
if (isNumber _config) then {
(_item getVariable [QGVAR(size), getNumber _config]) breakOut "return";
};
};
-1