Advanced trading tidying, spelling fixes, private fixes and string fixes (#1716)

* Advanced trading tidying, spelling fixes, private fixes and string fixes.

Fixes snap building issue with metal floors
Fixed spelling mistakes in various scripts
Fixed formatting uglyness in various scripts
Fixed invalid private lines in various scripts
Changed Advanced trading so buying worked more like selling, You can't
select backpack if you don't have a pack nor can you select a vehicle if
you don't have a vehicle.
Removed some redundant strings from Advanced trading and changed a few
of the strings to be more englishy
Removed the ability to buy a backpack into your backpack (You cant do
this anyway)
Fixed a bug where if you had nothing in your backpack it would break the
checkArrayInConfig script so the titlebar would not refresh correctly
Removed slot counts on no backpack and no vehicle (No need for it, just
clutter)
Moved backpack/vehicle checking to z_at_getContainer.sqf

* Last part of tidyness fixes

Last part of tidyness fixes

* Actual backpack fix

Lets actually fix the buying backpack into backpack or backpack when you
already have one.

* Missing from commit

Missing from commit
This commit is contained in:
oiad
2016-07-31 02:03:00 +12:00
committed by ebaydayz
parent 1d2fc3b266
commit 7c4d25ef1a
59 changed files with 536 additions and 538 deletions

View File

@@ -1,4 +1,5 @@
private ["_player","_amount","_wealth","_newwealth", "_result"];
_player = _this select 0;
_amount = _this select 1;
_result = false;
@@ -10,4 +11,5 @@ if (_player == player) then {call player_forceSave;};
_player setVariable ["moneychanged",1,true];
_newwealth = _player getVariable[Z_MoneyVariable,0];
if (_newwealth >= _wealth) then { _result = true; };
_result

View File

@@ -1,21 +1,23 @@
private ["_player","_amount","_wealth","_newwealth", "_result"];
_player = _this select 0;
_amount = _this select 1;
_result = false;
_wealth = _player getVariable[Z_MoneyVariable,0];
if(_amount > 0)then{
if (_wealth < _amount) then {
_result = false;
if (_amount > 0) then {
if (_wealth < _amount) then {
_result = false;
} else {
_newwealth = _wealth - _amount;
_player setVariable[Z_MoneyVariable,_newwealth, true];
_player setVariable ["moneychanged",1,true];
_result = true;
// can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines
// also fourth parameter in PVDZ_plr_Save is now used for achievements
if (_player == player) then { call player_forceSave; };
};
} else {
_newwealth = _wealth - _amount;
_player setVariable[Z_MoneyVariable,_newwealth, true];
_player setVariable ["moneychanged",1,true];
_result = true;
// can't use (magazines _player), server_playerSync expects nested array with ammo counts from player_countMagazines
// also fourth parameter in PVDZ_plr_Save is now used for achievements
if (_player == player) then {call player_forceSave;};
};
}else{
_result = true;
_result = true;
};
_result

View File

@@ -1,7 +1,7 @@
private ["_selection","_return","_toBuyWeaps","_toBuyMags","_toBuyBags","_toolsToBuy","_sidearmToBuy","_primaryToBuy","_currentPrimarys"
,"_currentSec","_currentPrim","_currentTool","_p","_b","_check0","_check1","_check2","_check3","_check4","_mags","_weaps","_bags"
,"_normalBags","_normalMags","_normalWeaps","_allowedMags","_allowedPrimary","_allowedTools","_allowedSidearm","_allowedWeapons","_allowedBackpacks"
,"_totalSpace","_totalNewSpace","_counter","_parentClasses","_alreadyInBackpack","_kinds","_kinds2","_kinds3","_ammmounts","_ammmounts2","_ammmounts3",
,"_totalSpace","_totalNewSpace","_counter","_parentClasses","_alreadyInBackpack","_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3",
"_actualMags","_toolClasses","_duplicate","_quantity","_tool","_totalBagSlots"
];
_selection = Z_SellingFrom;
@@ -20,14 +20,14 @@ if (_vehiclesToBuy > 0) then {
_toolsToBuy = _toolsToBuy + _vehiclesToBuy;
};
if(_selection == 2) then{ //gear
if (_selection == 2) then { //gear
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
_allowedMags = 20 - _actualMags;
_currentPrimarys = 0;
_p = primaryWeapon player;
if ( !isNil '_p' && _p != "" ) then {
if (!isNil '_p' && _p != "") then {
_currentPrimarys = 1;
};
@@ -44,7 +44,7 @@ if(_selection == 2) then{ //gear
_currentBackpacks = 0;
_b = unitBackpack player;
if ( !isNull _b ) then {
if (!isNull _b) then {
_currentBackpacks = 1;
};
@@ -53,12 +53,12 @@ if(_selection == 2) then{ //gear
_allowedTools = 14; // 12 toolbelt + 1 Binocular + 1 NVG
_duplicate = false;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x ),true] call BIS_fnc_returnParents;
if( 'ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_allowedTools = _allowedTools - 1;
if (_x in _toolClasses) then {_duplicate = true;}; // Forbid purchasing duplicate tools into gear
}
}count (weapons player);
} count (weapons player);
{
_tool = _x;
@@ -70,32 +70,28 @@ if(_selection == 2) then{ //gear
_check2 = false;
_check3 = false;
if( _allowedPrimary >= _primaryToBuy && _allowedSidearm >= _sidearmToBuy && _allowedTools >= _toolsToBuy && !_duplicate)then{
if (_allowedPrimary >= _primaryToBuy && _allowedSidearm >= _sidearmToBuy && _allowedTools >= _toolsToBuy && !_duplicate) then {
_check1 = true;
}else{
} else {
systemChat format[localize "STR_EPOCH_TRADE_GEAR_FULL", _allowedPrimary, _allowedSidearm , _allowedTools];
};
if( _allowedMags >= _toBuyMags)then{
if (_allowedMags >= _toBuyMags) then {
_check2 = true;
}else{
} else {
systemChat format[localize "STR_EPOCH_TRADE_MAGS_FULL",_allowedMags];
};
if( _allowedBackpacks >= _toBuyBags)then{
if (_allowedBackpacks >= _toBuyBags) then {
_check3 = true;
}else{
systemChat format[localize "STR_EPOCH_TRADE_BAG_FULL",_allowedBackpacks];
};
if(_check1 && _check2 && _check3)then{
_return = true;
};
if (_check1 && _check2 && _check3) then { _return = true; };
};
if(_selection == 1) then{ //vehicle
if (_selection == 1) then { //vehicle
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
if ( !isNull Z_vehicle) then {
if (!isNull Z_vehicle) then {
_mags = getMagazineCargo Z_vehicle;
_weaps = getWeaponCargo Z_vehicle;
@@ -106,35 +102,34 @@ if(_selection == 1) then{ //vehicle
_normalBags = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts select _forEachIndex)}do{
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
}forEach _kinds;
} forEach _kinds;
_kinds2 = _weaps select 0;
_ammmounts2 = _weaps select 1;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts2 select _forEachIndex)}do{
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
}forEach _kinds2;
} forEach _kinds2;
_kinds3 = _bags select 0;
_ammmounts3 = _bags select 1;
_amounts3 = _bags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts3 select _forEachIndex)}do{
while{_counter < (_amounts3 select _forEachIndex)} do {
_normalBags set [count(_normalBags),_x];
_counter = _counter + 1;
};
}forEach _kinds3;
} forEach _kinds3;
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxWeapons') - count(_normalWeaps);
_allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxMagazines') - count(_normalMags);
@@ -145,27 +140,26 @@ if(_selection == 1) then{ //vehicle
_check2 = false;
_check3 = false;
if( _allowedWeapons >= ( _toBuyWeaps + _toolsToBuy ) )then{
if (_allowedWeapons >= (_toBuyWeaps + _toolsToBuy)) then {
_check1 = true;
}else{
} else {
systemChat format[localize "STR_EPOCH_TRADE_VEHICLE_WEPS", _allowedWeapons];
};
if( _allowedMags >= _toBuyMags)then{
if (_allowedMags >= _toBuyMags) then {
_check2 = true;
}else{
} else {
systemChat format[localize "STR_EPOCH_TRADE_VEHICLE_MAGS", _allowedMags];
};
if( _allowedBackpacks >= _toBuyBags)then{
if (_allowedBackpacks >= _toBuyBags) then {
_check3 = true;
}else{
} else {
systemChat format[localize "STR_EPOCH_TRADE_VEHICLE_BAGS", _allowedBackpacks];
};
if(_check1 && _check2 && _check3)then{
_return = true;
};
if (_check1 && _check2 && _check3) then { _return = true; };
};
if(_selection == 0) then{ //backpack
if (_selection == 0) then { //backpack
_allowedWeapons = 0;
_allowedMags = 0;
_allowedBackpacks = 0;
@@ -185,41 +179,39 @@ if(_selection == 0) then{ //backpack
_normalWeaps = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts select _forEachIndex)} do {
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags), _x];
_counter = _counter + 1;
};
}forEach _kinds;
} forEach _kinds;
_kinds2 = _weaps select 0;
_ammmounts2 = _weaps select 1;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts2 select _forEachIndex)} do {
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps), _x];
_counter = _counter + 1;
};
}forEach _kinds2;
} forEach _kinds2;
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxWeapons') - count(_normalWeaps);
_totalBagSlots = getNumber (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'transportMaxMagazines');
_allowedMags = _totalBagSlots - count(_normalMags);
_currentPrim = 0;
_currentSec = 0;
_currentTool = 0;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x ),true] call BIS_fnc_returnParents;
if( 'ItemCore' in _parentClasses || 'Binocular' in _parentClasses ) then {
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_currentTool = _currentTool + 1;
} else {
if( 'PistolCore' in _parentClasses )then {
if ('PistolCore' in _parentClasses) then {
_currentSec = _currentSec + 1;
} else {
_currentPrim = _currentPrim + 1;
@@ -227,15 +219,14 @@ if(_selection == 0) then{ //backpack
};
} count _normalWeaps;
_alreadyInBackpack = (10 * _currentPrim) + (5 * _currentSec) + _currentTool + count(_normalMags);
_totalNewSpace = 10 * _primaryToBuy + 5 * _sidearmToBuy + _toolsToBuy + _toBuyMags;
_totalSpace = _alreadyInBackpack + _totalNewSpace;
}else {
systemChat localize "STR_EPOCH_TRADE_NEED_BAG";
} else {
systemChat localize "STR_EPOCH_TRADE_NO_BACKPACK";
};
_check1 = false;
@@ -243,31 +234,27 @@ if(_selection == 0) then{ //backpack
_check3 = false;
_check4 = false;
if( _allowedWeapons >= _toBuyWeaps)then{
if (_allowedWeapons >= _toBuyWeaps) then {
_check1 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_BAG_WEPS", _allowedWeapons];
};
if( _allowedMags >= _toBuyMags)then{
if (_allowedMags >= _toBuyMags) then {
_check2 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_BAG_MAGS", _allowedMags];
};
if( _allowedBackpacks >= _toBuyBags)then{
if (_allowedBackpacks >= _toBuyBags) then {
_check3 = true;
} else {
systemChat format[localize "STR_EPOCH_TRADE_BAG_BAGS", _allowedBackpacks ];
};
if( _totalSpace <= _totalBagSlots)then{
if (_totalSpace <= _totalBagSlots) then {
_check4 = true;
}else{
} else {
systemChat localize "STR_EPOCH_TRADE_BACKPACK_FULL";
};
if(_check0 && _check1 && _check2 && _check3 && _check4)then{
_return = true;
};
if (_check0 && _check1 && _check2 && _check3 && _check4) then { _return = true; };
};
_return;
_return;

View File

@@ -1,5 +1,5 @@
private ["_magazinesToBuy", "_weaponsToBuy", "_backpacksToBuy", "_toolsToBuy", "_sidearmToBuy", "_primaryToBuy", "_priceToBuy"
,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog","_tCost","_bTotal"
,"_enoughMoney", "_myMoney", "_canBuy", "_moneyInfo","_count","_success","_backpack","_toolClasses","_itemsToLog","_tCost","_bTotal","_backpack"
];
if (count Z_BuyingArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BUY_NO_ITEMS"; };
@@ -11,21 +11,22 @@ _toolsToBuy = 0;
_sidearmToBuy = 0;
_primaryToBuy = 0;
_vehiclesToBuy = 0;
_priceToBuy = 0;
_backpack = unitBackpack player;
_toolClasses = [];
_itemsToLog = [[],[],[],"buy"];
if (Z_SingleCurrency) then {
{
if( _x select 1 == "trade_weapons")then{
if (_x select 1 == "trade_weapons") then {
_parentClasses = [(configFile >> "CfgWeapons" >> (_x select 0)),true] call BIS_fnc_returnParents;
if( 'ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_toolsToBuy = _toolsToBuy + (_x select 9);
_toolClasses set [count _toolClasses,(_x select 0)];
} else {
_weaponsToBuy = _weaponsToBuy + (_x select 9);
if('PistolCore' in _parentClasses)then {
if ('PistolCore' in _parentClasses) then {
_sidearmToBuy = _sidearmToBuy + (_x select 9);
} else {
_primaryToBuy = _primaryToBuy + (_x select 9); // _ammount
@@ -33,15 +34,15 @@ if (Z_SingleCurrency) then {
};
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
};
if( _x select 1 == "trade_items")then{
if (_x select 1 == "trade_items") then {
_magazinesToBuy = _magazinesToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2));
};
if( _x select 1 == "trade_backpacks")then{
if (_x select 1 == "trade_backpacks") then {
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount
};
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{
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 {
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 9)*(_x select 2)); // _price * _amount
};
@@ -51,14 +52,14 @@ if (Z_SingleCurrency) then {
} count Z_BuyingArray;
} else {
{
if( _x select 1 == "trade_weapons")then{
if (_x select 1 == "trade_weapons") then {
_parentClasses = [(configFile >> "CfgWeapons" >> (_x select 0)),true] call BIS_fnc_returnParents;
if( 'ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
if ('ItemCore' in _parentClasses || 'Binocular' in _parentClasses) then {
_toolsToBuy = _toolsToBuy + (_x select 9);
_toolClasses set [count _toolClasses,(_x select 0)];
} else {
_weaponsToBuy = _weaponsToBuy + (_x select 9);
if('PistolCore' in _parentClasses)then {
if ('PistolCore' in _parentClasses) then {
_sidearmToBuy = _sidearmToBuy + (_x select 9);
} else {
_primaryToBuy = _primaryToBuy + (_x select 9);
@@ -66,15 +67,15 @@ if (Z_SingleCurrency) then {
};
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9)); // _worth * _price * _amount
};
if( _x select 1 == "trade_items")then{
if (_x select 1 == "trade_items") then {
_magazinesToBuy = _magazinesToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 11) *(_x select 2)*(_x select 9));
};
if( _x select 1 == "trade_backpacks")then{
if (_x select 1 == "trade_backpacks") then {
_backpacksToBuy = _backpacksToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9));
};
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{
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 {
_vehiclesToBuy = _vehiclesToBuy + (_x select 9) ;
_priceToBuy = _priceToBuy + ((_x select 11)*(_x select 2)*(_x select 9));
};
@@ -103,8 +104,11 @@ if (Z_SingleCurrency) then {
_enoughMoney = _moneyInfo select 0;
};
if(_enoughMoney) then {
if(_canBuy) then {
if (Z_SellingFrom == 0 && _backpacksToBuy >= 1) exitWith { systemChat localize "STR_EPOCH_TRADE_BAG_BAGS"; }; //backpack
if (Z_SellingFrom == 2 && !isNull _backpack) exitWith { systemChat localize "STR_EPOCH_TRADE_HAVE_BACKPACK"; }; //gear
if (_enoughMoney) then {
if (_canBuy) then {
_bTotal = 0;
_buyVehicle = {
private "_location";
@@ -125,7 +129,7 @@ if(_enoughMoney) then {
_dir = round(random 360);
_helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100];
if(count _helipad > 0) then {
if (count _helipad > 0) then {
_location = (getPosATL (_helipad select 0));
} else {
_location = [([player] call FNC_GetPos),0,20,1,0,2000,0] call BIS_fnc_findSafePos;
@@ -146,16 +150,16 @@ if(_enoughMoney) then {
closeDialog 2;
if(Z_SellingFrom == 0) then { //backpack
if (Z_SellingFrom == 0) then { //backpack
_backpack = unitBackpack player;
{
if( _x select 1 == "trade_weapons")then{
if (_x select 1 == "trade_weapons") then {
_backpack addWeaponCargoGlobal [_x select 0, _x select 9];
};
if( _x select 1 == "trade_items")then{
if (_x select 1 == "trade_items") then {
_backpack addMagazineCargoGlobal [_x select 0, _x select 9];
};
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{
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 {
_item2Add = [(_x select 0), (_x select 1)] call _buyVehicle;
if (_item2Add != "0") then {
_backpack addWeaponCargoGlobal [_item2Add, 1];
@@ -166,18 +170,18 @@ if(_enoughMoney) then {
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_BACKPACK",_bTotal];
};
if(Z_SellingFrom == 1) then { //vehicle
if (Z_SellingFrom == 1) then { //vehicle
{
if( _x select 1 == "trade_weapons")then{
if (_x select 1 == "trade_weapons") then {
Z_vehicle addWeaponCargoGlobal [_x select 0, _x select 9];
};
if( _x select 1 == "trade_items")then{
if (_x select 1 == "trade_items") then {
Z_vehicle addMagazineCargoGlobal [_x select 0, _x select 9];
};
if( _x select 1 == "trade_backpacks")then{
if (_x select 1 == "trade_backpacks") then {
Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9];
};
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{
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 {
_item2Add = [(_x select 0), (_x select 1)] call _buyVehicle;
if (_item2Add != "0") then {
Z_vehicle addWeaponCargoGlobal [_item2Add, 1];
@@ -188,26 +192,26 @@ if(_enoughMoney) then {
systemChat format[localize "STR_EPOCH_TRADE_BUY_IN_VEHICLE",_bTotal,typeOf Z_vehicle];
};
if(Z_SellingFrom == 2) then { //gear
if (Z_SellingFrom == 2) then { //gear
{
if( _x select 1 == "trade_weapons") then {
if (_x select 1 == "trade_weapons") then {
_count = 0;
while{ _count < (_x select 9)}do{
while { _count < (_x select 9)} do {
player addWeapon (_x select 0);
_count = _count + 1;
};
};
if( _x select 1 == "trade_items" ) then {
if (_x select 1 == "trade_items") then {
_count = 0;
while{ _count < (_x select 9)} do {
while { _count < (_x select 9)} do {
player addMagazine (_x select 0);
_count = _count + 1;
};
};
if( _x select 1 == "trade_backpacks")then{
if (_x select 1 == "trade_backpacks") then {
player addBackpack (_x select 0);
};
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{
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 {
_item2Add = [(_x select 0), (_x select 1)] call _buyVehicle;
if (_item2Add != "0") then {
player addWeapon _item2Add;
@@ -239,7 +243,7 @@ if(_enoughMoney) then {
systemChat localize "STR_EPOCH_TRADE_CONTAINER_FULL";
};
} else {
if( Z_SingleCurrency) then {
if (Z_SingleCurrency) then {
systemChat format[localize "STR_EPOCH_TRADE_NEED_COINS",_priceToBuy,CurrencyName];
} else {
systemChat localize "STR_EPOCH_TRADE_NEED_MONEY";

View File

@@ -1,4 +1,5 @@
private ["_arrayOfTraderCat","_counter","_cat","_cfgtraders","_y","_type","_buy","_sell","_pic","_text","_worth","_buyCurrency","_sellCurrency","_ignore","_categoryNumber"];
call Z_clearBuyList;
Z_BuyableArray = [];
_arrayOfTraderCat = Z_traderData;
@@ -17,7 +18,7 @@ _counter = 0;
_y = _cfgtraders select _i;
if (isClass _y) then
{
_y = configName (_y );
_y = configName (_y);
_type = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type");
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
@@ -32,20 +33,20 @@ _counter = 0;
if (_y == "bloodBagONEG") then {_y = "ItemBloodbag";} else {_ignore = true;};
};
if(_type == "trade_items")then{
if (_type == "trade_items") then {
_pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture');
_text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName');
};
if(_type == "trade_weapons")then{
if (_type == "trade_weapons") then {
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
};
if(_type in ["trade_backpacks", "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{
if (_type in ["trade_backpacks", "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 {
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
};
if(!Z_SingleCurrency) then {
if (!Z_SingleCurrency) then {
_buyCurrency = _buy select 1;
_sellCurrency = _sell select 1,
_part = (configFile >> "CfgMagazines" >> _buyCurrency);
@@ -53,7 +54,7 @@ _counter = 0;
if (_worth == 0) then {
_worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency);
};
}else{
} else {
_buyCurrency = CurrencyName;
_sellCurrency = CurrencyName;
};
@@ -64,7 +65,7 @@ _counter = 0;
};
};
};
}forEach _arrayOfTraderCat;
} forEach _arrayOfTraderCat;
Z_CategoryView = false;
Z_Selling = true; // flipped in ChangeBuySell
@@ -72,4 +73,4 @@ call Z_ChangeBuySell;
Z_OriginalBuyableArray = [] + Z_BuyableArray;
call Z_fillBuyableList;
call Z_calcPrice;
call Z_calcPrice;

View File

@@ -3,46 +3,46 @@
*
* Calculate the total price for single currency.
**/
private ["_sellPrice","_ctrltext","_bTotal"];
private ["_sellPrice","_ctrlText","_bTotal"];
#include "defines.hpp"
_bTotal = 0;
_sellPrice = 0;
if(Z_SingleCurrency) then {
_ctrltext = '';
if(Z_Selling)then{
if (Z_SingleCurrency) then {
_ctrlText = "";
if (Z_Selling) then {
{
_sellPrice = _sellPrice + (_x select 2);
}count Z_SellArray;
_ctrltext = format["%1 %2", _sellPrice , CurrencyName];
_sellPrice = _sellPrice + (_x select 2);
} count Z_SellArray;
_ctrlText = format["%1 %2", _sellPrice , CurrencyName];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_SELLING", count Z_SellArray];
} else {
{
_sellPrice = _sellPrice + ((_x select 2) * (_x select 9));
_bTotal = _bTotal + (_x select 9);
}count Z_BuyingArray;
_ctrltext = format["%1 %2", _sellPrice , CurrencyName];
_sellPrice = _sellPrice + ((_x select 2) * (_x select 9));
_bTotal = _bTotal + (_x select 9);
} count Z_BuyingArray;
_ctrlText = format["%1 %2", _sellPrice , CurrencyName];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_BUYING", _bTotal];
};
ctrlSetText [Z_AT_PRICEDISPLAY, _ctrltext];
ctrlSetText [Z_AT_PRICEDISPLAY, _ctrlText];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_PRICEINFO) ctrlSetStructuredText parseText '';
} else {
if(Z_Selling)then {
_ctrltext = "";
if (Z_Selling) then {
_ctrlText = "";
{
_sellPrice = _sellPrice + ((_x select 2) * (_x select 11));
}count Z_SellArray;
_ctrltext = _sellPrice call Z_calcDefaultCurrency;
_sellPrice = _sellPrice + ((_x select 2) * (_x select 11));
} count Z_SellArray;
_ctrlText = _sellPrice call Z_calcDefaultCurrency;
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_SELLING", count Z_SellArray];
} else {
{
_sellPrice = _sellPrice + ((_x select 2) * (_x select 11) * (_x select 9));
_bTotal = _bTotal + (_x select 9);
}count Z_BuyingArray;
_ctrltext = _sellPrice call Z_calcDefaultCurrency;
_sellPrice = _sellPrice + ((_x select 2) * (_x select 11) * (_x select 9));
_bTotal = _bTotal + (_x select 9);
} count Z_BuyingArray;
_ctrlText = _sellPrice call Z_calcDefaultCurrency;
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_RIGHTLISTTITLE) ctrlSetText format ["%1 (%2 items)", localize "STR_EPOCH_TRADE_BUYING", _bTotal];
};
ctrlSetText [Z_AT_PRICEDISPLAY, ''];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_PRICEINFO) ctrlSetStructuredText parseText _ctrltext;
ctrlSetText [Z_AT_PRICEDISPLAY, ''];
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_PRICEINFO) ctrlSetStructuredText parseText _ctrlText;
};

View File

@@ -5,7 +5,7 @@ private["_selection","_returnArray","_allowedMags","_allowedWeapons","_allowedBa
_selection = _this select 0;
_returnArray = [0,0,0];
if(_selection == 2) then{ //gear
if (_selection == 2) then { //gear
_actualMags = {!(_x in MeleeMagazines)} count (magazines player);
_allowedMags = 20 - _actualMags;
// 12 toolbelt + 1 Binoculars + 1 NVG + 1 Pistol + 1 Primary (onBack isn't counted in weapons player)
@@ -24,7 +24,7 @@ if(_selection == 2) then{ //gear
_returnArray = [_allowedMags, _allowedWeapons, _allowedBackpacks];
};
if(_selection == 1) then{ //vehicle
if (_selection == 1) then { //vehicle
_allowedMags = 0;
_allowedWeapons = 0;
_allowedBackpacks = 0;
@@ -46,21 +46,21 @@ if(_selection == 1) then{ //vehicle
{
_vehicleMagazines = _vehicleMagazines + _x;
}count ( _tempMagazinesArray select 1);
} count (_tempMagazinesArray select 1);
_tempWeaponsArray = getWeaponCargo Z_vehicle;
{
_vehicleWeapons = _vehicleWeapons + _x;
}count ( _tempWeaponsArray select 1);
} count (_tempWeaponsArray select 1);
_tempBackpackArray = getBackpackCargo Z_vehicle;
{
_vehicleBackpacks = _vehicleBackpacks + _x;
}count ( _tempBackpackArray select 1);
} count (_tempBackpackArray select 1);
_allowedWeapons = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxWeapons');
_allowedMags = getNumber (configFile >> 'CfgVehicles' >> (typeOf Z_vehicle) >> 'transportMaxMagazines');
@@ -68,7 +68,7 @@ if(_selection == 1) then{ //vehicle
};
_returnArray = [_allowedMags - _vehicleMagazines, _allowedWeapons - _vehicleWeapons, _allowedBackpacks - _vehicleBackpacks];
};
if(_selection == 0) then{ //backpack
if (_selection == 0) then { //backpack
_allowedBackpacks = 0;
_totalBagSlots = 0;
_alreadyInBackpack = 0;
@@ -113,7 +113,7 @@ if(_selection == 0) then{ //backpack
_currentSec = 0;
_currentTool = 0;
{
_parentClasses = [(configFile >> "CfgWeapons" >> _x ),true] call BIS_fnc_returnParents;
_parentClasses = [(configFile >> "CfgWeapons" >> _x),true] call BIS_fnc_returnParents;
if ('ItemCore' in _parentClasses or 'Binocular' in _parentClasses) then {
_currentTool = _currentTool + 1;
} else {

View File

@@ -1,4 +1,4 @@
private ['_worth', '_total_currency','_return','_part','_totalToPay','_inventoryMoney','_backpackMoney',"_kinds","_kinds2","_kinds3","_ammmounts","_ammmounts2","_ammmounts3"
private ['_worth', '_total_currency','_return','_part','_totalToPay','_inventoryMoney','_backpackMoney',"_kinds","_kinds2","_kinds3","_amounts","_amounts2","_amounts3"
,"_vehicleMoney"];
_totalToPay = _this;
@@ -24,20 +24,20 @@ _inventoryMoney = [];
_return set [1, _inventoryMoney];
if( Z_AllowTakingMoneyFromBackpack ) then {
if (Z_AllowTakingMoneyFromBackpack) then {
_backpackPlayer = unitBackpack player;
if (!isNull _backpackPlayer) then {
_mags = getMagazineCargo _backpackPlayer;
_backpackMoney = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_part = (configFile >> "CfgMagazines" >> _x);
_worth = (_part >> "worth");
if isNumber (_worth) then {
_total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex));
_total_currency = _total_currency + (getNumber(_worth) * (_amounts select _forEachIndex));
_counter = 0 ;
while{_counter < (_ammmounts select _forEachIndex)} do {
while {_counter < (_amounts select _forEachIndex)} do {
_backpackMoney set [count(_backpackMoney),_x];
_counter = _counter + 1;
};
@@ -45,9 +45,9 @@ if( Z_AllowTakingMoneyFromBackpack ) then {
_findGem = DZE_GemList find _x;
if (_findGem >= 0) then {
_worth = DZE_GemWorthList select _findGem;
_total_currency = _total_currency + (_worth * (_ammmounts select _forEachIndex));
_total_currency = _total_currency + (_worth * (_amounts select _forEachIndex));
_counter = 0 ;
while{_counter < (_ammmounts select _forEachIndex)} do {
while {_counter < (_amounts select _forEachIndex)} do {
_backpackMoney set [count(_backpackMoney),_x];
_counter = _counter + 1;
};
@@ -58,19 +58,19 @@ if( Z_AllowTakingMoneyFromBackpack ) then {
};
};
if( Z_AllowTakingMoneyFromVehicle ) then {
if (Z_AllowTakingMoneyFromVehicle) then {
if (!isNull Z_vehicle) then {
_mags = getMagazineCargo Z_vehicle;
_vehicleMoney = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_part = (configFile >> "CfgMagazines" >> _x);
_worth = (_part >> "worth");
if isNumber (_worth) then {
_total_currency = _total_currency + ( getNumber(_worth) * (_ammmounts select _forEachIndex));
_total_currency = _total_currency + (getNumber(_worth) * (_amounts select _forEachIndex));
_counter = 0 ;
while{_counter < ( _ammmounts select _forEachIndex)}do{
while {_counter < (_amounts select _forEachIndex)} do {
_vehicleMoney set [count(_vehicleMoney),_x];
_counter = _counter + 1;
};
@@ -78,9 +78,9 @@ if( Z_AllowTakingMoneyFromVehicle ) then {
_findGem = DZE_GemList find _x;
if (_findGem >= 0) then {
_worth = DZE_GemWorthList select _findGem;
_total_currency = _total_currency + (_worth * (_ammmounts select _forEachIndex));
_total_currency = _total_currency + (_worth * (_amounts select _forEachIndex));
_counter = 0 ;
while{_counter < (_ammmounts select _forEachIndex)} do {
while {_counter < (_amounts select _forEachIndex)} do {
_backpackMoney set [count(_backpackMoney),_x];
_counter = _counter + 1;
};
@@ -91,7 +91,7 @@ if( Z_AllowTakingMoneyFromVehicle ) then {
};
};
if ( _totalToPay <= _total_currency) then {
if (_totalToPay <= _total_currency) then {
_return set [0, true];
_return set [4, _total_currency];
};

View File

@@ -6,7 +6,7 @@ if (Z_Selling) then {
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_FILTERBUTTON) ctrlSetText localize "STR_UI_FILTER";
{ctrlShow [_x,true];} forEach [Z_AT_SELLABLELIST,Z_AT_SELLINGLIST,Z_AT_SELLBUTTON,Z_AT_ADDSELLITEMBUTTON,Z_AT_ADDALLSELLITEMBUTTON,Z_AT_REMOVESELLITEMBUTTON,Z_AT_REMOVEALLSELLITEMBUTTON,Z_AT_FILTERBOX]; // show
{ctrlShow [_x,false];} forEach [Z_AT_BUYABLELIST,Z_AT_BUYINGLIST,Z_AT_BUYBUTTON,Z_AT_ADDBUYITEMBUTTON,Z_AT_BUYINGAMOUNT,Z_AT_REMOVEBUYITEMBUTTON,Z_AT_REMOVEALLBUYITEMBUTTON,Z_AT_SLOTSDISPLAY,Z_AT_BACKBUTTON]; // hide
}else{
} else {
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SELLBUYTOGGLE) ctrlSetText localize "STR_EPOCH_PLAYER_292";
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_FILTERBUTTON) ctrlSetText localize "STR_UI_FILTER";
{ctrlShow [_x,true];} forEach [Z_AT_BUYABLELIST,Z_AT_BUYINGLIST,Z_AT_BUYBUTTON,Z_AT_ADDBUYITEMBUTTON,Z_AT_BUYINGAMOUNT,Z_AT_REMOVEBUYITEMBUTTON,Z_AT_REMOVEALLBUYITEMBUTTON,Z_AT_SLOTSDISPLAY,Z_AT_FILTERBOX,Z_AT_BACKBUTTON]; // show
@@ -32,4 +32,4 @@ if (Z_ResetContainer) then {
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText "";
ctrlSetText [Z_AT_TRADERLINE2, " "];
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_SELLING_ALL"];
};
};

View File

@@ -8,7 +8,7 @@
*
* Fills up the sell or buy list if the item has a valid config.
**/
private ["_weaps","_mags","_extraText","_all","_total","_arrayOfTraderCat","_totalPrice","_ctrltext","_backUpText","_bags"];
private ["_weaps","_mags","_extraText","_all","_arrayOfTraderCat","_totalPrice","_backUpText","_bags"];
#include "defines.hpp"
_weaps = _this select 0;
@@ -16,13 +16,14 @@ _mags = _this select 1;
_extraText = _this select 2;
_bags = _this select 3;
_vehTrade = false;
if (false call Z_checkCloseVehicle) then {
_all = _weaps + _mags + _bags + [(typeOf Z_vehicle)];
_vehTrade = true;
} else {
_all = _weaps + _mags + _bags;
};
_total = count(_all);
_arrayOfTraderCat = Z_traderData;
_HasKeyCheck = {
_obj = _this select 0;
@@ -44,92 +45,80 @@ _HasKeyCheck = {
_keyFound;
};
_totalPrice = 0;
if(_total > 0)then{
{
_y = _x;
{
_y = _x;
{
private ["_cat","_excists","_pic","_text","_type","_sell","_buy","_buyCurrency","_sellCurrency","_worth"];
_cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)];
if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then {
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
private ["_cat","_exists","_pic","_text","_type","_sell","_buy","_buyCurrency","_sellCurrency","_worth"];
_cat = format["Category_%1",(_arrayOfTraderCat select _forEachIndex select 1)];
if (isNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")) then {
_cat = format["Category_%1",getNumber (missionConfigFile >> "CfgTraderCategory" >> _cat >> "duplicate")];
};
_exists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y);
if (_exists) exitWith {
_pic = "";
_text = "";
_type = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type");
_sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
switch (true) do {
case (_type == "trade_items") :
{
_pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture');
_text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName');
};
case (_type == "trade_weapons") :
{
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
};
case (_type in ["trade_backpacks", "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"]) :
{
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
};
};
_excists = isClass(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y );
if(_excists)exitWith{
_pic = "";
_text = "";
_type = getText(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "type");
_sell = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "sell");
_buy = getArray(missionConfigFile >> "CfgTraderCategory" >> _cat >> _y >> "buy");
switch (true) do {
case (_type == "trade_items") :
{
_pic = getText (configFile >> 'CfgMagazines' >> _y >> 'picture');
_text = getText (configFile >> 'CfgMagazines' >> _y >> 'displayName');
};
case (_type == "trade_weapons") :
{
_pic = getText (configFile >> 'CfgWeapons' >> _y >> 'picture');
_text = getText (configFile >> 'CfgWeapons' >> _y >> 'displayName');
};
case (_type in ["trade_backpacks", "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"]) :
{
_pic = getText (configFile >> 'CfgVehicles' >> _y >> 'picture');
_text = getText (configFile >> 'CfgVehicles' >> _y >> 'displayName');
};
};
if( isNil '_text')then{
_text = _y;
if (isNil '_text') then { _text = _y; };
_HasKey = true;
if (_vehTrade && {(typeOf Z_vehicle) == _y}) then {
if (!(_type in ["trade_any_bicycle", "trade_any_bicycle_old", "trade_any_vehicle_free"]) && DZE_SaleRequiresKey) then {
_HasKey = [Z_vehicle, _all] call _HasKeyCheck;
};
_HasKey = true;
if (_vehTrade && {(typeOf Z_vehicle) == _y}) then {
if (!(_type in ["trade_any_bicycle", "trade_any_bicycle_old", "trade_any_vehicle_free"]) && DZE_SaleRequiresKey) then {
_HasKey = [Z_vehicle, _all] call _HasKeyCheck;
};
};
if (!_HasKey) exitWith {};
_worth = 0;
if(!Z_SingleCurrency) then {
_buyCurrency = _buy select 1;
_sellCurrency = _sell select 1;
_part = (configFile >> "CfgMagazines" >> _sellCurrency);
_worth = getNumber(_part >> "worth");
if (_worth == 0) then {
_worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency);
};
}else{
_buyCurrency = CurrencyName;
_sellCurrency = CurrencyName;
};
Z_SellableArray set [count(Z_SellableArray) , [_y, _type, _sell select 0, _text, _pic, _forEachIndex, _buy select 0, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]];
_totalPrice = _totalPrice + (_sell select 0);
};
}forEach _arrayOfTraderCat;
}count _all;
if (!_HasKey) exitWith {};
Z_OriginalSellableArray = [] + Z_SellableArray;
_worth = 0;
_backUpText = _extraText;
if (!Z_SingleCurrency) then {
_buyCurrency = _buy select 1;
_sellCurrency = _sell select 1;
_part = (configFile >> "CfgMagazines" >> _sellCurrency);
_worth = getNumber(_part >> "worth");
if (_worth == 0) then { _worth = DZE_GemWorthList select (DZE_GemList find _buyCurrency); };
} else {
_buyCurrency = CurrencyName;
_sellCurrency = CurrencyName;
};
if(Z_SellingFrom != 2)then{
_extraText = getText (configFile >> 'CfgVehicles' >> _extraText >> 'displayName');
};
if (isNil '_extraText')then{
_extraText = _backUpText;
};
Z_SellableArray set [count(Z_SellableArray) , [_y, _type, _sell select 0, _text, _pic, _forEachIndex, _buy select 0, _sellCurrency, _buyCurrency, 0 ,_cat, _worth]];
_totalPrice = _totalPrice + (_sell select 0);
};
} forEach _arrayOfTraderCat;
} count _all;
if (Z_SingleCurrency) then {
_ctrltext = format[localize "STR_EPOCH_TRADE_OFFER", _totalPrice,CurrencyName];
ctrlSetText [Z_AT_TRADERLINE2, _ctrltext];
} else {
ctrlSetText [Z_AT_TRADERLINE2, ''];
};
Z_OriginalSellableArray = [] + Z_SellableArray;
_ctrltext = format[localize "STR_EPOCH_TRADE_ACCEPT", count(Z_SellableArray) , _extraText];
ctrlSetText [Z_AT_TRADERLINE1, _ctrltext];
_backUpText = _extraText;
call Z_fillSellList;
if (Z_SellingFrom != 2) then { _extraText = getText (configFile >> 'CfgVehicles' >> _extraText >> 'displayName'); };
if (isNil '_extraText') then { _extraText = _backUpText; };
if (Z_SingleCurrency) then {
ctrlSetText [Z_AT_TRADERLINE2, format[localize "STR_EPOCH_TRADE_OFFER", _totalPrice,CurrencyName]];
} else {
ctrlSetText [Z_AT_TRADERLINE2, ''];
};
ctrlSetText [Z_AT_TRADERLINE1, format[localize "STR_EPOCH_TRADE_ACCEPT", count(Z_SellableArray) , _extraText]];
call Z_fillSellList;

View File

@@ -1,4 +1,5 @@
private ["_vehicle","_list","_result","_pos"];
Z_vehicle = objNull;
_vehicle = objNull;
_pos = [player] call FNC_GetPos;
@@ -7,9 +8,10 @@ _list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance];
if (!isNull _x && local _x && alive _x) then {
_vehicle = _x;
};
}count _list;
} count _list;
_result = false;
if(!isNull _vehicle)then{
if (!isNull _vehicle) then {
Z_vehicle = _vehicle;
_result = true;
if (_this) then { // Set trade title, don't set on menu start up since gear is selected initially.
@@ -21,4 +23,5 @@ if(!isNull _vehicle)then{
};
};
};
_result

View File

@@ -4,5 +4,6 @@
* Clears the visual listbox of items you could buy.
**/
#include "defines.hpp"
lbClear Z_AT_BUYABLELIST;
lbSetCurSel [Z_AT_BUYABLELIST,-1]; // clear
lbSetCurSel [Z_AT_BUYABLELIST,-1]; // clear

View File

@@ -3,6 +3,6 @@
*
* Clears the visual listbox of items you were going to buy.
**/
#include "defines.hpp"
lbClear Z_AT_BUYINGLIST;
lbClear Z_AT_BUYINGLIST;

View File

@@ -4,5 +4,6 @@
* Clears the visual listbox of items you were going to sell and could be selled.
**/
#include "defines.hpp"
lbClear Z_AT_SELLABLELIST;
lbClear Z_AT_SELLINGLIST;
lbClear Z_AT_SELLINGLIST;

View File

@@ -4,4 +4,5 @@
* Clears the visual listbox of items you were going to sell.
**/
#include "defines.hpp"
lbClear Z_AT_SELLABLELIST;
lbClear Z_AT_SELLABLELIST;

View File

@@ -1,7 +1,4 @@
private ["_item","_picture","_class","_display","_transportMaxWeapons","_transportMaxMagazines","_transportmaxBackpacks","_buyPrice","_sellPrice"
,"_buyCurrency","_sellCurrency","_formattedText","_picBuy","_picSell"
];
private ["_item","_picture","_class","_display","_transportMaxWeapons","_transportMaxMagazines","_transportmaxBackpacks","_buyPrice","_sellPrice","_buyCurrency","_sellCurrency","_formattedText","_picBuy","_picSell"];
#include "defines.hpp"
_item = _this select 0;
@@ -15,27 +12,27 @@ _transportMaxMagazines = 0;
_buyPrice = 0;
_sellPrice = 0;
if(Z_Selling)then{
if (Z_Selling) then {
_buyPrice = _item select 6;
_buyCurrency = _item select 8;
_sellPrice = _item select 2;
_sellCurrency = _item select 7;
}else{
} else {
_buyPrice = _item select 2;
_buyCurrency = _item select 7;
_sellPrice = _item select 6;
_sellCurrency = _item select 8;
};
if ( isNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxWeapons')) then {
if (isNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxWeapons')) then {
_transportMaxWeapons = getNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxWeapons');
};
if ( isNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxMagazines')) then {
if (isNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxMagazines')) then {
_transportMaxMagazines = getNumber (configFile >> 'CfgVehicles' >> _class >> 'transportMaxMagazines');
};
if ( Z_SingleCurrency ) then {
if (Z_SingleCurrency) then {
_buyCurrency = CurrencyName;
_sellCurrency = CurrencyName;
_formattedText = format [

View File

@@ -1,11 +1,13 @@
private ['_item','_picture','_class','_display','_buyPrice','_sellPrice','_formattedText','_buyCurrency','_sellCurrency','_compatible','_weapon','_attach','_config','_compatibleText','_type','_text'];
#include "defines.hpp"
_item = _this select 0;
_picture = _item select 4;
_class = _item select 0;
_display = _item select 3;
_buyPrice = 0;
_sellPrice = 0;
if (Z_Selling) then {
_buyPrice = _item select 6;
_buyCurrency = _item select 8;

View File

@@ -1,7 +1,6 @@
private ['_item', '_type','_picture',"_class","_display","_transportMaxWeapons","_transportMaxMagazines","_transportmaxBackpacks"
,"_buyPrice","_sellPrice","_buyCurrency","_sellCurrency","_formattedText","_fuelCapacity","_maxSpeed","_armor","_seats","_weapons",
"_weapons2","_config","_wepText","_turret","_text"
];
"_weapons2","_config","_wepText","_turret","_text"];
#include "defines.hpp"
@@ -129,7 +128,6 @@ if (Z_SingleCurrency) then {
, _picture, _display, _class, _transportmaxBackpacks, _sellPrice, _buyPrice, CurrencyName, _transportMaxWeapons,_transportMaxMagazines, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291", localize "STR_EPOCH_MAGS", localize "STR_EPOCH_WEPS", localize "STR_EPOCH_BAGS",
localize "STR_EPOCH_ARMOR",_armor,localize "STR_EPOCH_FUEL",_fuelCapacity,localize "STR_EPOCH_MAX",localize "STR_EPOCH_SPEED",_maxSpeed,localize "STR_EPOCH_SEATS",_seats,localize "STR_EPOCH_WEAPONS",_wepText
];
} else {
_picSell = getText (configFile >> 'CfgMagazines' >> _sellCurrency >> 'picture');
_sellCurrency = getText (configFile >> 'CfgMagazines' >> _sellCurrency >> 'displayName');

View File

@@ -45,7 +45,7 @@ _attachText = "";
} forEach _attachments;
_magazines = [];
if( isArray (configFile >> 'CfgWeapons' >> _class >> 'magazines')) then {
if (isArray (configFile >> 'CfgWeapons' >> _class >> 'magazines')) then {
{
_magazines set [count _magazines, getText (configFile >> "CfgMagazines" >> _x >> "displayName")];
} forEach (getArray (configFile >> 'CfgWeapons' >> _class >> 'magazines'));
@@ -53,13 +53,13 @@ if( isArray (configFile >> 'CfgWeapons' >> _class >> 'magazines')) then {
_magText = "";
{
if( _forEachIndex > 0) then {
if (_forEachIndex > 0) then {
_magText = _magText + ', ' + _x;
} else {
_magText = _magText + _x;
};
}foreach _magazines;
} foreach _magazines;
if (Z_SingleCurrency) then {
_formattedText = format [
@@ -70,7 +70,7 @@ if (Z_SingleCurrency) then {
"<t color='#33BFFF' size='0.8'>%10: </t><t color='#ffffff' size='0.8'>%5 %7</t><br />"
, _picture, _display, _class, _magText, _sellPrice, _buyPrice, CurrencyName, localize "STR_EPOCH_NAME", localize "STR_EPOCH_CLASS", localize "STR_EPOCH_PLAYER_292", localize "STR_EPOCH_PLAYER_291"
];
}else {
} else {
_picSell = getText (configFile >> 'CfgMagazines' >> _sellCurrency >> 'picture');
_sellCurrency = getText (configFile >> 'CfgMagazines' >> _sellCurrency >> 'displayName');
_picBuy = getText (configFile >> 'CfgMagazines' >> _buyCurrency >> 'picture');

View File

@@ -1,5 +1,7 @@
private "_index";
#include "defines.hpp"
{
_index = lbAdd [Z_AT_BUYABLELIST, _x select 3];
lbSetPicture [Z_AT_BUYABLELIST, _index, _x select 4 ];
} count Z_BuyableArray;
} count Z_BuyableArray;

View File

@@ -1,5 +1,7 @@
private "_index";
#include "defines.hpp"
{
_index = lbAdd [Z_AT_BUYINGLIST, _x select 3];
lbSetPicture [Z_AT_BUYINGLIST, _index, _x select 4];
}count Z_BuyingArray;
} count Z_BuyingArray;

View File

@@ -1,8 +1,9 @@
private "_index";
#include "defines.hpp"
call Z_clearBuyList;
{
_index = lbAdd [Z_AT_BUYABLELIST,_x select 0];
lbSetPicture [Z_AT_BUYABLELIST,_index,"\z\addons\dayz_code\gui\epoch\arrow_right.paa"];
} forEach Z_traderData;
} forEach Z_traderData;

View File

@@ -3,8 +3,10 @@
*
* Visualy fills in the listbox of items that can be sold.
**/
private "_index";
#include "defines.hpp"
{
_index = lbAdd [Z_AT_SELLABLELIST, _x select 3];
lbSetPicture [Z_AT_SELLABLELIST, _index, _x select 4 ];
}count Z_SellableArray;
} count Z_SellableArray;

View File

@@ -3,8 +3,10 @@
*
* Visualy fills in the listbox of items currently being sold.
**/
private "_index";
#include "defines.hpp"
{
_index = lbAdd [Z_AT_SELLINGLIST, _x select 3];
lbSetPicture [Z_AT_SELLINGLIST, _index, _x select 4];
}count Z_SellArray;
} count Z_SellArray;

View File

@@ -5,6 +5,8 @@
*
* Changes the indication of where you are selling/buying from in the trade window.
**/
private "_text";
#include "defines.hpp"
_text = _this select 0;
ctrlSetText [Z_AT_CONTAINERINDICATOR, _text];
ctrlSetText [Z_AT_CONTAINERINDICATOR, _text];

View File

@@ -5,15 +5,16 @@
*
* Filters the buyable or sellable list on your input.
**/
private ["_query","_newSellArray","_newBuyArray"];
if(count _this > 0) then {
if (count _this > 0) then {
_query = _this select 0; // the search string.
if(Z_Selling)then {
if (Z_Selling) then {
if (count Z_SellArray > 0) exitWith {}; //Do not filter if items already in selling list (dupes)
if(isNil '_query' || _query == "") then {
if (isNil '_query' || _query == "") then {
_newSellArray = [];
{
if( _x find Z_SellArray < 0) then {
if (_x find Z_SellArray < 0) then {
_newSellArray set [count(_newSellArray), _x];
};
} forEach Z_OriginalSellableArray;
@@ -22,11 +23,11 @@ if(count _this > 0) then {
call Z_clearSellableList;
call Z_fillSellList;
}else {
} else {
_newSellArray = [];
{
if(( [_query,(_x select 0)] call fnc_inString) || ([_query,(_x select 3)] call fnc_inString) ) then {
if( _x find Z_SellArray < 0 ) then {
if (([_query,(_x select 0)] call fnc_inString) || ([_query,(_x select 3)] call fnc_inString)) then {
if (_x find Z_SellArray < 0) then {
_newSellArray set [count(_newSellArray), _x];
};
};
@@ -35,15 +36,15 @@ if(count _this > 0) then {
call Z_clearSellableList;
call Z_fillSellList;
};
}else {
if(isNil '_query' || _query == "") then {
} else {
if (isNil '_query' || _query == "") then {
Z_BuyableArray = [] + Z_OriginalBuyableArray;
call Z_clearBuyList;
call Z_fillBuyableList;
}else {
} else {
_newBuyArray = [];
{
if(( [_query,(_x select 0)] call fnc_inString) || ([_query,(_x select 3)] call fnc_inString) ) then {
if (([_query,(_x select 0)] call fnc_inString) || ([_query,(_x select 3)] call fnc_inString)) then {
_newBuyArray set [count(_newBuyArray), _x];
};
} forEach Z_OriginalBuyableArray;
@@ -52,4 +53,4 @@ if(count _this > 0) then {
call Z_fillBuyableList;
};
};
};
};

View File

@@ -3,12 +3,14 @@
*
* Gets all your items stored in your backpack and innitiates the selling list.
**/
private ["_backpack","_pic","_formattedText","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_amounts","_amounts2"];
#include "defines.hpp"
private ["_backpack","_pic","_formattedText","_mags","_weaps","_normalMags","_normalWeaps","_kinds","_kinds2","_ammmounts","_ammmounts2","_ctrltext"];
call Z_clearLists;
Z_SellableArray = [];
Z_SellArray = [];
_backpack = unitBackpack player;
if (!isNull _backpack) then {
_pic = getText (configFile >> 'CfgVehicles' >> (typeOf _backpack) >> 'picture');
@@ -24,30 +26,24 @@ if (!isNull _backpack) then {
_normalMags = [];
_normalWeaps = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts select _forEachIndex)}do{
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
};
}forEach _kinds;
} forEach _kinds;
_kinds2 = _weaps select 0;
_ammmounts2 = _weaps select 1;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts2 select _forEachIndex)}do{
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
}forEach _kinds2;
} forEach _kinds2;
[_normalMags,_normalWeaps, typeOf _backpack,[]] call Z_checkArrayInConfig;
}else{
_ctrltext = localize "STR_EPOCH_TRADE_STUPID";
ctrlSetText [Z_AT_TRADERLINE2, _ctrltext];
_ctrltext = localize "STR_EPOCH_TRADE_NO_BACKPACK";
ctrlSetText [Z_AT_TRADERLINE1, _ctrltext];
};

View File

@@ -1,11 +1,11 @@
/**
* call Z_getContainer
*
* Switches between selling and buying and the item container (gear/vehicle/bakcpack) and initiates item loading.
* Switches between selling and buying and the item container (gear/vehicle/backpack) and initiates item loading.
**/
private ["_lbIndex","_canBuyInVehicle"];
private ["_lbIndex","_canBuyInVehicle","_backpack"];
#include "defines.hpp"
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetText format["0 / 0 / 0"];
if (Z_Selling) then {
call Z_clearBuyingList;
Z_BuyingArray = [];
@@ -15,22 +15,34 @@ Z_SellableArray = [];
Z_SellArray = [];
_lbIndex = _this select 0;
_backpack = unitBackpack player;
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_ITEMINFO) ctrlSetStructuredText parseText "";
call Z_calcPrice;
if(Z_Selling)then{
if (Z_Selling) then {
switch (_lbIndex) do {
case 0: {
[localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_filleTradeTitle;
Z_SellingFrom = 0;
call Z_getBackpackItems;
if (!isNull _backpack) then {
[localize "STR_EPOCH_TRADE_SELLING_BACKPACK"] call Z_filleTradeTitle;
Z_SellingFrom = 0;
call Z_getBackpackItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
};
};
case 1: {
[localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_filleTradeTitle;
Z_SellingFrom = 1;
call Z_getVehicleItems;
_canBuyInVehicle = true call Z_checkCloseVehicle;
if (_canBuyInVehicle) then {
[localize "STR_EPOCH_TRADE_SELLING_VEHICLE"] call Z_filleTradeTitle;
Z_SellingFrom = 1;
call Z_getVehicleItems;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
};
};
case 2: {
[localize "STR_EPOCH_TRADE_SELLING_GEAR"] call Z_filleTradeTitle;
@@ -38,24 +50,29 @@ if(Z_Selling)then{
call Z_getGearItems;
};
};
}else{
} else {
ctrlSetText [Z_AT_TRADERLINE2, " "];
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_SELLING_ALL"];
switch (_lbIndex) do {
case 0: {
Z_SellingFrom = 0;
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_filleTradeTitle;
[0] call Z_calculateFreeSpace;
if (!isNull _backpack) then {
Z_SellingFrom = 0;
[localize "STR_EPOCH_TRADE_BUYING_BACKPACK"] call Z_filleTradeTitle;
[0] call Z_calculateFreeSpace;
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_TRADE_NO_BACKPACK"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
};
};
case 1: {
Z_SellingFrom = 1;
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_filleTradeTitle;
_canBuyInVehicle = true call Z_checkCloseVehicle;
if(_canBuyInVehicle)then{
if (_canBuyInVehicle) then {
Z_SellingFrom = 1;
[localize "STR_EPOCH_TRADE_BUYING_VEHICLE"] call Z_filleTradeTitle;
[1] call Z_calculateFreeSpace;
}else{
systemChat localize "STR_EPOCH_PLAYER_245";
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_SLOTSDISPLAY) ctrlSetText format["%1 / %2 / %3",0,0,0];
} else {
ctrlSetText [Z_AT_TRADERLINE1, localize "STR_EPOCH_PLAYER_245"];
ctrlSetText [Z_AT_SLOTSDISPLAY, " "];
};
};
case 2: {

View File

@@ -1,10 +1,11 @@
/**
* call Z_getBackpackItems
* call Z_getGearItems
*
* Gets all your items stored in your gear and innitiates the selling list.
**/
private ["_mags","_weaps","_skin","_formattedText","_bag","_bags"];
private ["_mags","_weaps","_skin","_formattedText","_bag","_bags","_pic"];
#include "defines.hpp"
call Z_clearLists;
Z_SellArray = [];
Z_SellableArray = [];
@@ -23,4 +24,4 @@ _formattedText = format [
(findDisplay Z_AT_DIALOGWINDOW displayCtrl Z_AT_CONTAINERINFO) ctrlSetStructuredText parseText _formattedText;
[_weaps,_mags,localize "STR_EPOCH_YOUR_GEAR",_bags] call Z_checkArrayInConfig;
[_weaps,_mags,toLower (localize "STR_UI_GEAR"),_bags] call Z_checkArrayInConfig;

View File

@@ -1,6 +1,6 @@
#include "defines.hpp"
private ['_item', '_type'];
#include "defines.hpp"
_item = _this select 0;
_type = _item select 1;

View File

@@ -10,8 +10,8 @@ _selectedIndex = _this select 1;
_item = [];
if(_selectedIndex >= 0) then {
switch(_selectedList) do {
if (_selectedIndex >= 0) then {
switch (_selectedList) do {
case 'sellable': {
_item = Z_SellableArray select _selectedIndex;
};
@@ -27,6 +27,6 @@ if(_selectedIndex >= 0) then {
};
};
if( count _item > 0) then {
if (count _item > 0) then {
[_item] call Z_getItemConfig;
};
};

View File

@@ -1,9 +1,11 @@
/**
* call Z_getBackpackItems
* call Z_getVehicleItems
*
* Gets all your items stored in your vehicle and innitiates the selling list.
**/
private ["_vehicle","_pos","_list","_formattedText","_pic","_mags","_weaps","_bags","_normalMags","_normalWeaps","_normalBags","_kinds","_amounts","_counter","_kinds2","_amounts2"];
#include "defines.hpp"
Z_vehicle = objNull;
call Z_clearLists;
Z_SellableArray = [];
@@ -16,7 +18,7 @@ _list = nearestObjects [_pos, ["Air","LandVehicle","Ship"], Z_VehicleDistance];
if (!isNull _x && local _x && alive _x) then {
_vehicle = _x;
};
}count _list;
} count _list;
if (!isNull _vehicle) then {
systemChat format[localize "STR_EPOCH_TRADE_SELECTED",typeOf _vehicle];
@@ -38,43 +40,37 @@ if (!isNull _vehicle) then {
_normalBags = [];
_kinds = _mags select 0;
_ammmounts = _mags select 1;
_amounts = _mags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts select _forEachIndex)}do{
while {_counter < (_amounts select _forEachIndex)} do {
_normalMags set [count(_normalMags),_x];
_counter = _counter + 1;
_counter = _counter + 1;
};
}forEach _kinds;
} forEach _kinds;
_kinds2 = _weaps select 0;
_ammmounts2 = _weaps select 1;
_amounts2 = _weaps select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts2 select _forEachIndex)}do{
while {_counter < (_amounts2 select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
}forEach _kinds2;
} 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;
_amounts3 = _bags select 1;
{
_counter = 0 ;
while{ _counter < ( _ammmounts3 select _forEachIndex)}do{
while {_counter < (_amounts3 select _forEachIndex)} do {
_normalBags set [count(_normalBags),_x];
_counter = _counter + 1;
};
}forEach _kinds3;
} forEach _kinds3;
*/
[_normalWeaps,_normalMags, typeOf _vehicle,_normalBags] call Z_checkArrayInConfig;
}else{
_ctrltext = localize "STR_EPOCH_PLAYER_245";
ctrlSetText [Z_AT_TRADERLINE2, _ctrltext];
_ctrltext = localize "STR_EPOCH_TRADE_NO_VEHICLE";
ctrlSetText [Z_AT_TRADERLINE1, _ctrltext];
};

View File

@@ -1,7 +1,7 @@
private ["_Z_logTrade","_classNames","_className","_amounts","_amount","_prices","_price","_quantity","_queueAmounts","_queueNames","_queuePrices","_index","_buyOrSell"];
_Z_logTrade = {
private ["_buyOrSell","_className","_container","_currency","_price","_quantity"];
private ["_buyOrSell","_className","_container","_currency","_price","_quantity","_tCost"];
_className = _this select 0;
_quantity = _this select 1;
@@ -12,7 +12,7 @@ _Z_logTrade = {
case 1 : {localize "STR_EPOCH_TRADE_VEHICLE"};
case 2 : {localize "STR_UI_GEAR"};
};
_tcost = _price call Z_calcDefaultCurrencyNoImg;
_tCost = _price call Z_calcDefaultCurrencyNoImg;
_currency = if (Z_SingleCurrency) then {"Coins"} else {""};
// Log to client RPT
@@ -24,9 +24,9 @@ _Z_logTrade = {
};
} else {
if (_buyOrSell == "buy") then {
diag_log format["%5: Bought %4 x %1 into %7 at %2 for %3",_className,inTraderCity,_tcost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
diag_log format["%5: Bought %4 x %1 into %7 at %2 for %3",_className,inTraderCity,_tCost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
} else {
diag_log format["%5: Sold %4 x %1 from %7 at %2 for %3",_className,inTraderCity,_tcost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
diag_log format["%5: Sold %4 x %1 from %7 at %2 for %3",_className,inTraderCity,_tCost,_quantity,localize "STR_EPOCH_PLAYER_289",_currency,_container];
};
};
@@ -40,9 +40,9 @@ _Z_logTrade = {
};
} else {
if (_buyOrSell == "buy") then {
PVDZE_obj_Trade = [player,0,0,_className,inTraderCity,_currency,_tcost,_quantity,_container,false];
PVDZE_obj_Trade = [player,0,0,_className,inTraderCity,_currency,_tCost,_quantity,_container,false];
} else {
PVDZE_obj_Trade = [player,0,1,_className,inTraderCity,_currency,_tcost,_quantity,_container,false];
PVDZE_obj_Trade = [player,0,1,_className,inTraderCity,_currency,_tCost,_quantity,_container,false];
};
};
publicVariableServer "PVDZE_obj_Trade";

View File

@@ -10,12 +10,12 @@ _moneyInVehicle = _moneyInfo select 3;
{
_nil = [player, _x , 1] call BIS_fnc_invRemove;
}count _moneyInGear;
} count _moneyInGear;
if (count _moneyInBackpack > 0 ) then {
if (count _moneyInBackpack > 0) then {
_nil = [unitBackpack _player, _moneyInBackpack, []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
};
if (!isNull Z_vehicle && count _moneyInVehicle > 0 ) then {
if (!isNull Z_vehicle && count _moneyInVehicle > 0) then {
_nil = [Z_vehicle, _moneyInVehicle, []] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
};

View File

@@ -1,6 +1,8 @@
private ["_index","_temp","_index2"];
#include "defines.hpp"
_index = _this select 0;
if(!isNil"_index" && _index > -1)then {
if (!isNil"_index" && _index > -1) then {
lbDelete [Z_AT_SELLABLELIST, _index];
_temp = Z_SellableArray select _index;
//_item = [_temp select 0,_temp select 1 ,_temp select 2,_temp select 3, _temp select 4 ];
@@ -10,4 +12,4 @@ if(!isNil"_index" && _index > -1)then {
_index2 = lbAdd [Z_AT_SELLINGLIST, _temp select 3];
lbSetPicture [Z_AT_SELLINGLIST, _index2, _temp select 4];
call Z_calcPrice;
};
};

View File

@@ -1,8 +1,10 @@
private "_index";
#include "defines.hpp"
_index = _this select 0;
if(!isNil"_index" && _index > -1)then {
if (!isNil"_index" && _index > -1) then {
lbDelete [Z_AT_BUYINGLIST, _index];
Z_BuyingArray set [_index,"deleted"];
Z_BuyingArray = Z_BuyingArray - ["deleted"];
call Z_calcPrice;
};
};

View File

@@ -1,6 +1,8 @@
private ["_index","_temp","_index2"];
#include "defines.hpp"
_index = _this select 0;
if(!isNil"_index" && _index > -1)then {
if (!isNil"_index" && _index > -1) then {
lbDelete [Z_AT_SELLINGLIST, _index];
_temp = Z_SellArray select _index;
//_item = [_temp select 0,_temp select 1 ,_temp select 2,_temp select 3, _temp select 4 ];
@@ -10,4 +12,4 @@ if(!isNil"_index" && _index > -1)then {
_index2 = lbAdd [Z_AT_SELLABLELIST, _temp select 3];
lbSetPicture [Z_AT_SELLABLELIST, _index2, _temp select 4];
call Z_calcPrice;
};
};

View File

@@ -35,14 +35,14 @@ _sellVehicle = {
if (!(_sellType in ["trade_any_boat", "trade_any_boat_old"])) then {
_hitpoints = _obj call vehicle_getHitpoints;
{
if(["Wheel",_x,false] call fnc_inString) then {
if (["Wheel",_x,false] call fnc_inString) then {
_damage = [_obj,_x] call object_getHit;
_tireDmg = _tireDmg + _damage;
_tires = _tires + 1;
};
} forEach _hitpoints;
if(_tireDmg > 0 && _tires > 0) then {
if((_tireDmg / _tires) > 0.75) then {
if (_tireDmg > 0 && _tires > 0) then {
if ((_tireDmg / _tires) > 0.75) then {
_okToSell = false;
};
};
@@ -52,14 +52,16 @@ _sellVehicle = {
_objectCharacterId = _obj getVariable ["CharacterID","0"];
_notSetup = (_objectID == "0" && _objectUID == "0");
if(local _obj && !isNull _obj && alive _obj && !_notSetup) then {
if(_okToSell) then {
if (local _obj && !isNull _obj && alive _obj && !_notSetup) then {
if (_okToSell) then {
_returnInfo = [_objectCharacterId, _obj, _objectID, _objectUID, _sellType];
} else {
systemChat format[localize "str_epoch_player_182",typeOf _obj]; _returnInfo = [];
systemChat format[localize "str_epoch_player_182",typeOf _obj];
_returnInfo = [];
};
} else {
systemChat localize "str_epoch_player_245"; _returnInfo = [];
systemChat localize "str_epoch_player_245";
_returnInfo = [];
};
};
_returnInfo;
@@ -99,7 +101,7 @@ _sellVehicle = {
};
};
};
}forEach Z_SellArray;
} forEach Z_SellArray;
_tSold = _itemsArray + _weaponsArray + _bpArray + _vehArray;
@@ -115,7 +117,7 @@ if (Z_SellingFrom == 1) then {
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])];
//gear
if (Z_SellingFrom == 2)then{
if (Z_SellingFrom == 2) then {
private ["_localResult", "_vehTraded"];
_wA = [];
_mA = [];
@@ -139,23 +141,23 @@ if (Z_SellingFrom == 2)then{
if (_type == "trade_items") then {_name = configFile >> "CfgMagazines" >> _name;};
if (_type == "trade_weapons") then {_name = configFile >> "CfgWeapons" >> _name;};
_localResult = [player,_name,1] call BIS_fnc_invRemove; // Use config for BIS_fnc_invRemove
if(_localResult != 1)then{
if(_x select 1 == "trade_items")then{
if (_localResult != 1) then {
if (_x select 1 == "trade_items") then {
_mA set [count(_mA),0];
}else{
} else {
_wA set [count(_wA),0];
};
}else{
if(_x select 1 == "trade_items")then{
} else {
if (_x select 1 == "trade_items") then {
_mA set [count(_mA),1];
}else{
} else {
_wA set [count(_wA),1];
};
};
};
};
}forEach Z_SellArray;
} forEach Z_SellArray;
_outcome set [0,_mA];
_outcome set [1,_wA];
@@ -169,22 +171,22 @@ if (Z_SellingFrom == 2)then{
systemchat format[localize "STR_EPOCH_TRADE_SELL_IN_GEAR",count _tSold];
};
{ _itemsToLog set [1, (_itemsToLog select 1) + _x] } forEach _outcome;
{_itemsToLog set [1, (_itemsToLog select 1) + _x]} forEach _outcome;
_money = 0;
if (Z_SingleCurrency) then {
{
_money = _money + ( (((_itemsCheckArray select _forEachIndex) select 0)) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [( (((_itemsCheckArray select _forEachIndex) select 0)) * _x)]];
}forEach (_outcome select 0);
_money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [((((_itemsCheckArray select _forEachIndex) select 0)) * _x)]];
} forEach (_outcome select 0);
{
_money = _money + ( (((_weaponsCheckArray select _forEachIndex) select 0)) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [( (((_weaponsCheckArray select _forEachIndex) select 0)) * _x)]];
}forEach (_outcome select 1);
_money = _money + ((((_weaponsCheckArray select _forEachIndex) select 0)) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [((((_weaponsCheckArray select _forEachIndex) select 0)) * _x)]];
} forEach (_outcome select 1);
{
_money = _money + ( ( ((_bpCheckArray select _forEachIndex) select 0) ) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [( (((_bpCheckArray select _forEachIndex) select 0)) * _x)]];
}forEach (_outcome select 2);
_money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x) ;
_itemsToLog set [2, (_itemsToLog select 2) + [((((_bpCheckArray select _forEachIndex) select 0)) * _x)]];
} forEach (_outcome select 2);
if (count _outcome > 3) then {
_money = _money + ((_vehCheckArray select 0) select 0);
@@ -193,19 +195,19 @@ if (Z_SingleCurrency) then {
} else {
{
_itemData = _itemsCheckArray select _forEachIndex;
_money = _money + ( (_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]];
}forEach (_outcome select 0);
_money = _money + ((_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [((_itemData select 0) * (_itemData select 1) * _x)]];
} forEach (_outcome select 0);
{
_itemData = _weaponsCheckArray select _forEachIndex;
_money = _money + ( (_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]];
}forEach (_outcome select 1);
_money = _money + ((_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [((_itemData select 0) * (_itemData select 1) * _x)]];
} forEach (_outcome select 1);
{
_itemData = _bpCheckArray select _forEachIndex;
_money = _money + ( (_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [( (_itemData select 0) * (_itemData select 1) * _x)]];
}forEach (_outcome select 2);
_money = _money + ((_itemData select 0) * (_itemData select 1) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [((_itemData select 0) * (_itemData select 1) * _x)]];
} forEach (_outcome select 2);
if ((count _outcome) > 3) then {
_itemData = _vehCheckArray select 0;
_money = _money + ((_itemData select 0) * (_itemData select 1));

View File

@@ -1,9 +1,9 @@
private ["_amount","_index","_index2","_temp"];
#include "defines.hpp"
_index = _this select 0;
_amount = parseNumber(_this select 1);
if(!isNil"_index" && _index > -1 && (typeName _amount == "SCALAR") && _amount > 0 )then {
if (!isNil"_index" && _index > -1 && (typeName _amount == "SCALAR") && _amount > 0) then {
_temp = [] + (Z_BuyableArray select _index);
_temp set [9,(ceil _amount)];
Z_BuyingArray set [count(Z_BuyingArray),_temp];

View File

@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------
Examples:
_result = [_backpack, ["SmokeShell","M16_AMMO"],["M16","M16","M240"],["backpack1","backpack2"]] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
_result == [[1,0,0,1,1,1,0],[1,0,0,1],[1,0]]; // 1 = success, 0 = fail ->( item was not in cargo)
_result == [[1,0,0,1,1,1,0],[1,0,0,1],[1,0]]; // 1 = success, 0 = fail ->(item was not in cargo)
Author:
Zupa 2014-09-30
@@ -14,7 +14,7 @@ _weaps = _this select 2;
_bags = [];
_vehInfo = [];
if(count _this > 3) then {
if (count _this > 3) then {
if (count (_this select 3) > 0) then {
if (typeName ((_this select 3) select 0) == "STRING") then {
_bags = _this select 3;
@@ -46,31 +46,31 @@ _unit_allBags_count = _unit_allBags select 1;
clearMagazineCargoGlobal _unit;
clearWeaponCargoGlobal _unit;
if( count _bags > 0 )then{
if (count _bags > 0) then {
clearBackpackCargoGlobal _unit;
};
{
_counter = 0 ;
while{ _counter < ( _unit_allItems_count select _forEachIndex)}do{
_normalItems set [count(_normalItems),_x];
_counter = _counter + 1;
while {_counter < (_unit_allItems_count select _forEachIndex)} do {
_normalItems set [count(_normalItems),_x];
_counter = _counter + 1;
};
}forEach _unit_allItems_types;
} forEach _unit_allItems_types;
{
_counter = 0 ;
while{ _counter < ( _unit_allWeaps_count select _forEachIndex)}do{
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
while {_counter < (_unit_allWeaps_count select _forEachIndex)} do {
_normalWeaps set [count(_normalWeaps),_x];
_counter = _counter + 1;
};
}forEach _unit_allWeaps_types;
} forEach _unit_allWeaps_types;
{
_counter = 0 ;
while{ _counter < ( _unit_allBags_count select _forEachIndex)}do{
_normalBagss set [count(_normalBags),_x];
_counter = _counter + 1;
while {_counter < (_unit_allBags_count select _forEachIndex)} do {
_normalBagss set [count(_normalBags),_x];
_counter = _counter + 1;
};
}forEach _unit_allBags_types;
} forEach _unit_allBags_types;
_returnVar = [];
_returnMag = [];
@@ -78,45 +78,45 @@ _returnWeap = [];
_returnBag = [];
{
_inCargo = _normalItems find _x;
if(_inCargo > -1)then{
if (_inCargo > -1) then {
_normalItems set [_inCargo, "soldItem"];
_returnMag set [count(_returnMag),1];
}else{
} else {
_returnMag set [count(_returnMag),0];
};
}count _items;
} count _items;
_normalItems = _normalItems - ["soldItem"];
{
_unit addMagazineCargoGlobal [_x, 1];
}count _normalItems;
} count _normalItems;
{
_inCargo = _normalBags find _x;
if(_inCargo > -1)then{
if (_inCargo > -1) then {
_normalBags set [_inCargo, "soldItem"];
_returnBag set [count(_returnBag),1];
}else{
} else {
_returnBag set [count(_returnBag),0];
};
}count _bags;
} count _bags;
{
_unit addBackpackCargoGlobal [_x, 1];
}count _normalBags;
} count _normalBags;
{
_inCargo = _normalWeaps find _x;
if(_inCargo > -1)then{
if (_inCargo > -1) then {
_normalWeaps set [_inCargo, "soldItem"];
_returnWeap set [count(_returnWeap),1];
}else{
} else {
_returnWeap set [count(_returnWeap),0];
};
}count _weaps;
} count _weaps;
_normalWeaps = _normalWeaps - ["soldItem"];
{
_unit addWeaponCargoGlobal [_x, 1];
}count _normalWeaps;
} count _normalWeaps;
_normalWeaps = _normalWeaps - ["soldItem"];
if (count _vehInfo > 0) then {
@@ -130,4 +130,4 @@ _returnVar set [0,_returnMag];
_returnVar set [1,_returnWeap];
_returnVar set [2,_returnBag];
_returnVar;
_returnVar;