From b5af74b72b318389ff3f12fcb318dba02553ac1e Mon Sep 17 00:00:00 2001 From: icomrade Date: Wed, 27 Apr 2016 22:04:47 -0400 Subject: [PATCH] Add Vehicle Purchasing to Advanced Trading Allows 1 vehicle purchase at a time. Vehicles will still spawn inside each other if one is already parked on the pad. --- .../functions/z_at_allowBuying.sqf | 11 ++--- .../functions/z_at_buyItems.sqf | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf index 0f0ae95b5..40e53f88f 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_allowBuying.sqf @@ -13,6 +13,10 @@ _sidearmToBuy = _this select 4; _primaryToBuy = _this select 5; _vehiclesToBuy = _this select 6; +if (_vehiclesToBuy > 1) exitWith {systemChat "You can only purchase one vehicle at a time."; false;}; +if (_vehiclesToBuy > 0) then { + _toolsToBuy = _toolsToBuy + _vehiclesToBuy; +}; if(_selection == 2) then{ //gear _allowedMags = 20 - count(magazines player); @@ -256,9 +260,4 @@ if(_selection == 0) then{ //backpack }; }; -if(_vehiclesToBuy != 0)then{ - _return = false; - systemChat "You can NOT buy vehicles in this version"; -}; - -_return +_return; \ No newline at end of file diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf index 927a10cc1..a282bd53f 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_buyItems.sqf @@ -93,6 +93,31 @@ if (Z_SingleCurrency) then { if(_enoughMoney) then { if(_canBuy) then { + _buyVehicle = { + private "_location"; + _part_out = _this; + _keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; + _keyNumber = (floor(random 2500)) + 1; + _keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; + _isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); + if (!_isKeyOK) exitWith {localize "str_epoch_player_107" call dayz_rollingMessages; "";}; + _activatingPlayer = player; + _dir = round(random 360); + _helipad = nearestObjects [player, ["HeliHCivil","HeliHempty"], 100]; + + 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; + }; + + _veh = createVehicle ["Sign_arrow_down_large_EP1", _location, [], 0, "CAN_COLLIDE"]; + _location = (getPosATL _veh); + + PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; + publicVariableServer "PVDZE_veh_Publish2"; + _keySelected; + }; systemChat format["Starting trade."]; closeDialog 2; @@ -108,6 +133,13 @@ if(_enoughMoney) then { if( _x select 1 == "trade_items")then{ _backpack addMagazineCargoGlobal [_x select 0, _x select 9]; diag_log format ["%1 x %2 added", _x select 0, _x select 9]; + }; + if( _x select 1 == "trade_any_vehicle")then{ + _item2Add = (_x select 0) call _buyVehicle; + if (_item2Add != "") then { + _backpack addWeaponCargoGlobal [_item2Add, 1]; + diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; + }; }; } count Z_BuyingArray; }; @@ -127,6 +159,13 @@ if(_enoughMoney) then { Z_vehicle addBackpackCargoGlobal [_x select 0, _x select 9]; diag_log format ["%1 x %2 added", _x select 0, _x select 9]; }; + if( _x select 1 == "trade_any_vehicle")then{ + _item2Add = (_x select 0) call _buyVehicle; + if (_item2Add != "") then { + Z_vehicle addWeaponCargoGlobal [_item2Add, 1]; + diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; + }; + }; } count Z_BuyingArray; }; @@ -152,6 +191,13 @@ if(_enoughMoney) then { if( _x select 1 == "trade_backpacks")then{ player addBackpack (_x select 0); }; + if( _x select 1 == "trade_any_vehicle")then{ + _item2Add = (_x select 0) call _buyVehicle; + if (_item2Add != "") then { + player addWeapon _item2Add; + diag_log format ["Key %1 added for vehicle %2", _item2Add, _x select 0]; + }; + }; } count Z_BuyingArray; }; if (!Z_SingleCurrency) then {