Incontinentia 339 Posted January 15, 2017 Hi guys. Apologies if this has been posted already, tried searching to no avail. Really simple request: How do I remove a specific object and all its contents from a container (groundweaponholder, crate, vehicle etc) without having to remove everything? I'm specifically looking at uniforms / vests / backpacks with items in them. Edit: was being dense. Here's the final function. fnc_findNewUniform = { params ["_unit",["_switchUniform",true],["_attempt",1],["_autoReAttempt",true]]; private ["_activeContainer","_newUnif","_origUnif","_newUnifItems","_droppedUniform","_containerArray"]; _containerArray = []; if (_attempt <= 1) then {_containerArray = (nearestObjects [_unit, ["GroundWeaponHolder"],5])}; if ((count _containerArray == 0) && {_attempt <= 2}) then {_attempt = 2; _containerArray = (_unit nearEntities [["LandVehicle","Ship","Air"],5])}; if ((count _containerArray == 0) && {_attempt <= 3}) then {_attempt = 3; _containerArray = (nearestObjects [_unit, ["ReammoBox_F"],5])}; if (count _containerArray == 0) exitWith {false}; _activeContainer = (_containerArray select 0); _origUnif = uniform _unit; _origUnifItems = uniformItems _unit; _newUnif = (((everyContainer _activeContainer) select { ( ( (((_x select 0) find "U_") >= 0) || {(((_x select 0) find "uniform") >= 0)} || {(((_x select 0) find "Uniform") >= 0)} ) && { !(((_x select 0) find _origUnif) == 0) || {_origUnif == ""} } ) }) select 0); if (isNil "_newUnif") exitWith { _return = false; if (_autoReAttempt && {_attempt <= 2}) then { _return = [[_unit,_switchUniform,(_attempt + 1)],"switchUniforms"] call INCON_fnc_civHandler; }; _return }; if (_switchUniform) then { [_unit,_activeContainer,_origUnifItems,_origUnif,_newUnif] spawn { params ["_unit","_activeContainer","_origUnifItems","_origUnif","_newUnif"]; if (_activeContainer isKindOf "GroundWeaponHolder") then {_oldGwh = _activeContainer; _activeContainer = createVehicle ["GroundWeaponHolder", getPosATL _unit, [], 0, "CAN_COLLIDE"]}; _activeContainer addItemCargoGlobal [(_origUnif), 1]; _newUnifItems = (itemcargo (_newUnif select 1)) + (magazinecargo (_newUnif select 1)) + (weaponcargo (_newUnif select 1)); [_unit,"AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"] remoteExec ["playMove",0]; sleep 0.2; {_activeContainer addItemCargoGlobal [_x, 1];} forEach (_newUnifItems); sleep 0.1; _unit forceAddUniform (_newUnif select 0); sleep 0.2; {(uniformContainer _unit) addItemCargoGlobal [_x, 1]} forEach (_origUnifItems); sleep 0.1; _crateCargo = itemCargo _activeContainer; _newCrateCargo = (itemCargo _activeContainer); _newCrateCargo set [(_newCrateCargo find (_newUnif select 0)),-1]; _newCrateCargo = _newCrateCargo - [-1]; sleep 0.2; clearItemCargoGlobal _activeContainer; {_activeContainer addItemCargoGlobal [_x,1]} forEach (_newCrateCargo); }; }; _return = true}; This function should cycle through all the nearby containers, returning true if a new uniform is found, and (optionally) removing that uniform and placing it on the unit, maintaining the unit's current items and placing the new uniform's original items back into the container. Any suggestions for improvements welcome! Share this post Link to post Share on other sites
Incontinentia 339 Posted January 15, 2017 Here's the script so far: _input params ["_unit",["_switchUniform",true]]; private ["_activeContainer","_newUnif","_origUnif","_newUnifItems","_droppedUniform","_gwhArray"]; _gwhArray = (nearestObjects [_unit, ["GroundWeaponHolder"],5]); if (count _gwhArray == 0) then {_gwhArray = (_unit nearEntities [["Car","Truck"],5])}; if (count _gwhArray == 0) exitWith {_return = false}; _activeContainer = (_gwhArray select 0); _origUnif = uniform _unit; _origUnifItems = uniformItems _unit; _newUnif = (((everyContainer _activeContainer) select { ( (((_x select 0) find "U_") == 0) && { !(((_x select 0) find _origUnif) == 0) || {_origUnif == ""} } && {(_x select 0) in (INC_safeUniforms + INC_incognitoUniforms)} ) }) select 0); if (isNil "_newUnif") exitWith {_return = false}; if (_switchUniform) then { [_unit,_activeContainer,_origUnifItems,_origUnif,_newUnifItems,_newUnif] spawn { params ["_unit","_activeContainer","_origUnifItems","_origUnif","_newUnifItems","_newUnif"]; _newUnifItems = (itemcargo (_newUnif select 1)) + (magazinecargo (_newUnif select 1)) + (weaponcargo (_newUnif select 1)); sleep 0.2; {_activeContainer addItemCargoGlobal [_x, 1];} forEach (_origUnifItems); sleep 0.2; _activeContainer addItemCargoGlobal [(_origUnif), 1]; sleep 0.1; _unit forceAddUniform (_newUnif select 0); {_unit addItemToUniform _x} forEach (_newUnifItems); }; }; Which does everything I need it to, except remove the new uniform. Anyone? Edit: See first post for final function. Share this post Link to post Share on other sites