mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
d1f0dc5e83
* Update CfgVehicles.hpp * Cargo cleanup * Update menu.hpp * Updated status effect key * Update fnc_onMenuOpen.sqf * Update fnc_onMenuOpen.sqf * fix comment from merge * nil interaction GVARs on menu close * fix carry bug * Fix floating objects in MP * Updated ace_cargoAdded doc * Fix progress bar prematurely stopping * Finer cursor object selection --------- Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com>
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
#include "..\script_component.hpp"
|
|
/*
|
|
* Author: kymckay
|
|
* Sets the cargo space of any object. Has global effect.
|
|
* Adds the cargo action menu if necessary.
|
|
*
|
|
* Arguments:
|
|
* 0: Vehicle <OBJECT> (default: objNull)
|
|
* 1: Cargo space <NUMBER> (default: nil)
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [vehicle player, 20] call ace_cargo_fnc_setSpace
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
|
|
params [
|
|
["_vehicle", objNull, [objNull]],
|
|
["_space", nil, [0]] // default can't be a number since all are valid
|
|
];
|
|
TRACE_2("setSpace",_vehicle,_space);
|
|
|
|
// Nothing to do here
|
|
if (isNil "_space" || {isNull _vehicle}) exitWith {};
|
|
|
|
// Account for cargo already in the vehicle
|
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
private _cargoSpace = _space;
|
|
|
|
{
|
|
_cargoSpace = _cargoSpace - ((_x call FUNC(getSizeItem)) max 0);
|
|
} forEach _loaded;
|
|
|
|
// If the new value is the same as the old, do nothing
|
|
if (_cargoSpace == (_vehicle call FUNC(getCargoSpaceLeft))) exitwith {};
|
|
|
|
// Apply new space globally
|
|
// Necessary to update value, even if no space, as API could be used again
|
|
_vehicle setVariable [QGVAR(hasCargo), _space > 0, true];
|
|
_vehicle setVariable [QGVAR(space), _cargoSpace, true];
|
|
|
|
// Space should be added for all future JIP players too, regardless of space
|
|
private _jipID = format [QGVAR(spaceJipID_%1), hashValue _vehicle];
|
|
[QGVAR(initVehicle), _vehicle, _jipID] call CBA_fnc_globalEventJIP;
|
|
|
|
// Remove from JIP queue if vehicle is deleted
|
|
if !(_vehicle getVariable [QGVAR(setSpaceRemoveJip), false]) then {
|
|
[_jipID, _vehicle] call CBA_fnc_removeGlobalEventJIP;
|
|
|
|
_vehicle setVariable [QGVAR(setSpaceRemoveJip), true, true];
|
|
};
|