Jump to content
Sign in to follow this  
Nick Seafort

Find vehicle current inventory level, and what determines cargo capacity?

Recommended Posts

Hi all, I've been digging through the A3 files, Biki, BIS forums and google for these but not found satisfactory answers yet. My issue is that I'm trying to add a bit to a current GUI I've been building to allow both loading preset groups of items into a vehicle's inventory (e.g. some AT, patrol supplies, or medical gear), and loading crates into a vehicle with ACE logistics. The ACE logistics side of it seems trivial, and early tests have worked just as expected... but I've run into a complete stop with the vanilla side of things.

 

Scenario: I have a vehicle with unknown cargo capacity, filled with an unknown selection of gear. I wish to load a selection of items in to the cargo, but need to check whether there is enough space to hold the selection before loading.

 

Issue: I can't find a function that returns the current inventory fill. I know there must bloody be one, though, because the inventory has a cap and a bar displaying loading!

 

 

"Load" looks like it should work, but just returns 0 when I try it. I've checked the GUI_F and Functions_F (among most other even tenuously-related folders), but can't see how either the GUI determines how full the bar is or when to block a transfer because the destination container isn't big enough. Can anyone point me in the right direction here please?

 

 

Additional: The Blackout/Commanche doesn't seem to have a "MaximumLoad" specified, and nor does anything it inherits from as far as I can see. It's the only helicopter that doesn't, but none of the fixed-wings do either. What config entry is determining the maximum capacity?

 

Additional 2: Vehicle inventory bars don't always display as fully empty when no items remain in cargo. Is this just a bug in the way the bar displays, or is something wonky at a more fundamental level?

Share this post


Link to post
Share on other sites

maximumLoad I think if it's not defined then it will be default 2000 (probably wrong)

&

canAdd is probably what you're looking for

&

don't forget ACE's which is ace_cargo_space and to see if it even has cargo ace_cargo_hasCargo

Share this post


Link to post
Share on other sites

canAdd is helpful for individual items, but ideally I want to know in advance if I can load the entire group of items or not. Thanks though, I hadn't found that one before!

 

As for the ACE side of things, I've already got that all in hand but thanks :)

Share this post


Link to post
Share on other sites

Maybe this:
 

/*   
    0 / _vehicleClass / STRING / Vehicle classname   
    1 / _itemsArray / ARRAY / Items array format [["arifle_MXC_f",2],["ItemMap",10]]
*/

HG_doesItFit =
{    
    params["_vehicleClass","_itemsArray"];           
    private["_maxLoad","_totalMass","_itemClass","_mass","_count","_return"];

    _maxLoad = getNumber(configFile >> "CfgVehicles" >> _vehicleClass >> "maximumLoad");    
    _totalMass = 0;
    _return = false;    

    {        
        _itemClass = [(_x select 0)] call HG_getConfig;       
        _mass = getNumber(configFile >> _itemClass >> (_x select 0) >> "mass");        
        _count = (_x select 1);        
        _totalMass = (_mass * _count) + _totalMass;    
    } forEach _itemsArray;    

    if(_totalMass > _maxLoad) then    
    {        
        _return = false;    
    } else {        
        _return = true;    
    };    
    
    _return;
};
HG_getConfig = 
{    
    params["_item];        

    switch true do    
    {        
        case(isClass(configFile >> "CfgWeapons" >> _item)): {"CfgWeapons"};        
        case(isClass(configFile >> "CfgMagazines" >> _item)): {"CfgMagazines"};        
        case(isClass(configFile >> "CfgVehicles" >> _item)): {"CfgVehicles"};    
    };
};

To call it:

_doesItFit = [_vehicleClass,_itemsArray] call HG_doesItFit;

Returns false when it doesn't fit and true if it does.

Dont know if this is what you're looking for tho :x

  • Like 2

Share this post


Link to post
Share on other sites

That looks like pretty much exactly what I intend - I'd really hoped to find there was a native command for this, but I reckon I'll have to go the route of manually calculating it each time. Thanks :)

Share this post


Link to post
Share on other sites

Just for the readability and usage purposes, I'd rename this to hasEnoughSpace ;) Perhaps that's just me, but it seems easier to remember.

Share this post


Link to post
Share on other sites

Sorry, didn't make it clear - I'm striking out in a slightly different direction and working from scratch, but was appreciative of having my suspicions effectively confirmed. And bonus marks for someone willing to stump-up some reasonably nice code in response to an open question :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×