Twiznak 57 Posted May 22, 2020 Hi. I need help with adding items to an ammo box. My aim here is to spawn a copy of an already existing ammo box. For the ultimate purposes of creating a custom ammo drop script that is called from the crates init field. In the supply drop support module. Here is my script, so you can see what I am doing: ammo box placed in the editor named customCrate_1. addAction ["Spawn Copy Crate", "SCC.sqf"]; SCC.sqf _newBP = getBackpackCargo customCrate_1; _newItem = getItemCargo customCrate_1; _newMag = getMagazineCargo customCrate_1; _newWep = getWeaponCargo customCrate_1; _box ="B_SupplyCrate_F" createVehicle position Player; clearBackpackCargoGlobal _box; clearItemCargoGlobal _box; clearMagazineCargoGlobal _box; clearWeaponCargoGlobal _box; _box addBackpackCargoGlobal _newBP; _box addItemCargoGlobal _newItem; _box addMagazineCargoGlobal _newMag; _box addWeaponCargoGlobal _newWep; No errors in the editor or the logs, but there's no cargo being added to the new box. I tried getting as fancy as I could by trying to call specific variables from the predefined array. Example, _box addBackpackCargoGlobal [(_newBP select 1),(_newBP select 2)]; again, no errors and no cargo. I usually follow my trail of tears errors through the logs to find a solution but the trail went cold for me. Would someone please point out my errors so that I can learn. Thank you. Share this post Link to post Share on other sites
Dedmen 2590 Posted May 22, 2020 2 hours ago, Twiznak said: _box addBackpackCargoGlobal _newBP; Well.. Thats a syntax error. Check the wiki https://community.bistudio.com/wiki/addBackpackCargoGlobal https://community.bistudio.com/wiki/getBackpackCargo Here's how I do it: https://github.com/WolfCorps/WolfLogistics/tree/master/addons/main/functions But that doesn't handle backpacks, but backpacks are just boxes too, so you just need to recurse into https://community.bistudio.com/wiki/everyBackpack 1 Share this post Link to post Share on other sites
Twiznak 57 Posted May 22, 2020 11 hours ago, Dedmen said: Well.. Thats a syntax error. Check the wiki https://community.bistudio.com/wiki/addBackpackCargoGlobal https://community.bistudio.com/wiki/getBackpackCargo Here's how I do it: https://github.com/WolfCorps/WolfLogistics/tree/master/addons/main/functions But that doesn't handle backpacks, but backpacks are just boxes too, so you just need to recurse into https://community.bistudio.com/wiki/everyBackpack Dedmen, Thank you for the functions! I am copy/pasting to notepad++ and getting to work right now! When I figure it out, I will comeback here and post my working model so that future arma scripters can use it as a resource......Key word there is when 🙂 thank you Dedmen!. Share this post Link to post Share on other sites
Twiznak 57 Posted May 25, 2020 On 5/22/2020 at 1:39 AM, Dedmen said: Here's how I do it: https://github.com/WolfCorps/WolfLogistics/tree/master/addons/main/functions But that doesn't handle backpacks, but backpacks are just boxes too, so you just need to recurse into https://community.bistudio.com/wiki/everyBackpack THANK. YOU. Dedmen! I have a working solution to share with everyone. this script will spawn a copy of an ammo crate with ALL weapons(including all attachments), armor, uniforms, backpacks, magazines, and items. However, it will not transfer items in the inventories of vests and backpacks. They will need to be emptied. Mission: Spawn a copy of a crate. In the editor: Place down a supply crate, name it "CustomCrate_1" and clear its inventory. In CustomCrate_1's init field, add the following this addAction ["Spawn a Copy Crate", "spawnCopyCrate.sqf"]; Copy & Paste the following into NotePad++. Save the file as spawnCopyCrate.sqf and add the file into your mission file. params ["_target", "_presetName", "_presetDescription"]; _target = customCrate_1; private _presetContents = []; private _presetBackpackContents = []; private _newPreset = [_presetName, _presetDescription, _presetContents, _presetBackpackContents]; private _weapons = []; { _presetContents pushBack _X; } forEach weaponsItemsCargo _target; private _magazineCargo = getMagazineCargo _target; { _presetContents pushBack [_x, (_magazineCargo select 1) select _forEachIndex]; } forEach (_magazineCargo select 0); private _itemCargo = getItemCargo _target; { _presetContents pushBack [_x, (_itemCargo select 1) select _forEachIndex]; } forEach (_itemCargo select 0); private _bagCargo = getBackpackCargo _target; { _presetBackpackContents pushBack [_x, (_bagCargo select 1) select _forEachIndex]; } forEach (_bagCargo select 0); _box = "B_SupplyCrate_F" createVehicle position Player; clearWeaponCargoGlobal _box; clearItemCargoGlobal _box; clearMagazineCargoGlobal _box; clearBackpackCargoGlobal _box; params ["_target", "_preset"]; _target = _box; _preset params ["_presetName","_presetDescription","_presetContents", "_presetBackpackContents"]; { if (count _x > 2) then { //Weapon _target addWeaponWithAttachmentsCargoGlobal [_x, 1]; } else { //Item _x params ["_class", "_count"]; _target addItemCargoGlobal [_class, _count]; } } forEach _presetContents; { _x params ["_class", "_count"]; _target addBackpackCargoGlobal [_class, _count]; } forEach _presetBackpackContents; This script can also be called from a virtual supply drop support module. Replacing the default contents of the ammo crate with the contents of CustomCrate_1. Here is how: In the virtual supply drop support module, add the following into the Crate init field _this execVM "spawnCopyCrate.sqf"; In spawnCopyCrate.sqf, delete the the following line _box = "B_SupplyCrate_F" createVehicle position Player; and change all 5 remaining instances of "_box" to "_this". Share this post Link to post Share on other sites
Dedmen 2590 Posted May 26, 2020 On 5/25/2020 at 5:03 AM, Twiznak said: The error received is : 2 elements provided , 7 expected Yes. You are missing the check https://github.com/WolfCorps/WolfLogistics/blob/master/addons/main/functions/fnc_fillPresetIntoBox.sqf#L25 1 Share this post Link to post Share on other sites
Twiznak 57 Posted May 26, 2020 10 hours ago, Dedmen said: Yes. You are missing the check https://github.com/WolfCorps/WolfLogistics/blob/master/addons/main/functions/fnc_fillPresetIntoBox.sqf#L25 My avatar explains everything about this 🙂 I had removed the if () then{}; control structure while I was trying to get the backpacks to transfer and forgot to add it back in. Oops! Thank you again Dedmen. I have up'd the ante and modified PierreMGI's vehicle drop script to add the copied ammo crate contents to air dropped vehicles. SUPER useful script. Thank you man. 1 Share this post Link to post Share on other sites