mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-23 00:20:50 +03:00
Add epoch_generateKey function
This commit is contained in:
@@ -21,7 +21,7 @@ if (!isNil '_pic' && _pic == "") then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_formattedText = format [
|
_formattedText = format [
|
||||||
"<t size='1' align='center' color='#ffffff'>%1 %2</t>"
|
"<t size='1' align='center' color='#ffffff'> %2 </t>"
|
||||||
, _pic, localize "STR_UI_GEAR"
|
, _pic, localize "STR_UI_GEAR"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -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;};
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||||
DZE_ActionInProgress = true;
|
DZE_ActionInProgress = true;
|
||||||
@@ -117,27 +117,8 @@ if (_finished) then {
|
|||||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||||
|
|
||||||
if(dayzTradeResult == "PASS") then {
|
if(dayzTradeResult == "PASS") then {
|
||||||
|
_result = call epoch_generateKey;
|
||||||
// First select key color
|
if (_result select 0) then {
|
||||||
_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 {
|
|
||||||
|
|
||||||
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
||||||
if (_done) then {
|
if (_done) then {
|
||||||
|
|
||||||
@@ -156,7 +137,7 @@ if (_finished) then {
|
|||||||
|
|
||||||
_location = (getPosATL _veh);
|
_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";
|
publicVariableServer "PVDZE_veh_Publish2";
|
||||||
|
|
||||||
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||||
|
|||||||
@@ -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;};
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||||
DZE_ActionInProgress = true;
|
DZE_ActionInProgress = true;
|
||||||
@@ -97,25 +97,8 @@ if (_qty >= _qty_in) then {
|
|||||||
if(dayzTradeResult == "PASS") then {
|
if(dayzTradeResult == "PASS") then {
|
||||||
|
|
||||||
if(_buy_o_sell == "buy") then {
|
if(_buy_o_sell == "buy") then {
|
||||||
|
_result = call epoch_generateKey;
|
||||||
// First select key color
|
if (_result select 0) then {
|
||||||
_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 {
|
|
||||||
|
|
||||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||||
if(_removed == _qty_in) then {
|
if(_removed == _qty_in) then {
|
||||||
_dir = round(random 360);
|
_dir = round(random 360);
|
||||||
@@ -132,14 +115,14 @@ if (_qty >= _qty_in) then {
|
|||||||
|
|
||||||
_location = (getPosATL _veh);
|
_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";
|
publicVariableServer "PVDZE_veh_Publish2";
|
||||||
|
|
||||||
player reveal _veh;
|
player reveal _veh;
|
||||||
|
|
||||||
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||||
} else {
|
} else {
|
||||||
player removeMagazine _keySelected;
|
player removeMagazine (_result select 1);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||||
|
|||||||
@@ -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;};
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||||
DZE_ActionInProgress = true;
|
DZE_ActionInProgress = true;
|
||||||
@@ -116,27 +116,8 @@ if (_finished) then {
|
|||||||
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
//diag_log format["DEBUG Complete Trade: %1", dayzTradeResult];
|
||||||
|
|
||||||
if(dayzTradeResult == "PASS") then {
|
if(dayzTradeResult == "PASS") then {
|
||||||
|
_result = call epoch_generateKey;
|
||||||
// First select key color
|
if (_result select 0) then {
|
||||||
_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 {
|
|
||||||
|
|
||||||
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
_done = [[[_part_in,_qty_in]],0] call epoch_returnChange;
|
||||||
if (_done) then {
|
if (_done) then {
|
||||||
|
|
||||||
@@ -155,7 +136,7 @@ if (_finished) then {
|
|||||||
|
|
||||||
_location = (getPosATL _veh);
|
_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";
|
publicVariableServer "PVDZE_veh_Publish2";
|
||||||
|
|
||||||
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
format[localize "STR_EPOCH_ACTIONS_11",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||||
@@ -163,7 +144,7 @@ if (_finished) then {
|
|||||||
} else {
|
} else {
|
||||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
format[localize "str_epoch_player_183",_textPartOut] call dayz_rollingMessages;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;};
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||||
DZE_ActionInProgress = true;
|
DZE_ActionInProgress = true;
|
||||||
|
|||||||
@@ -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;};
|
if (DZE_ActionInProgress) exitWith {localize "str_epoch_player_103" call dayz_rollingMessages;};
|
||||||
DZE_ActionInProgress = true;
|
DZE_ActionInProgress = true;
|
||||||
@@ -104,25 +104,8 @@ if (_qty >= _qty_in) then {
|
|||||||
if(dayzTradeResult == "PASS") then {
|
if(dayzTradeResult == "PASS") then {
|
||||||
|
|
||||||
if(_buy_o_sell == "buy") then {
|
if(_buy_o_sell == "buy") then {
|
||||||
|
_result = call epoch_generateKey;
|
||||||
// First select key color
|
if (_result select 0) then {
|
||||||
_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 {
|
|
||||||
|
|
||||||
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
_removed = ([player,_part_in,_qty_in] call BIS_fnc_invRemove);
|
||||||
if(_removed == _qty_in) then {
|
if(_removed == _qty_in) then {
|
||||||
_dir = round(random 360);
|
_dir = round(random 360);
|
||||||
@@ -139,12 +122,12 @@ if (_qty >= _qty_in) then {
|
|||||||
|
|
||||||
_location = (getPosATL _veh);
|
_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";
|
publicVariableServer "PVDZE_veh_Publish2";
|
||||||
|
|
||||||
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
format["Bought %3 for %1 %2, key added to toolbelt.",_qty_in,_textPartIn,_textPartOut] call dayz_rollingMessages;
|
||||||
} else {
|
} else {
|
||||||
player removeMagazine _keySelected;
|
player removeMagazine (_result select 1);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
localize "str_epoch_player_107" call dayz_rollingMessages;
|
localize "str_epoch_player_107" call dayz_rollingMessages;
|
||||||
|
|||||||
27
SQF/dayz_code/compile/epoch_generateKey.sqf
Normal file
27
SQF/dayz_code/compile/epoch_generateKey.sqf
Normal file
@@ -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]
|
||||||
@@ -153,6 +153,7 @@ if (!isDedicated) then {
|
|||||||
dze_getPlotFriends = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_getPlotFriends.sqf";
|
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_requiredItemsCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_requiredItemsCheck.sqf";
|
||||||
dze_surrender_off = {player setVariable ["DZE_Surrendered",false,true]; DZE_Surrender = false;};
|
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_tempKeys = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_tempKeys.sqf";
|
||||||
epoch_totalCurrency = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_totalCurrency.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";
|
epoch_itemCost = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_itemCost.sqf";
|
||||||
|
|||||||
Reference in New Issue
Block a user