Add backpack selling to Advanced Trading

It was not possible to sell a backpack from your gear or vehicle.

Added option to sell from gear. Sell backpack from vehicle is still not
possible currently due to Arma limitations.
This commit is contained in:
ebaydayz
2016-05-05 14:55:50 -04:00
parent 2c6ef2ced3
commit fe54b78bdb
5 changed files with 51 additions and 20 deletions

View File

@@ -1,24 +1,26 @@
/**
* [_weaps,_mags,_extraText] call Z_checkArrayInConfig
* [_weaps,_mags,_extraText,_bags] call Z_checkArrayInConfig
*
* @param Array of Strings _this select 0 (_weaps) -> all weapons/items in the container
* @param Array of Strings _this select 1 (_mags) -> all magazines in the container
* @param String _this select 2 (_extraText) -> Indicator what container you are trading from
* @param Array of Strings _this select 3 (_bags) -> all backpacks in the container
*
* Fills up the sell or buy list if the item has a valid config.
**/
private ["_weaps","_mags","_extraText","_all","_total","_arrayOfTraderCat","_totalPrice","_ctrltext","_backUpText"];
private ["_weaps","_mags","_extraText","_all","_total","_arrayOfTraderCat","_totalPrice","_ctrltext","_backUpText","_bags"];
#include "defines.sqf";
_weaps = _this select 0;
_mags = _this select 1;
_extraText = _this select 2;
_bags = _this select 3;
_vehTrade = false;
if (false call Z_checkCloseVehicle) then {
_all = _weaps + _mags + [(typeOf Z_vehicle)];
_all = _weaps + _mags + _bags + [(typeOf Z_vehicle)];
_vehTrade = true;
} else {
_all = _weaps + _mags;
_all = _weaps + _mags + _bags;
};
_total = count(_all);
_arrayOfTraderCat = Z_traderData;

View File

@@ -43,7 +43,7 @@ if (!isNull _backpack) then {
};
}forEach _kinds2;
[_normalMags,_normalWeaps, typeOf _backpack] call Z_checkArrayInConfig;
[_normalMags,_normalWeaps, typeOf _backpack,[]] call Z_checkArrayInConfig;
}else{
_ctrltext = localize "STR_EPOCH_TRADE_STUPID";
ctrlSetText [Z_AT_TRADERLINE2, _ctrltext];

View File

@@ -3,13 +3,15 @@
*
* Gets all your items stored in your gear and innitiates the selling list.
**/
private ["_mags","_weaps","_skin","_formattedText"];
private ["_mags","_weaps","_skin","_formattedText","_bag","_bags"];
#include "defines.sqf";
call Z_clearLists;
Z_SellArray = [];
Z_SellableArray = [];
_mags = magazines player;
_weaps = weapons player;
_bag = unitBackpack player;
_bags = if (isNull _bag) then {[]} else {[typeOf _bag]};
_skin = typeOf player;
_pic = getText (configFile >> 'CfgVehicles' >> _skin >> 'portrait');
@@ -22,4 +24,4 @@ _formattedText = format [
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
[_weaps,_mags,localize "STR_EPOCH_YOUR_GEAR"] call Z_checkArrayInConfig;
[_weaps,_mags,localize "STR_EPOCH_YOUR_GEAR",_bags] call Z_checkArrayInConfig;

View File

@@ -31,9 +31,11 @@ if (!isNull _vehicle) then {
Z_vehicle = _vehicle;
_mags = getMagazineCargo _vehicle;
_weaps = getWeaponCargo _vehicle;
_bags = getBackpackCargo _vehicle;
_normalMags = [];
_normalWeaps = [];
_normalBags = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
@@ -54,8 +56,21 @@ if (!isNull _vehicle) then {
_counter = _counter + 1;
};
}forEach _kinds2;
// Can't sell backpacks from vehicle because there is currently no command to remove single backpacks from cargo (only clearBackpackCargo which removes all)
/*
_kinds3 = _bags select 0;
_ammmounts3 = _bags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts3 select _forEachIndex)}do{
_normalBags set [count(_normalBags),_x];
_counter = _counter + 1;
};
}forEach _kinds3;
*/
[_normalWeaps,_normalMags, typeOf _vehicle] call Z_checkArrayInConfig;
[_normalWeaps,_normalMags, typeOf _vehicle,_normalBags] call Z_checkArrayInConfig;
}else{
_ctrltext = localize "STR_EPOCH_PLAYER_245";
ctrlSetText [Z_AT_TRADERLINE2, _ctrltext];

View File

@@ -1,4 +1,4 @@
private ["_index","_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success"];
private ["_index","_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag"];
_index = count (Z_SellArray) - 1;
_tempArray = Z_SellArray;
@@ -140,24 +140,33 @@ if(_index > -1)then{
_wA = [];
_mA = [];
_vehTraded = false;
_bagTraded = false;
{
if ((_x select 1) in ["trade_any_vehicle", "trade_any_vehicle_free", "trade_any_vehicle_old", "trade_any_bicycle", "trade_any_bicycle_old", "trade_any_boat", "trade_any_boat_old"]) then {
_localResult = [_vehArray, (_x select 1)] call _deleteTradedVehicle;
if (_localResult == 1) then {_vehTraded = true;};
} else {
_localResult = [player,(_x select 0),1] call BIS_fnc_invRemove;
if(_localResult != 1)then{
if(_x select 1 == "trade_items")then{
_mA set [count(_mA),0];
if (_x select 1 == "trade_backpacks") then {
//BIS_fnc_invRemove doesn't handle backpacks
_bag = unitBackpack player;
removeBackpack player;
_localResult = if (_bag != (unitBackpack player)) then {1} else {0};
if (_localResult == 1) then {_bagTraded = true;};
} else {
_localResult = [player,(_x select 0),1] call BIS_fnc_invRemove;
if(_localResult != 1)then{
if(_x select 1 == "trade_items")then{
_mA set [count(_mA),0];
}else{
_wA set [count(_wA),0];
};
}else{
_wA set [count(_wA),0];
};
}else{
if(_x select 1 == "trade_items")then{
_mA set [count(_mA),1];
}else{
_wA set [count(_wA),1];
if(_x select 1 == "trade_items")then{
_mA set [count(_mA),1];
}else{
_wA set [count(_wA),1];
};
};
};
};
@@ -170,6 +179,9 @@ if(_index > -1)then{
if (_vehTraded) then {
_outcome set [3,[1]];
};
if (_bagTraded) then {
_outcome set [2,[1]];
};
};
_money = 0;