Gilson 10 Posted April 16, 2012 I've come to a complete loss; I have little to no scripting experience in any medium, however myself and a couple of people have managed to mangle this together: Init: waitUntil {!isNil primaryWeapon this}; [this] exec "WeaponCaptive.sqf"; weaponCaptive.sqf: (_this select 0) setCaptive true; waitUntil {isNil primaryWeapon this}; [this] exec "NoWeaponCaptive.sqf" noweaponCaptive.sqf: (_this select 0) setCaptive false; waitUntil {!isNil primaryWeapon this}; [this] exec "WeaponCaptive.sqf" What is supposed to be happening is unit(s) start with the initial state of being setCaptive true, so enemy AI do not react to them, then once they've picked up a gun their state becomes setCaptive false, then if they drop their weapon they return to the initial state of setCaptive true. The snippets above give undefined errors on both the 'this' within the {}'s and the exec part. Looking for some assistance - absolutely anything will be welcome. Share this post Link to post Share on other sites
PELHAM 10 Posted April 17, 2012 (edited) I've come to a complete loss; I have little to no scripting experience in any medium, however myself and a couple of people have managed to mangle this together: One or two bad things there - you can't wait in a vehicle init. I have tested this - seems to work perfectly: Unit init: removeAllWeapons this; this setCaptive true; nul = [this] execVM "WeaponCaptive.sqf"; private ["_unit"]; _unit = _this select 0; while {true} do { if (primaryWeapon _unit != "") then { _unit setCaptive false; } else { _unit setCaptive true; }; sleep 1; }; for testing: Add a weapon to a unit with a radio trigger: {unitName addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3]; unitName addWeapon "M4A1"; Place a weapon on the ground that you can pick up then drop (put this in the init of a traffic cone) you can also make a unit pick up this with the 6 key menu: wpnhld1 = "WeaponHolder" createVehicle (position player); wpnhld1 addWeaponCargoGlobal ["M4A1",1]; wpnhld1 addMagazineCargoGlobal ["30Rnd_556x45_Stanag",5]; Edited April 17, 2012 by PELHAM Share this post Link to post Share on other sites
Gilson 10 Posted April 17, 2012 It works perfectly and is exactly what I needed. Many thanks for your help and work. Share this post Link to post Share on other sites