Advanced trading modifications, maintain_area modifications

This lot of changes brings forth the following:

Sets up a "default" set of compiles that are the minimum needed for
maintain_area.sqf and custom scripts to utilize the gem based currency
that @icomrade added.

maintain_area.sqf: This will now utilize the gem based currency system.

Removed the redundant Z_Vehicle and replaced it with the Epoch built in
DZE_myVehicle

z_at_buyItems: Code tidying and optimization

z_at_checkCloseVehicle: Tidied up the code since removing Z_Vehicle
allowed us to remove some now useless code.

z_at_getVehicleItems: Removed the nearestObjects check for your vehicle
since we now do z_checkCloseVehicle on Advanced trading start up.
This commit is contained in:
oiad
2016-10-28 00:00:51 +13:00
parent f92d84f720
commit a9b4a79a77
16 changed files with 232 additions and 234 deletions

View File

@@ -1,7 +1,7 @@
private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold"];
private ["_tempArray","_outcome","_vehCheckArray","_vehArray","_weaponsArray","_itemsArray","_bpArray","_bpCheckArray","_weaponsCheckArray","_itemsCheckArray","_VehKey","_wA","_mA","_money","_itemData","_success","_bag","_itemsToLog","_tCost","_tSold","_wealth"];
if (count Z_SellArray < 1) exitWith { systemChat localize "STR_EPOCH_TRADE_SELL_NO_ITEMS"; };
if (Z_SellingFrom == 1 && (isNull Z_vehicle or !local Z_vehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; };
if (Z_SellingFrom == 1 && (isNull DZE_myVehicle or !local DZE_myVehicle)) exitWith { systemChat localize "STR_EPOCH_PLAYER_245"; };
_tempArray = Z_SellArray;
closeDialog 2;
@@ -17,15 +17,14 @@ _itemsCheckArray = [];
_itemsToLog = [[],[],[],"sell"];
_sellVehicle = {
private ["_distance","_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"];
private ["_damage","_tireDmg","_tires","_okToSell","_returnInfo","_obj","_hitpoints","_objectID","_objectUID","_objectCharacterId","_notSetup","_part_in","_qty_in","_activatingPlayer","_objects","_qty","_vehicle"];
_vehicle = _this select 0;
_sellType = _this select 1;
_part_in = typeOf _vehicle;
_qty_in = 1;
_activatingPlayer = player;
_distance = Z_VehicleDistance;
_returnInfo = [];
_objects = nearestObjects [(getPosATL player), [_part_in], _distance];
_objects = nearestObjects [(getPosATL player), [_part_in], Z_VehicleDistance];
_qty = ({(typeOf _x) == _part_in} count _objects);
if (_qty >= _qty_in) then {
_obj = (_objects select 0);
@@ -51,17 +50,17 @@ _sellVehicle = {
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_objectCharacterId = _obj getVariable ["CharacterID","0"];
_notSetup = (_objectID == "0" && _objectUID == "0");
_notSetup = (_objectID == "0" && _objectUID == "0");
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];
systemChat format[localize "str_epoch_player_182",typeOf _obj];
_returnInfo = [];
};
} else {
systemChat localize "str_epoch_player_245";
systemChat localize "str_epoch_player_245";
_returnInfo = [];
};
};
@@ -91,8 +90,8 @@ _sellVehicle = {
};
case (_type in DZE_tradeVehicle) :
{
if (local Z_vehicle) then {
_VehKey = [Z_vehicle, _type] call _sellVehicle;
if (local DZE_myVehicle) then {
_VehKey = [DZE_myVehicle, _type] call _sellVehicle;
if (count _VehKey > 0) then {
_vehArray set [count(_vehArray),_VehKey];
_vehCheckArray set [count(_vehCheckArray),[_x select 2, _x select 11]];
@@ -111,11 +110,11 @@ if (Z_SellingFrom == 0) then {
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_BACKPACK",count _tSold];
};
if (Z_SellingFrom == 1) then {
_outcome = [Z_vehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf Z_vehicle];
_outcome = [DZE_myVehicle,_itemsArray,_weaponsArray,_vehArray] call ZUPA_fnc_removeWeaponsAndMagazinesCargo;
systemChat format[localize "STR_EPOCH_TRADE_SELL_IN_VEHICLE",count _tSold,typeOf DZE_myVehicle];
};
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf Z_vehicle])];
_itemsToLog set [0,(_itemsArray + _weaponsArray + _bpArray + [typeOf DZE_myVehicle])];
//gear
if (Z_SellingFrom == 2) then {
@@ -181,15 +180,15 @@ _money = 0;
if (Z_SingleCurrency) then {
{
_money = _money + ((((_itemsCheckArray select _forEachIndex) select 0)) * _x) ;
_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) ;
_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) ;
_money = _money + ((((_bpCheckArray select _forEachIndex) select 0)) * _x);
_itemsToLog set [2, (_itemsToLog select 2) + [((((_bpCheckArray select _forEachIndex) select 0)) * _x)]];
} forEach (_outcome select 2);
@@ -222,7 +221,8 @@ if (Z_SingleCurrency) then {
if (typeName _money == "SCALAR") then {
if (Z_SingleCurrency) then {
_success = [player,_money] call SC_fnc_addCoins;
_wealth = player getVariable[Z_MoneyVariable,0];
player setVariable[Z_MoneyVariable,(_wealth + _money),true];
systemChat format[localize "STR_EPOCH_TRADE_SUCCESS_CHANGE",[_money] call BIS_fnc_numberText,CurrencyName];
} else {
_success = [_money,0,false,0,[],[],false] call Z_returnChange;
@@ -233,10 +233,10 @@ if (typeName _money == "SCALAR") then {
_itemsToLog call Z_logTrade;
call player_forceSave;
if (Z_SellingFrom == 1) then {
PVDZ_veh_Save = [Z_vehicle,"gear"];
PVDZ_veh_Save = [DZE_myVehicle,"gear"];
publicVariableServer "PVDZ_veh_Save";
};
} else {
systemChat localize "STR_EPOCH_TRADE_DEBUG";
diag_log "Money is not a number. Something went wrong.";
};
};