Grumpy Old Man 3546 Posted December 7, 2013 Hey folks, ran into another issue for the script I'm working on. (Which will of course be shared when it's finished, sometime before Christmas) At first glance I thought there would be a way to access the squad commands through script commands, but there seems to be no way to do so. Is it currently even possible to make AI units (not in players group) pick up a backpack via script commands? Had some attempts from which only the following code snippet seems to execute, The named units (without backpacks) are performing the action without getting any backpacks and the backpacks on the ground stay on the ground. Variables are global because I'm trying it within the editors debug console. gunner1BP = nearestObject [gunner1,"B_HuntingBackpack"]; gunner2BP = nearestObject [gunner2,"B_FieldPack_oli"]; gunner1 action ["takeBag",gunner1BP]; gunner2 action ["takeBag",gunner2BP]; Or should I simply delete the backpack objects and use the addbackpack command? Would feel a bit hacky and won't fit the rest of the script since I try to keep it as authentic as possible. Cheers Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 8, 2013 (edited) This works, it's the same backpack - contents are stored correctly: http://community.bistudio.com/wiki/ArmA_3:_Actions#AddBag gunner1 action ["AddBag", (nearestObject [gunner1, "WeaponHolder"]), typeOf firstBackpack (nearestObject [gunner1, "WeaponHolder"])]; or a sqf _handle = [gunner1] execVM "findBagAddBag.sqf"; _unit = _this select 0; _array = nearestObjects [_unit, ["WeaponHolder"], 25]; for "_i" from 0 to (count _array)-1 do { _wh = _array select _i; if (!isNull (firstBackpack _wh)) then { _bp = firstBackpack _wh; _unit action ["AddBag", _wh, typeOf _bp]; }; }; Edited December 8, 2013 by Mattar_Tharkari Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted December 8, 2013 thanks Mattar_Tharkari, that helped a lot! the first code seems to work more reliable, had to change the WeaponHolder into GroundWeaponHolder. is there any way to search for one specific backpack amongst other different backpacks that are on the ground? tried to check for a B_HuntingBackpack without any results. How would a iskindof check look like? or am I trying a wrong approach? Share this post Link to post Share on other sites
Mattar_Tharkari 10 Posted December 8, 2013 placed 6 different types with hunting backpack furthest distance from AI, - this works: _unit = _this select 0; _array = nearestObjects [_unit, ["WeaponHolder"], 25]; for "_i" from 0 to (count _array)-1 do { _wh = _array select _i; if ((typeOf (firstBackpack _wh)) == "B_HuntingBackpack") then { _bp = firstBackpack _wh; _unit action ["AddBag", _wh, typeOf _bp]; }; }; (it checks a radius of 25m so change that if you need a wider search) Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted December 8, 2013 This is exactly what I needed and working exceptionally well! Thanks a ton! Share this post Link to post Share on other sites
Salty Bear 2 Posted November 11, 2018 Quote This works, it's the same backpack - contents are stored correctly: http://community.bistudio.com/wiki/ArmA_3:_Actions#AddBag gunner1 action ["AddBag", (nearestObject [gunner1, "WeaponHolder"]), typeOf firstBackpack (nearestObject [gunner1, "WeaponHolder"])]; gunner1 action ["AddBag", (nearestObject [gunner1, "WeaponHolder"]), typeOf firstBackpack (nearestObject [gunner1, "WeaponHolder"])]; I've been trying to get this working with addAction, and just can't figure it out. I added the following to a unit's INIT: this addAction ["<t color='#FF0000'>Put on Pack</t>","_this action ['AddBag', (nearestObject [_this, 'WeaponHolder']), typeOf firstBackpack (nearestObject [_this, 'WeaponHolder'])];","",10,true,true,"",""]; It gives me an error with nearestObject, saying Type Array, Expected Number. Share this post Link to post Share on other sites
pierremgi 4900 Posted November 11, 2018 wow! necroing a Grumpy Young man's post! this addAction ["<t color='#FF0000'>Put on Pack</t>","params ['_target','_caller']; _target action ['AddBag', (nearestObject [(_target, 'WeaponHolder']), typeOf firstBackpack (nearestObject [_target, 'WeaponHolder'])];","",10,true,true,"",""]; (not tested) 1 Share this post Link to post Share on other sites