Files
DayZ-Epoch/SQF/dayz_code/actions/AdvancedTrading/functions/zupa_fnc_removeWeaponsAndMagazinesCargo.sqf
ebaydayz ee3eb845a3 Remove selling backpacks from vehicles
I don't think we should allow selling backpacks from vehicles because we
can not get backpack contents.

We can only remove all backpacks with clearBackpackCargo and then add
back new empty backpacks for ones that weren't sold.

This means players may unintentionally wipe all contents of all other
backpacks in their vehicle when they only want to sell one.

Thanks @AirwavesMan for catching this.

Also made changes discussed in #1718 @oiad
2016-08-01 17:14:42 -04:00

68 lines
1.8 KiB
Plaintext

/* ----------------------------------------------------------------------------
Examples:
_result = [_backpack, ["SmokeShell","M16_AMMO"],["M16","M16","M240"], _vehInfo] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
_result == [[1,0,0,1,1,1,0],[1,0,0,1],[]]; // 1 = success, 0 = fail ->(item was not in cargo)
Author:
Zupa 2014-09-30
---------------------------------------------------------------------------- */
private ["_vehInfo","_inCargo","_object","_mags","_weaps","_normalMags","_normalWeaps","_returnVar","_returnMag","_returnWeap","_freeSpace"];
_object = _this select 0;
_mags = _this select 1;
_weaps = _this select 2;
_vehInfo = _this select 3;
_freeSpace = [_object,0,0,0,0] call Z_calcFreeSpace;
_normalMags = _freeSpace select 5;
_normalWeaps = _freeSpace select 6;
clearMagazineCargoGlobal _object;
clearWeaponCargoGlobal _object;
_returnVar = [];
_returnMag = [];
_returnWeap = [];
{
_inCargo = _normalMags find _x;
if (_inCargo > -1) then {
_normalMags set [_inCargo, "soldItem"];
_returnMag set [count(_returnMag),1];
} else {
_returnMag set [count(_returnMag),0];
};
} count _mags;
_normalMags = _normalMags - ["soldItem"];
{
_object addMagazineCargoGlobal [_x, 1];
} count _normalMags;
{
_inCargo = _normalWeaps find _x;
if (_inCargo > -1) then {
_normalWeaps set [_inCargo, "soldItem"];
_returnWeap set [count(_returnWeap),1];
} else {
_returnWeap set [count(_returnWeap),0];
};
} count _weaps;
_normalWeaps = _normalWeaps - ["soldItem"];
{
_object addWeaponCargoGlobal [_x, 1];
} count _normalWeaps;
if (count _vehInfo > 0) then {
_sell = [_vehInfo, ((_vehInfo select 0) select 4), _object] call DZE_deleteTradedVehicle;
if (_sell > 0) then {
_returnVar set [3,[1]];
};
};
_returnVar set [0,_returnMag];
_returnVar set [1,_returnWeap];
_returnVar set [2,[]];
_returnVar