Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
somners

Check if an object has an inventory

Recommended Posts

Hi, so I would like to get nearby objects with nearestObjects. And then check each object to see if it has an inventory space. Such as an ammo crate or an offroad. Where things like H-Barriers and Buildings don't have inventories.

Is there a way to check if an inventory exists within an object? There is clearly no scripting command to check, and i've been looking possible config values that would signify it an object with an inventory, but to no avail.

Share this post


Link to post
Share on other sites

Just came back here to reply with my solution and, you pretty much nailed the best option.

canAdd isn't a great option because (even though I didn't try it) I need to know if its capable of holding objects, if its full that would return false. If it does work.

I then tried using the supplyRadius config entry, but that doesn't work with vehicles.

So, as you also suggested, the transportWeapons, transportMagazines, and transportBackpacks are the best options. Just check to make sure at least one is above zero.

Below is a function that will do this for anyone interested.

_className = _this select 0;
_tb = getNumber (configFile >> "CfgVehicles" >> _className >> "transportmaxbackpacks");
_tm = getNumber (configFile >> "CfgVehicles" >> _className >> "transportmaxmagazines");
_tw = getNumber (configFile >> "CfgVehicles" >> _className >> "transportmaxweapons");
_return = if (_tb > 0  || _tm > 0 || _tw > 0) then {true;} else {false;};
_return

Share this post


Link to post
Share on other sites
Sign in to follow this  

×