diff --git a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getGearItems.sqf b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getGearItems.sqf index e20c02df9..d62041e22 100644 --- a/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getGearItems.sqf +++ b/SQF/dayz_code/actions/AdvancedTrading/functions/z_at_getGearItems.sqf @@ -21,7 +21,7 @@ if (!isNil '_pic' && _pic == "") then { }; _formattedText = format [ - "%1 %2" + " %2 " , _pic, localize "STR_UI_GEAR" ]; diff --git a/SQF/dayz_code/actions/trade_any_boat.sqf b/SQF/dayz_code/actions/trade_any_boat.sqf index a1728f93f..9c7ac1e39 100644 --- a/SQF/dayz_code/actions/trade_any_boat.sqf +++ b/SQF/dayz_code/actions/trade_any_boat.sqf @@ -1,4 +1,4 @@ -private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; +private ["_veh","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -117,27 +117,8 @@ if (_finished) then { //diag_log format["DEBUG Complete Trade: %1", dayzTradeResult]; if(dayzTradeResult == "PASS") then { - - // First select key color - _keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; - - // then select number from 1 - 2500 - _keyNumber = (floor(random 2500)) + 1; - - // Combine to key (eg.ItemKeyYellow2494) classname - _keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; - - _isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); - - //Remove melee magazines (BIS_fnc_invAdd fix) - {player removeMagazines _x} count MeleeMagazines; - _config = _keySelected; - _isOk = [player,_config] call BIS_fnc_invAdd; - - waitUntil {!isNil "_isOk"}; - - if (_isOk && _isKeyOK) then { - + _result = call epoch_generateKey; + if (_result select 0) then { _done = [[[_part_in,_qty_in]],0] call epoch_returnChange; if (_done) then { @@ -156,7 +137,7 @@ if (_finished) then { _location = (getPosATL _veh); - PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; + PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_result select 1,_activatingPlayer]; publicVariableServer "PVDZE_veh_Publish2"; format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages; diff --git a/SQF/dayz_code/actions/trade_any_boat_old.sqf b/SQF/dayz_code/actions/trade_any_boat_old.sqf index 65726995a..de741d550 100644 --- a/SQF/dayz_code/actions/trade_any_boat_old.sqf +++ b/SQF/dayz_code/actions/trade_any_boat_old.sqf @@ -1,4 +1,4 @@ -private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_okToSell","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"]; +private ["_veh","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_okToSell","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -97,25 +97,8 @@ if (_qty >= _qty_in) then { if(dayzTradeResult == "PASS") then { if(_buy_o_sell == "buy") then { - - // First select key color - _keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; - - // then select number from 1 - 2500 - _keyNumber = (floor(random 2500)) + 1; - - // Combine to key (eg.ItemKeyYellow2494) classname - _keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; - - _isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); - - //Remove melee magazines (BIS_fnc_invAdd fix) - {player removeMagazines _x} count MeleeMagazines; - _config = _keySelected; - _isOk = [player,_config] call BIS_fnc_invAdd; - waitUntil {!isNil "_isOk"}; - if (_isOk && _isKeyOK) then { - + _result = call epoch_generateKey; + if (_result select 0) then { _removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove); if(_removed == _qty_in) then { _dir = round(random 360); @@ -132,14 +115,14 @@ if (_qty >= _qty_in) then { _location = (getPosATL _veh); - PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; + PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_result select 1,_activatingPlayer]; publicVariableServer "PVDZE_veh_Publish2"; player reveal _veh; format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages; } else { - player removeMagazine _keySelected; + player removeMagazine (_result select 1); }; } else { localize "str_epoch_player_107" call dayz_rollingMessages; diff --git a/SQF/dayz_code/actions/trade_any_vehicle.sqf b/SQF/dayz_code/actions/trade_any_vehicle.sqf index 1f0eb396c..884e072b8 100644 --- a/SQF/dayz_code/actions/trade_any_vehicle.sqf +++ b/SQF/dayz_code/actions/trade_any_vehicle.sqf @@ -1,4 +1,4 @@ -private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_temp_keys","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; +private ["_veh","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_damage","_tireDmg","_tires","_okToSell","_temp_keys","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -116,27 +116,8 @@ if (_finished) then { //diag_log format["DEBUG Complete Trade: %1", dayzTradeResult]; if(dayzTradeResult == "PASS") then { - - // First select key color - _keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; - - // then select number from 1 - 2500 - _keyNumber = (floor(random 2500)) + 1; - - // Combine to key (eg.ItemKeyYellow2494) classname - _keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; - - _isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); - - //Remove melee magazines (BIS_fnc_invAdd fix) - {player removeMagazines _x} count MeleeMagazines; - _config = _keySelected; - _isOk = [player,_config] call BIS_fnc_invAdd; - - waitUntil {!isNil "_isOk"}; - - if (_isOk && _isKeyOK) then { - + _result = call epoch_generateKey; + if (_result select 0) then { _done = [[[_part_in,_qty_in]],0] call epoch_returnChange; if (_done) then { @@ -155,7 +136,7 @@ if (_finished) then { _location = (getPosATL _veh); - PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; + PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_result select 1,_activatingPlayer]; publicVariableServer "PVDZE_veh_Publish2"; format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages; @@ -163,7 +144,7 @@ if (_finished) then { } else { localize "str_epoch_player_107" call dayz_rollingMessages; }; - + } else { format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages; }; diff --git a/SQF/dayz_code/actions/trade_any_vehicle_free.sqf b/SQF/dayz_code/actions/trade_any_vehicle_free.sqf index 590568a73..c35b379d9 100644 --- a/SQF/dayz_code/actions/trade_any_vehicle_free.sqf +++ b/SQF/dayz_code/actions/trade_any_vehicle_free.sqf @@ -1,4 +1,4 @@ -private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; +private ["_veh","_location","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_canAfford","_trade_total","_total_currency","_return_change","_done"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;}; DZE_ActionInProgress = true; diff --git a/SQF/dayz_code/actions/trade_any_vehicle_old.sqf b/SQF/dayz_code/actions/trade_any_vehicle_old.sqf index b9609b7d8..c98798c2f 100644 --- a/SQF/dayz_code/actions/trade_any_vehicle_old.sqf +++ b/SQF/dayz_code/actions/trade_any_vehicle_old.sqf @@ -1,4 +1,4 @@ -private ["_veh","_location","_isOk","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_keyColor","_keyNumber","_keySelected","_isKeyOK","_config","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"]; +private ["_veh","_location","_result","_part_out","_part_in","_qty_out","_qty_in","_qty","_buy_o_sell","_obj","_objectID","_objectUID","_bos","_started","_finished","_animState","_isMedic","_dir","_helipad","_removed","_damage","_tireDmg","_tires","_okToSell","_hitpoints","_needed","_activatingPlayer","_textPartIn","_textPartOut","_traderID","_playerNear"]; if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;}; DZE_ActionInProgress = true; @@ -104,25 +104,8 @@ if (_qty >= _qty_in) then { if(dayzTradeResult == "PASS") then { if(_buy_o_sell == "buy") then { - - // First select key color - _keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; - - // then select number from 1 - 2500 - _keyNumber = (floor(random 2500)) + 1; - - // Combine to key (eg.ItemKeyYellow2494) classname - _keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; - - _isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); - - //Remove melee magazines (BIS_fnc_invAdd fix) - {player removeMagazines _x} count MeleeMagazines; - _config = _keySelected; - _isOk = [player,_config] call BIS_fnc_invAdd; - waitUntil {!isNil "_isOk"}; - if (_isOk && _isKeyOK) then { - + _result = call epoch_generateKey; + if (_result select 0) then { _removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove); if(_removed == _qty_in) then { _dir = round(random 360); @@ -139,12 +122,12 @@ if (_qty >= _qty_in) then { _location = (getPosATL _veh); - PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_keySelected,_activatingPlayer]; + PVDZE_veh_Publish2 = [_veh,[_dir,_location],_part_out,false,_result select 1,_activatingPlayer]; publicVariableServer "PVDZE_veh_Publish2"; format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages; } else { - player removeMagazine _keySelected; + player removeMagazine (_result select 1); }; } else { localize "str_epoch_player_107" call dayz_rollingMessages; diff --git a/SQF/dayz_code/compile/epoch_generateKey.sqf b/SQF/dayz_code/compile/epoch_generateKey.sqf new file mode 100644 index 000000000..6a02fdca3 --- /dev/null +++ b/SQF/dayz_code/compile/epoch_generateKey.sqf @@ -0,0 +1,27 @@ +/* + - Generates key + - Attempts to add to toolbelt + Usage: _result = call epoch_generateKey; + Returns array: + [bool, string] + [(key added successfully or not), ItemKey## class name] +*/ + +private ["_isKeyOK","_keyColor","_keyNumber","_keySelected"]; + +// First select key color +_keyColor = ["Green","Red","Blue","Yellow","Black"] call BIS_fnc_selectRandom; + +// then select number from 1 - 2500 +_keyNumber = (floor(random 2500)) + 1; + +// Combine to key (eg.ItemKeyYellow2494) classname +_keySelected = format["ItemKey%1%2",_keyColor,_keyNumber]; + +_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected); + +//Remove melee magazines (BIS_fnc_invAdd fix) +{player removeMagazines _x} count MeleeMagazines; +_isOk = [player,_keySelected] call BIS_fnc_invAdd; + +[(_isOk && _isKeyOK),_keySelected] \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 55b6a92a7..1a7c79a13 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -153,6 +153,7 @@ if (!isDedicated) then { dze_getPlotFriends = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_getPlotFriends.sqf"; dze_requiredItemsCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_requiredItemsCheck.sqf"; dze_surrender_off = {player setVariable ["DZE_Surrendered",false,true]; DZE_Surrender = false;}; + epoch_generateKey = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_generateKey.sqf"; epoch_tempKeys = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_tempKeys.sqf"; epoch_totalCurrency = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_totalCurrency.sqf"; epoch_itemCost = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_itemCost.sqf";