Jump to content
pSiKO

how to clear the backpack content when it's into a container ??

Recommended Posts

Hi everyone,

Is it possible to empty the contents of a backpack into a container (box)?

_pos = getPosATL player;
_box = createVehicle ["Land_PlasticCase_01_small_black_F", _pos, [], 0, "CAN_COLLIDE"];
_box addBackpackCargo ["B_Kitbag_rgr_Exp",1];

// at this point the backpack is placed in the container, but the backpack is full of items (toolbox, detector and mines)

_backpack = firstBackpack _box;
clearItemCargo _backpack;

// at this point only the toolbox and the detector are removed from the backpack in the container but the mines are still present


I can't go any further ...
I try with clearBackpackCargo, clearAllItemsFromBackpack, almost everything in https://community.bistudio.com/wiki/Category:Command_Group:_Containers. without luck 😞

 


clearAllItemsFromBackpack seems like the right solution, but it doesn't work when the backpack is in a container ??


Thanks for your help

 

Happy holiday

Share this post


Link to post
Share on other sites
3 hours ago, pSiKO said:

Is it possible to empty the contents of a backpack into a container (box)?

Yes,

_backpack = firstBackpack _box;

clearWeaponCargoGlobal _backpack;
clearMagazineCargoGlobal _backpack;
clearItemCargoGlobal _backpack;

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

You might also want to spawn the crate just in front of the player, rather than inside their footprint, and remove the collision allowance so it doesn't end up inside a wall or rock.

_dir = getDir player;  
_pos = player getPos [2,_dir];  
_box = createVehicle ["Land_PlasticCase_01_small_black_F", _pos, [], 0, "NONE"];
_box setDir _dir + 90;
_box addBackpackCargo ["B_Kitbag_rgr_Exp",1];
_backpack = firstBackpack _box;
clearWeaponCargoGlobal _backpack;
clearMagazineCargoGlobal _backpack;
clearItemCargoGlobal _backpack;

In which case you could use the faster main syntax for createVehicle, though the performance gain for one spawn would be meaningless.

  • Like 2

Share this post


Link to post
Share on other sites

hi,

 

Thank you very much Mr Santa Claus !!

you both really make my day 🙂

 

thanks to you, here is the script to create a grave plus a box containing the player stuff

 

weapons are equipped with attachment

I do not use the global version deliberately (my needs) feel free to add Global call

 

//(bla, bla, trigger)
 
_unit = player;
_pos = _unit getRelPos [3, 0];

// create grave
_grave = "Land_Grave_rocks_F" createVehicle _pos;
_grave enableSimulationGlobal false;

// create grave box
_grave_dir = getDir _grave; 
_grave_box_pos = (getposASL _grave) vectorAdd ([[-1.8, 0, 0], -_grave_dir] call BIS_fnc_rotateVector2D);    
_grave_box = "Land_PlasticCase_01_small_black_F" createVehicle _grave_box_pos;
_grave_box setPosASL _grave_box_pos; 
_grave_box setDir _grave_dir; 

// clear box
clearWeaponCargo _grave_box;
clearMagazineCargo _grave_box;
clearItemCargo _grave_box;
clearBackpackCargo _grave_box;

// store player stuff in the box
// uniform
if (uniform _unit != "") then {
  _grave_box addItemCargo [(uniform _unit), 1];
  _uniform = (everyContainer _grave_box) select (count everyContainer _grave_box) - 1 select 1;
  {_uniform addItemCargo [_x, 1]} forEach (uniformItems _unit);
};

// vest
if (vest _unit != "") then {
  _grave_box addItemCargo [(vest _unit), 1];
  _vest = (everyContainer _grave_box) select (count everyContainer _grave_box) - 1 select 1;
  {_vest addItemCargo [_x, 1]} forEach (vestItems _unit);
};

_grave_box addItemCargo [(headgear _unit), 1];

// weapons + attachment
{_grave_box addWeaponWithAttachmentsCargo [_x, 1]} forEach weaponsItems _unit;
//{_grave_box addItemCargo [_x, 1]} forEach (assignedItems _unit);

// backpack
if (backpack _unit != "") then {
  _grave_box addBackpackCargo [(Backpack _unit), 1];
  _backpack = firstBackpack _grave_box;
  clearItemCargo _backpack;
  clearWeaponCargo _backpack;
  clearMagazineCargo _backpack;
  clearItemCargo _backpack;
  {_backpack addItemCargo [_x, 1]} forEach (backpackItems _unit);
};

 

so far so good, all player stuff is in the box, like it was put by hand

 

Thanks

 

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×