Razor[42JTF] 10 Posted October 2, 2015 Hi All Hoping someone can help me with adding a backpack/uniform/vest that have items/ammo inside them to ammo crates. You can transfer your gear with items inside into an ammo box in game so I imagine there is a way to script it in sqf. For example, I want to script that there are backpacks loaded with smoke and frag grenades inside the ammo crate. If anyone has advice or can direct me to a thread, will appreciate it. Regards Razor Share this post Link to post Share on other sites
Larrow 2779 Posted October 3, 2015 Once you have added a container (backpack,uniform,vest) to a crate you can retrieve a reference to it by using everyContainer on the crate, you can then add your gear to this reference. Heres a function you can use.. fnc_addContainerWithCargo = { private [ "_containerCommand", "_containerList", "_container", "_type", "_item", "_amount" ]; params[ [ "_box", objNull, [ objNull ] ], [ "_containerType", "B_AssaultPack_blk", [ "" ] ], [ "_count", 1, [ 0 ] ], [ "_loadout", [], [ [] ] ] ]; if ( isNull _box ) exitWith {}; //Get the type of item being placed in the box _containerCommand = switch ( ( _containerType call BIS_fnc_itemType ) select 1 ) do { case "Uniform"; case "Vest" : { "Item" }; case "Backpack" : { "Backpack" }; default { nil }; }; if ( isNil "_containerCommand" ) exitWith {}; //For each container to add for "_i" from 1 to _count do { //if there is room in the box for the container if ( _box canAdd _containerType ) then { //Get a list of current containers in the box _containerList = everyContainer _box; //Add new container call compile format [ "_box add%1CargoGlobal [ _containerType, 1 ]", _containerCommand ]; //Find the new container _container = ( everyContainer _box - _containerList ) select 0 select 1; //For each item in the loadout { //If item is an array if ( typeName _x isEqualTo typeName [] ) then { //Set item and amount _item = _x select 0; _amount = _x select 1; }else{ //Else its just item and amount of 1 _item = _x; _amount = 1; }; //For the amount of the item for "_a" from 1 to _amount do { //If the item will fit in the container if ( _container canAdd _item ) then { //Find the items type _type = _x call BIS_fnc_itemType; //Add item based on its type switch ( _type select 0 ) do { case "Item" : { _container addItemCargoGlobal [ _item, 1 ]; }; case "Magazine" : { _container addMagazineCargoGlobal [ _item, 1 ]; }; case "Weapon" : { _container addWeaponCargoGlobal [ _item, 1 ]; }; case "Equipment" : { if ( _type select 1 == "Backpack" ) then { _container addBackpackCargoGlobal [ _item, 1 ]; }else{ _container addItemCargoGlobal [ _item, 1 ]; }; }; }; }; }; }forEach _loadout; }; }; };And you would use it like.. _myloadout = [ [ "30Rnd_65x39_caseless_mag", 5 ], "hgun_P07_F" ]; //[ crate, container item type, amount, loadout ] call fnc_addContainerWithCargo [ box, "B_AssaultPack_blk", 3, _myLoadout] call fnc_addContainerWithCargo;Which would add 3 "B_AssaultPack_blk" backpacks to a crate named box, each containing 5 "30Rnd_65x39_caseless_mag" magazines and one "hgun_P07_F" handgun.Not thoroughly tested, see how you get on with it. 1 Share this post Link to post Share on other sites
Razor[42JTF] 10 Posted October 3, 2015 I f***ing love the Arma Community. Works like a boss. Thanks alot. Share this post Link to post Share on other sites