armyinf 33 Posted December 13, 2014 As title states, whats the best choice for doing this? An example would be nice if you can. I am trying to have 8 backpacks in the inventory of a few vehicles, all backpacks filled with supplies. Share this post Link to post Share on other sites
armyinf 33 Posted December 13, 2014 So I assume just making sure I am following your code, write an SQF and link it in the init of the vehicle. so for 8 backpacks I would name each one something I.E. _BP1 _vehicle; _BP2 _vehicle; etc Then _vehicle addBackpackCargoGlobal ["B_AssaultPack_khk", 1]; _BP1 = (everyBackpack _vehicle) select (count _BPs); etc _BP1 addItemCargoGlobal ["FirstAidKit", 2]; _BP2 addItemCargoGlobal ["FirstAidKit", 2]; etc Share this post Link to post Share on other sites
dreadedentity 278 Posted December 13, 2014 So I assume just making sure I am following your code, write an SQF and link it in the init of the vehicle. so for 8 backpacks I would name each one something I.E. If you want to do it from vehicle init then this would be much better: { _x addItemCargoGlobal ["FirstAidKit", 2]; }forEach (everyBackpack this); Note: The backpacks need to already be inside the vehicle otherwise this won't work. Only works on backpacks that are already inside your vehicle. Share this post Link to post Share on other sites
armyinf 33 Posted December 14, 2014 That won't work as the backpacks are not already part of the vehicle If you want to do it from vehicle init then this would be much better: { _x addItemCargoGlobal ["FirstAidKit", 2]; }forEach (everyBackpack this); Note: The backpacks need to already be inside the vehicle otherwise this won't work. Only works on backpacks that are already inside your vehicle. Share this post Link to post Share on other sites
Larrow 2823 Posted December 14, 2014 //Call from vehicles init with //loadBPs = this execVM "nameOfScript.sqf"; //If multiplayer, only add backpack where the vehicle is local //as the backpack and item commands are global they will be seen on all machines if ( isMultiplayer && { !( local _this ) } ) exitWith {}; //Add 8 backpacks with 2 FAKs each for "_i" from 1 to 8 do { //list all backpacks in the vehicle _BPs = everyBackpack _this; //add a new backpack to the vehicle _this addBackpackCargoGlobal ["B_AssaultPack_khk", 1]; //Find the added backpack _BP = (everyBackpack _this) select (count _BPs); //Last one added //Fill it with your stuff _BP addItemCargoGlobal ["FirstAidKit", 2]; //Add what ever else you want here }; No need to name everything just loop the code 8 times Share this post Link to post Share on other sites
armyinf 33 Posted December 14, 2014 How would that work with the following: 8 bags 4 having the same thing (30 Stanags)- same type bag 2 having hand grenades/ smoke grenades - same type bag 2 having agm medical supplies- Same type of bag So it would be 3 different class names of bags, with that break down. Is that possible? Share this post Link to post Share on other sites
jshock 513 Posted December 14, 2014 You would need seperate for loops for each "type" of bag, and you would actually have to go into some nested for loops to make it easy on yourself. For example your magazine bags you would need a nested for loop, the over arching loop at 4, and the nested element at however many magazines you want in the bag (i.e. 15). Share this post Link to post Share on other sites
dreadedentity 278 Posted December 14, 2014 You would need seperate for loops for each "type" of bag, and you would actually have to go into some nested for loops to make it easy on yourself. For example your magazine bags you would need a nested for loop, the over arching loop at 4, and the nested element at however many magazines you want in the bag (i.e. 15). keeping it complicated, eh, JShock? this addBackpackCargoGlobal ["B_AssaultPack_khk", 8]; { if (_forEachIndex <= 1) then { //add AGM medical supplies }; if ((_forEachIndex > 1) && {_forEachIndex <= 3) then { //add hand grenades/smoke grenades }; if (_forEachIndex > 3) then { _x addMagazineAmmoCargo ["STANAG_CLASSNAME", 30, 30]; }; }forEach (everyBackpack this); Share this post Link to post Share on other sites
Larrow 2823 Posted December 15, 2014 How about something like if ( isMultiplayer && { !( local _this ) } ) exitWith {}; { //Find backpacks already in vehicle _BPs = everyBackpack _this; //Add backpack to vehicle _this addBackpackCargoGlobal [ _x select 0, 1]; //Find last backpack _BP = (everyBackpack _this) select (count _BPs); //Fill backpack with stuff { _item = _x select 0; switch ( toUpper( ( [ _item ] call BIS_fnc_itemType ) select 0 ) ) do { case ( "MINE" ); case ( "MAGAZINE" ):{ _BP addMagazineCargoGlobal _x; }; case ( "WEAPON" ):{ _BP addWeaponCargoGlobal _x; }; default { _BP addItemCargoGlobal _x; }; }; }forEach ( _x select 1 ); }forEach [ //Bag 1 [ "B_AssaultPack_khk",[ //Bag type //Stuff [ type, amount ] [ "30Rnd_556x45_Stanag", 30 ], [ "FirstAidKit", 2 ], [ "hgun_P07_F", 1 ] ]], //Bag 2 [ "B_AssaultPack_blk",[ [ "30Rnd_556x45_Stanag", 30 ], [ "U_B_CombatUniform_mcam", 1 ] ]], [ "B_Carryall_cbr",[ [ "H_HelmetSpecB_paint2", 1 ] ]], [ "B_AssaultPack_khk",[ [ "30Rnd_556x45_Stanag", 30 ] ]], [ "B_AssaultPack_khk",[ [ "30Rnd_556x45_Stanag", 30 ] ]], [ "B_AssaultPack_khk",[ [ "30Rnd_556x45_Stanag", 30 ], [ "DemoCharge_Remote_Mag", 2 ] ]], [ "B_AssaultPack_khk",[ [ "30Rnd_556x45_Stanag", 30 ], [ "SmokeShellPurple", 3 ] ]], [ "B_AssaultPack_khk",[ [ "30Rnd_556x45_Stanag", 30 ] ]] ]; Then all you have to do is fill out the arrays at the end with the type of bags you want and the items to go in each of them. Then you can have as many bags as you like with what ever items you like without having to worry about the code above it. Or have i complicated things more? The only thing it does not check for you is if there is enough room for all the stuff and whether it can actually fit in the bag. Not thoroughly tested.. Share this post Link to post Share on other sites
jshock 513 Posted December 15, 2014 Or have i complicated things more? Well, I understand it, but really the main person that needs to understand it is the OA :p. Share this post Link to post Share on other sites