Jump to content

Recommended Posts

Hey guys,

 

How would you recommend I save a vehicle's or ammo box's detailed inventory?  

 

Currently I am saving and restoring using the "getBackpackCargo" family of commands but I have learned it doesn't save contents, attachments etc. and would love a fresh opinion.

 

Thank you!

Share this post


Link to post
Share on other sites

Instead of allowing the command to grab the weapons for you why not just do it manually.

Because I believe for all the command cares, the weapons could be of any size and any attachment.

You should be able to just index the weapons from the backpack 

Share this post


Link to post
Share on other sites

Thanks,  I was hoping there was a pre-built function that I was missing.  The biggest issue that I have been told about is backpacks and other items within backpacks, within ammo crates/inventory.  I'll see if I can make a handler and post it here when its made.

Share this post


Link to post
Share on other sites
18 hours ago, wyattwic said:

Thanks,  I was hoping there was a pre-built function that I was missing.  The biggest issue that I have been told about is backpacks and other items within backpacks, within ammo crates/inventory.  I'll see if I can make a handler and post it here when its made.

As far as I know, backpacks in a ammo inventory are just represented visually until the need to pull them physically. So it shouldn't be too hard to find out the different types in a given ammo crate. 

Share this post


Link to post
Share on other sites

I'm working on creating code to address my issue, but for some reason my code below freezes the game.   Any idea what I am doing wrong here?

 

This is being ran from debug console.

 

_veh = cursorObject;

_getContainerItems = {
	_return = [];
	{
	_name = _x select 0;
	_object = _x select 1;
	
	_mags = magazinesAmmoCargo _veh;
	_weaps = weaponsItemsCargo _veh;
	_items = itemCargo _veh;
	_containers = everyContainer _veh;
	
	_containers = if (_containers isEqualTo []) then {[]} else {_containers call _getContainerItems};
	
	_return pushBack [_name,_mags,_items,_weaps,_containers];
	
	} foreach _this;
	_return
};


_top_mags = magazinesAmmoCargo _veh;

_top_weaps = weaponsItemsCargo _veh;

_top_items = itemCargo _veh;

_top_containers = everyContainer _veh;  

_top_containers = if (_top_containers isEqualTo []) then {[]} else {_top_containers call _getContainerItems};

return = [_top_mags,_top_items,_top_weaps,_top_containers];

 

Share this post


Link to post
Share on other sites

Welp, I discovered after posing I had a few errors.  I corrected them, but now I have another issue.

 

For some reason, the below code wont return the contents of a backpack.

When broken down and ran in debug, I have no issues.  Any ideas?

 

 



getContainerItems = {
	private _return = [];
	{
	_name = _x select 0;
	_object = _x select 1;
	
	_mags = magazinesAmmo _object;
	_weaps = weaponsItems _object;
	_items = itemCargo _object;
	_containers = everyContainer _object;
	
	_containers = if (_containers isEqualTo []) then {[]} else {_containers call getContainerItems};
	
	_return pushBack [_name,_mags,_items,_weaps,_containers];
	
	} foreach _this;
	_return
};

_veh = cursorObject;
_top_mags = magazinesAmmoCargo _veh;

_top_weaps = weaponsItemsCargo _veh;

_top_items = itemCargo _veh;

_top_containers = everyContainer _veh;  

_top_containers = if (_top_containers isEqualTo []) then {[]} else {_top_containers call getContainerItems};

return = [_top_mags,_top_items,_top_weaps,_top_containers];

 

Share this post


Link to post
Share on other sites
_containers = if (_containers isEqualTo []) then {[]} else {_containers call getContainerItems};

Havent scripted in a while

 

But isn't this forcing it into a never ending loop? because this line is within getcontaineritems?

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

×