ACE3/addons/cargo/functions/fnc_validateCargoSpace.sqf

39 lines
850 B
Plaintext
Raw Normal View History

2015-08-10 21:07:47 +00:00
/*
* Author: Glowbal
2015-08-16 20:41:35 +00:00
* Validate the vehicle cargo space.
2015-08-10 21:07:47 +00:00
*
* Arguments:
* 0: Object <OBJECT>
*
* Return value:
* None
*
2015-08-16 20:41:35 +00:00
* Example:
* [object] call ace_cargo_fnc_validateCargoSpace
*
2015-08-10 21:07:47 +00:00
* Public: No
*/
#include "script_component.hpp"
private ["_loaded", "_newLoaded", "_totalSpaceOccupied"];
2015-08-16 20:41:35 +00:00
2015-08-10 21:07:47 +00:00
params ["_vehicle"];
2015-08-16 20:41:35 +00:00
_loaded = _vehicle getVariable [QGVAR(loaded), []];
2015-08-10 21:07:47 +00:00
_newLoaded = [];
_totalSpaceOccupied = 0;
{
if !(isNull _x) then {
_newLoaded pushback _x;
_totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem));
};
true
} count _loaded;
2015-08-10 21:07:47 +00:00
if (count _loaded != count _newLoaded) then {
2015-08-16 20:41:35 +00:00
_vehicle setVariable [QGVAR(loaded), _newLoaded, true];
2015-08-10 21:07:47 +00:00
};
2015-08-16 20:41:35 +00:00
_vehicle setVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space)) - _totalSpaceOccupied, true];