Add fn_swapPlayerContainer

This commit is contained in:
taggerung committed 2026-07-26 10:15:14 +00:00
1 parent c2a8743b6f
commit 3ac0b7bd7a
1 file changed
+225
+225
View File
@@ -0,0 +1,225 @@
_uniform = _this select 0;
_caller = player;
// use classnames for each, for any blank simply leave as ""
//any blank slots will use existing slots classname
//["helmet","uniform","vest","backpack"] call TAGG_fnc_VestSwap;
//example
//["H_HelmetB_grass","U_B_CombatUniform_mcam","V_PlateCarrier1_rgr",""] call TAGG_fnc_VestSwap;
////////////////////////////////////////////////////////////////////////
//HEADGEAR
////////////////////////////////////////////////////////////////////////
_newHelm = _this select 0;
_strCount = count str _newHelm;
if (_strCount < 3) then {_newHelm = headgear _caller} else {_newHelm = _this select 0;};
removeHeadgear _caller;
_caller addHeadgear _newHelm;
////////////////////////////////////////////////////////////////////////
//UNIFORM
////////////////////////////////////////////////////////////////////////
//if blank use what unit currently has
_newContainer = _this select 1;
_strCount = count str _newContainer;
if (_strCount < 3) then {_newContainer = uniform _caller} else {_newContainer = _this select 1;};
//get magazines and item arrays (nested)
_contentMagVest = getMagazineCargo uniformContainer _caller;
_contentItemVest = getItemCargo uniformContainer _caller;
//remove container and add new one
removeUniform _caller;
_caller addUniform _newContainer;
//get magazine and item classname arrays
_vestMagArray = _contentMagVest select 0;
_vestItemArray = _contentItemVest select 0;
//count how many indexes in array
_countMags = count _vestMagArray;
_countItems = count _vestItemArray;
//fill magazine loop
while {_countMags > 0} do {
//select first classname from array
_magToAdd = _vestMagArray select 0;
//select which to remove after loop
_magAmountArray = _contentMagVest select 1;
//select how many to add from array
_magAmountToAdd = _magAmountArray select 0;
//fill container
for "_i" from 1 to _magAmountToAdd do {
_caller addItemToUniform _magToAdd;
};
//remove from respective indexes
_countMags = _countMags -1;
_vestMagArray deleteAt 0;
_magAmountArray deleteAt 0;
//loop complete
};
//fill item loop
while {_countItems > 0} do {
//select first classname from array
_itemToAdd = _vestItemArray select 0;
//select which to remove after loop
_itemAmountArray = _contentitemVest select 1;
//select how many to add from array
_itemAmountToAdd = _itemAmountArray select 0;
//fill container
for "_i" from 1 to _itemAmountToAdd do{
_caller addItemToUniform _itemToAdd;
};
//remove from respective indexes
_countItems = _countItems -1;
_vestItemArray deleteAt 0;
_itemAmountArray deleteAt 0;
//loop complete
};
////////////////////////////////////////////////////////////////////////
//VEST
////////////////////////////////////////////////////////////////////////
//if blank use what unit currently has
_newContainer = _this select 2;
_strCount = count str _newContainer;
if (_strCount < 3) then {_newContainer = vest _caller} else {_newContainer = _this select 2;};
//get magazines and item arrays
_contentMagVest = getMagazineCargo vestContainer _caller;
_contentItemVest = getItemCargo vestContainer _caller;
//remove container and add new one
removeVest _caller;
_caller addVest _newContainer;
//get magazine and item classname arrays
_vestMagArray = _contentMagVest select 0;
_vestItemArray = _contentItemVest select 0;
//count how many indexes in array
_countMags = count _vestMagArray;
_countItems = count _vestItemArray;
//fill magazine loop
while {_countMags > 0} do {
//select first classname from array
_magToAdd = _vestMagArray select 0;
//select which to remove after loop
_magAmountArray = _contentMagVest select 1;
//select how many to add from array
_magAmountToAdd = _magAmountArray select 0;
//fill container
for "_i" from 1 to _magAmountToAdd do{
_caller addItemToVest _magToAdd;
};
//remove from respective indexes
_countMags = _countMags -1;
_vestMagArray deleteAt 0;
_magAmountArray deleteAt 0;
//loop complete
};
//fill item loop
while {_countItems > 0} do {
//select first classname from array
_itemToAdd = _vestItemArray select 0;
//select which to remove after loop
_itemAmountArray = _contentitemVest select 1;
//select how many to add from array
_itemAmountToAdd = _itemAmountArray select 0;
//fill container
for "_i" from 1 to _itemAmountToAdd do{
_caller addItemToVest _itemToAdd;
};
//remove from respective indexes
_countItems = _countItems -1;
_vestItemArray deleteAt 0;
_itemAmountArray deleteAt 0;
//loop complete
};
////////////////////////////////////////////////////////////////////////
//BACKPACK
////////////////////////////////////////////////////////////////////////
//if blank use what unit currently has
_newContainer = _this select 3;
_strCount = count str _newContainer;
if (_strCount < 3) then {_newContainer = backpack _caller} else {_newContainer = _this select 3;};
//get magazines and item arrays
_contentMagBackpack = getMagazineCargo backpackContainer _caller;
_contentItemBackpack = getItemCargo backpackContainer _caller;
//remove container and add new one
removeBackpack _caller;
_caller addBackpack _newContainer;
//get magazine and item classname arrays
_backpackMagArray = _contentMagbackpack select 0;
_backpackItemArray = _contentItembackpack select 0;
//count how many indexes in array
_countMags = count _backpackMagArray;
_countItems = count _backpackItemArray;
//fill magazine loop
while {_countMags > 0} do {
//select first classname from array
_magToAdd = _backpackMagArray select 0;
//select which to remove after loop
_magAmountArray = _contentMagbackpack select 1;
//select how many to add from array
_magAmountToAdd = _magAmountArray select 0;
//fill container
for "_i" from 1 to _magAmountToAdd do{
_caller addItemToVest _magToAdd;
};
//remove from respective indexes
_countMags = _countMags -1;
_backpackMagArray deleteAt 0;
_magAmountArray deleteAt 0;
//loop complete
};
//fill item loop
while {_countItems > 0} do {
//select first classname from array
_itemToAdd = _backpackItemArray select 0;
//select which to remove after loop
_itemAmountArray = _contentitembackpack select 1;
//select how many to add from array
_itemAmountToAdd = _itemAmountArray select 0;
//fill container
for "_i" from 1 to _itemAmountToAdd do{
_caller addItemToBackpack _itemToAdd;
};
//remove from respective indexes
_countItems = _countItems -1;
_backpackItemArray deleteAt 0;
_itemAmountArray deleteAt 0;
//loop complete
};