Add epoch_generateKey function

This commit is contained in:
ebaydayz
2016-05-03 13:35:43 -04:00
parent 2f98fc0451
commit 1eeaa3e792
8 changed files with 49 additions and 93 deletions

View File

@@ -21,7 +21,7 @@ if (!isNil '_pic' && _pic == "") then {
};
_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"
];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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;

View 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]

View File

@@ -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";