mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-24 09:29:21 +03:00
Adding salivals Change Code to Epoch Core
This commit is contained in:
97
SQF/dayz_code/actions/changeCode.sqf
Normal file
97
SQF/dayz_code/actions/changeCode.sqf
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
changeCode - Safe, Lockbox and Door code changing script by salival (https://github.com/oiad)
|
||||
*/
|
||||
|
||||
if (dayz_actionInProgress) exitWith {localize "str_player_actionslimit" call dayz_rollingMessages;};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
if (isNull cursorTarget) exitWith {systemChat "cursorTarget isNull!";};
|
||||
|
||||
private ["_backupCode","_badCode","_cursorTarget","_dialog","_dir","_doorFriends","_isDoor","_isLockBox","_isSafe","_isStorage","_location","_lockCode","_object","_ownerID","_typeOf","_vector"];
|
||||
|
||||
_cursorTarget = _this select 3;
|
||||
_typeOf = typeOf (_cursorTarget);
|
||||
|
||||
_isSafe = _typeOf == "VaultStorage";
|
||||
_isLockBox = _typeOf == "LockBoxStorage";
|
||||
_isStorage = (_isSafe || _isLockBox);
|
||||
_isDoor = _typeOf in DZE_DoorsLocked;
|
||||
|
||||
_badCode = false;
|
||||
|
||||
_dialog = call {
|
||||
if (_isLockBox) exitwith {"KeyPadUI"};
|
||||
if (_isSafe) exitwith {"SafeKeyPad"};
|
||||
if (_isDoor) exitwith {"ComboLockUI"};
|
||||
};
|
||||
|
||||
if (_isStorage) then {
|
||||
_backupCode = dayz_combination;
|
||||
dayz_combination = "";
|
||||
dayz_selectedVault = objNull;
|
||||
} else {
|
||||
DZE_topCombo = 0;
|
||||
DZE_midCombo = 0;
|
||||
DZE_botCombo = 0;
|
||||
_backupCode = DZE_Lock_Door;
|
||||
DZE_Lock_Door = "";
|
||||
dayz_selectedDoor = objNull;
|
||||
};
|
||||
|
||||
createDialog _dialog;
|
||||
|
||||
waitUntil {!dialog};
|
||||
|
||||
if (keypadCancel) exitWith {
|
||||
dayz_actionInProgress = false;
|
||||
if (_isStorage) then {dayz_combination = _backupCode;} else {DZE_Lock_Door = _backupCode;};
|
||||
};
|
||||
|
||||
if (_isStorage) then {
|
||||
if (_isSafe) then {
|
||||
if ((parseNumber dayz_combination) > 9999 || count (toArray (dayz_combination)) < 4) then {_badCode = true;};
|
||||
} else {
|
||||
_lockCode = dayz_combination call fnc_lockCode;
|
||||
if (typeName _lockCode == "SCALAR") then {_badCode = true;};
|
||||
};
|
||||
} else {
|
||||
if (parseNumber DZE_Lock_Door == 0) then {_badCode = true};
|
||||
};
|
||||
|
||||
if (_badCode) exitWith {
|
||||
dayz_actionInProgress = false;
|
||||
if (_isStorage) then {dayz_combination = _backupCode;} else {DZE_Lock_Door = _backupCode;};
|
||||
systemChat localize "STR_CL_CC_CODE_INVALID";
|
||||
};
|
||||
|
||||
if (_isStorage) then {
|
||||
sk_changeCode = [player,_cursorTarget,dayz_combination,dayz_authKey];
|
||||
publicVariableServer "sk_changeCode";
|
||||
} else {
|
||||
_location = _cursorTarget getVariable["OEMPos",getPosATL _cursorTarget];
|
||||
_dir = getDir _cursorTarget;
|
||||
_vector = [vectorDir _cursorTarget,vectorUp _cursorTarget];
|
||||
|
||||
_object = createVehicle [_typeOf, [0,0,0], [], 0, "CAN_COLLIDE"];
|
||||
_object setDir _dir;
|
||||
_object setVectorDirAndUp _vector;
|
||||
_object setPosATL _location;
|
||||
_object setVariable ["memDir",_dir,true];
|
||||
|
||||
if (DZE_permanentPlot) then {
|
||||
_ownerID = _cursorTarget getVariable["ownerPUID","0"];
|
||||
_object setVariable ["ownerPUID",_ownerID,true];
|
||||
_doorFriends = _cursorTarget getVariable ["doorfriends",[]];
|
||||
if (isNil "_ownerID" || _ownerID == "0") then {_ownerID = dayz_playerUID;};
|
||||
if (count _doorFriends == 0) then {_doorFriends = [[dayz_playerUID,toArray (name player)]];};
|
||||
_object setVariable ["doorfriends",_doorFriends,true];
|
||||
PVDZE_obj_Swap = [DZE_Lock_Door,_object,[_dir,_location,_ownerID,_vector],_typeOf,_cursorTarget,player,_doorFriends,dayz_authKey];
|
||||
} else {
|
||||
PVDZE_obj_Swap = [DZE_Lock_Door,_object,[_dir,_location,_vector],_typeOf,_cursorTarget,player,[],dayz_authKey];
|
||||
};
|
||||
|
||||
publicVariableServer "PVDZE_obj_Swap";
|
||||
};
|
||||
|
||||
systemChat format[localize "STR_CL_CC_CODE_CHANGED",if (_isStorage) then {if (_isSafe) then {dayz_combination} else {(dayz_combination call fnc_lockCode)}} else {DZE_Lock_Door}];
|
||||
dayz_actionInProgress = false;
|
||||
@@ -443,42 +443,78 @@ if (_canBuild select 0) then {
|
||||
|
||||
_combinationDisplay = ""; //define new display
|
||||
|
||||
switch (_lockable) do { //generate random combinations depending on item type
|
||||
call { //generate random combinations depending on item type
|
||||
|
||||
case 2: { // 2 lockbox
|
||||
_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
dayz_combination = _combination;
|
||||
if (_combination_1 == 100) then {
|
||||
_combination_1_Display = localize "STR_TEAM_RED";
|
||||
if (_lockable == 2) exitwith { // 2 lockbox
|
||||
dayz_combination = "";
|
||||
dayz_selectedVault = objNull;
|
||||
|
||||
createDialog "KeyPadUI";
|
||||
waitUntil {!dialog};
|
||||
|
||||
_combinationDisplay = dayz_combination call fnc_lockCode;
|
||||
if (keypadCancel || {typeName _combinationDisplay == "SCALAR"}) then {
|
||||
_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
dayz_combination = _combination;
|
||||
if (_combination_1 == 100) then {
|
||||
_combination_1_Display = localize "STR_TEAM_RED";
|
||||
};
|
||||
if (_combination_1 == 101) then {
|
||||
_combination_1_Display = localize "STR_TEAM_GREEN";
|
||||
};
|
||||
if (_combination_1 == 102) then {
|
||||
_combination_1_Display = localize "STR_TEAM_BLUE";
|
||||
};
|
||||
_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
|
||||
} else {
|
||||
_combination = dayz_combination;
|
||||
};
|
||||
if (_combination_1 == 101) then {
|
||||
_combination_1_Display = localize "STR_TEAM_GREEN";
|
||||
};
|
||||
if (_combination_1 == 102) then {
|
||||
_combination_1_Display = localize "STR_TEAM_BLUE";
|
||||
};
|
||||
_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
|
||||
};
|
||||
|
||||
case 3: { // 3 combolock
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
DZE_Lock_Door = _combination;
|
||||
if (_lockable == 3) exitwith { // 3 combolock
|
||||
DZE_topCombo = 0;
|
||||
DZE_midCombo = 0;
|
||||
DZE_botCombo = 0;
|
||||
DZE_Lock_Door = "";
|
||||
dayz_selectedDoor = objNull;
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
createDialog "ComboLockUI";
|
||||
waitUntil {!dialog};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
if (keypadCancel || {parseNumber DZE_Lock_Door == 0}) then {
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
DZE_Lock_Door = _combination;
|
||||
} else {
|
||||
_combination = DZE_Lock_Door;
|
||||
};
|
||||
_combinationDisplay = _combination;
|
||||
};
|
||||
|
||||
case 4: { // 4 safe
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination_4 = floor(random 10);
|
||||
_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
|
||||
dayz_combination = _combination;
|
||||
if (_lockable == 4) exitwith { // 4 safe
|
||||
dayz_combination = "";
|
||||
dayz_selectedVault = objNull;
|
||||
|
||||
createDialog "SafeKeyPad";
|
||||
waitUntil {!dialog};
|
||||
|
||||
if (keypadCancel || {(parseNumber dayz_combination) > 9999} || {count (toArray (dayz_combination)) < 4}) then {
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination_4 = floor(random 10);
|
||||
_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
|
||||
dayz_combination = _combination;
|
||||
} else {
|
||||
_combination = dayz_combination;
|
||||
};
|
||||
_combinationDisplay = _combination;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ _needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >>
|
||||
};
|
||||
if (_x == "workshop") exitwith {
|
||||
_distance = 3;
|
||||
_isNear = count (nearestObjects [_pos, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
|
||||
_isNear = count (nearestObjects [_pos, DZE_Workshops, _distance]);
|
||||
if (_isNear == 0) then {
|
||||
_abort = true;
|
||||
_reason = localize "STR_EPOCH_WORKBENCH_NEARBY";
|
||||
@@ -362,42 +362,78 @@ if (_canBuild select 0) then {
|
||||
|
||||
_combinationDisplay = "";
|
||||
|
||||
switch (_lockable) do {
|
||||
call { //generate random combinations depending on item type
|
||||
|
||||
case 2: { // 2 lockbox
|
||||
_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
dayz_combination = _combination;
|
||||
if (_combination_1 == 100) then {
|
||||
_combination_1_Display = localize "STR_TEAM_RED";
|
||||
if (_lockable == 2) exitwith { // 2 lockbox
|
||||
dayz_combination = "";
|
||||
dayz_selectedVault = objNull;
|
||||
|
||||
createDialog "KeyPadUI";
|
||||
waitUntil {!dialog};
|
||||
|
||||
_combinationDisplay = dayz_combination call fnc_lockCode;
|
||||
if (keypadCancel || {typeName _combinationDisplay == "SCALAR"}) then {
|
||||
_combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
dayz_combination = _combination;
|
||||
if (_combination_1 == 100) then {
|
||||
_combination_1_Display = localize "STR_TEAM_RED";
|
||||
};
|
||||
if (_combination_1 == 101) then {
|
||||
_combination_1_Display = localize "STR_TEAM_GREEN";
|
||||
};
|
||||
if (_combination_1 == 102) then {
|
||||
_combination_1_Display = localize "STR_TEAM_BLUE";
|
||||
};
|
||||
_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
|
||||
} else {
|
||||
_combination = dayz_combination;
|
||||
};
|
||||
if (_combination_1 == 101) then {
|
||||
_combination_1_Display = localize "STR_TEAM_GREEN";
|
||||
};
|
||||
if (_combination_1 == 102) then {
|
||||
_combination_1_Display = localize "STR_TEAM_BLUE";
|
||||
};
|
||||
_combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
|
||||
};
|
||||
|
||||
case 3: { // 3 combolock
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
DZE_Lock_Door = _combination;
|
||||
if (_lockable == 3) exitwith { // 3 combolock
|
||||
DZE_topCombo = 0;
|
||||
DZE_midCombo = 0;
|
||||
DZE_botCombo = 0;
|
||||
DZE_Lock_Door = "";
|
||||
dayz_selectedDoor = objNull;
|
||||
|
||||
dayz_actionInProgress = false;
|
||||
createDialog "ComboLockUI";
|
||||
waitUntil {!dialog};
|
||||
dayz_actionInProgress = true;
|
||||
|
||||
if (keypadCancel || {parseNumber DZE_Lock_Door == 0}) then {
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
DZE_Lock_Door = _combination;
|
||||
} else {
|
||||
_combination = DZE_Lock_Door;
|
||||
};
|
||||
_combinationDisplay = _combination;
|
||||
};
|
||||
|
||||
case 4: { // 4 safe
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination_4 = floor(random 10);
|
||||
_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
|
||||
dayz_combination = _combination;
|
||||
if (_lockable == 4) exitwith { // 4 safe
|
||||
dayz_combination = "";
|
||||
dayz_selectedVault = objNull;
|
||||
|
||||
createDialog "SafeKeyPad";
|
||||
waitUntil {!dialog};
|
||||
|
||||
if (keypadCancel || {(parseNumber dayz_combination) > 9999} || {count (toArray (dayz_combination)) < 4}) then {
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination_4 = floor(random 10);
|
||||
_combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
|
||||
dayz_combination = _combination;
|
||||
} else {
|
||||
_combination = dayz_combination;
|
||||
};
|
||||
_combinationDisplay = _combination;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -117,14 +117,25 @@ if ((count _upgrade) > 0) then {
|
||||
_object setPosATL _location;
|
||||
|
||||
if (_lockable == 3 && {!(_classname in ["WoodenGate_2_DZ","WoodenGate_3_DZ","WoodenGate_4_DZ"])}) then {
|
||||
DZE_topCombo = 0;
|
||||
DZE_midCombo = 0;
|
||||
DZE_botCombo = 0;
|
||||
DZE_Lock_Door = "";
|
||||
dayz_selectedDoor = objNull;
|
||||
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
createDialog "ComboLockUI";
|
||||
waitUntil {!dialog};
|
||||
|
||||
if (keypadCancel || {parseNumber DZE_Lock_Door == 0}) then {
|
||||
_combination_1 = floor(random 10);
|
||||
_combination_2 = floor(random 10);
|
||||
_combination_3 = floor(random 10);
|
||||
_combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
|
||||
DZE_Lock_Door = _combination;
|
||||
} else {
|
||||
_combination = DZE_Lock_Door;
|
||||
};
|
||||
_objectCharacterID = _combination;
|
||||
DZE_Lock_Door = _combination;
|
||||
|
||||
format[localize "str_epoch_player_158",_combination,_text] call dayz_rollingMessages;
|
||||
systemChat format[localize "str_epoch_player_158",_combination,_text];
|
||||
|
||||
Reference in New Issue
Block a user