Adding salivals Change Code to Epoch Core

This commit is contained in:
AirwavesMan
2020-07-23 22:20:58 +02:00
parent 04a81c15c3
commit 5e296fc092
12 changed files with 364 additions and 81 deletions

View File

@@ -458,7 +458,7 @@ class ComboLockUI
y = 0.762017;
w = 0.201064;
h = 0.233964;
onButtonClick = "keypadCancel = false; if (!isNull dayz_selectedDoor) then {call player_unlockDoor;};";
onButtonClick = "keypadCancel = false; if (!isNull dayz_selectedDoor) then {call player_unlockDoor;} else {((ctrlParent (_this select 0)) closeDisplay 2);};";
};
};
};

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

View File

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

View File

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

View File

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

View File

@@ -655,11 +655,16 @@ if (!isNull _cursorTarget && {!_inVehicle} && {!_isPZombie} && {player distance
if (s_player_packvault < 0) then {
s_player_packvault = player addAction [format["<t color='#ff0000'>%1</t>",format[localize "STR_EPOCH_ACTIONS_PACK",_text]], "\z\addons\dayz_code\actions\vault_pack.sqf",_cursorTarget, 0, false, true];
};
if (s_player_changeVaultCode < 0 && (_characterID == dayz_combination || _ownerID == _uid)) then {
s_player_changeVaultCode = player addAction [format[localize "STR_CL_CC_CODE_CHANGE",_text], "\z\addons\dayz_code\actions\changeCode.sqf",_cursorTarget, 0, false, true];
};
} else {
player removeAction s_player_packvault;
s_player_packvault = -1;
player removeAction s_player_lockvault;
s_player_lockvault = -1;
player removeAction s_player_changeVaultCode;
s_player_changeVaultCode = -1;
};
//Player Deaths
@@ -723,23 +728,30 @@ if (!isNull _cursorTarget && {!_inVehicle} && {!_isPZombie} && {player distance
};
// downgrade system
if (DZE_Lock_Door == _characterID && {!keypadCancel} && {_cursorTarget isKindOf "Land_DZE_WoodDoorLocked_Base" || _cursorTarget isKindOf "CinderWallDoorLocked_DZ_Base"}) then {
if ((s_player_lastTarget select 1) != _cursorTarget) then {
if (s_player_downgrade_build > 0) then {
player removeAction s_player_downgrade_build;
s_player_downgrade_build = -1;
if (DZE_Lock_Door == _characterID && !keypadCancel) then {
if (_cursorTarget isKindOf "Land_DZE_WoodDoorLocked_Base" || _cursorTarget isKindOf "CinderWallDoorLocked_DZ_Base") then {
if ((s_player_lastTarget select 1) != _cursorTarget) then {
if (s_player_downgrade_build > 0) then {
player removeAction s_player_downgrade_build;
s_player_downgrade_build = -1;
};
};
};
if (s_player_downgrade_build < 0) then {
_hasAccess = [player, _cursorTarget] call FNC_check_access;
if ((_hasAccess select 0) || {_hasAccess select 2} || {_hasAccess select 3}) then {
s_player_lastTarget set [1,_cursorTarget];
s_player_downgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_REMLOCK",_text], "\z\addons\dayz_code\actions\player_buildingDowngrade.sqf",_cursorTarget, -2, false, true];
if (s_player_downgrade_build < 0) then {
_hasAccess = [player, _cursorTarget] call FNC_check_access;
if ((_hasAccess select 0) || {_hasAccess select 2} || {_hasAccess select 3}) then {
s_player_lastTarget set [1,_cursorTarget];
s_player_downgrade_build = player addAction [format[localize "STR_EPOCH_ACTIONS_REMLOCK",_text], "\z\addons\dayz_code\actions\player_buildingDowngrade.sqf",_cursorTarget, -2, false, true];
};
};
};
if (s_player_changeDoorCode < 0 && {_typeOfCursorTarget in DZE_DoorsLocked}) then {
s_player_changeDoorCode = player addAction [format[localize "STR_CL_CC_CODE_CHANGE",_text], "\z\addons\dayz_code\actions\changeCode.sqf",_cursorTarget, 0, false, true];
};
} else {
player removeAction s_player_downgrade_build;
s_player_downgrade_build = -1;
player removeAction s_player_changeDoorCode;
s_player_changeDoorCode = -1;
};
// inplace maintenance tool
@@ -996,6 +1008,10 @@ if (!isNull _cursorTarget && {!_inVehicle} && {!_isPZombie} && {player distance
s_player_manageDoor = -1;
player removeAction s_player_hide_body;
s_player_hide_body = -1;
player removeAction s_player_changeDoorCode;
s_player_changeDoorCode = -1;
player removeAction s_player_changeVaultCode;
s_player_changeVaultCode = -1;
};
//Dog actions on player self

View File

@@ -197,6 +197,8 @@ if (!isDedicated) then {
vectorActions = -1;
s_player_manageDoor = -1;
s_player_hide_body = -1;
s_player_changeDoorCode = -1;
s_player_changeVaultCode = -1;
};
call dayz_resetSelfActions;

View File

@@ -0,0 +1,83 @@
/*
changeCode - Safe, Lockbox and Door code changing script by salival (https://github.com/oiad)
*/
"SK_changeCode" addPublicVariableEventHandler {(_this select 1) call server_changeCode};
server_changeCode = {
private ["_backpacks","_charID","_characterID","_clientID","_coins","_dir","_holder","_inventory","_key","_lockedClass","_magazines","_message","_name","_object","_objectID","_objectUID","_ownerID","_ownerPUID","_player","_playerUID","_pos","_typeOf","_vector","_weapons","_worldSpace","_clientKey","_exitReason"];
if (count _this < 4) exitWith {diag_log "server_changeCode error: Improper parameter format";};
_player = _this select 0;
_object = _this select 1;
_characterID = _this select 2;
_clientKey = _this select 3;
_typeOf = typeOf _object;
if !(_typeOf in DZE_unlockedStorage) exitWith {diag_log "server_changeCode called with invalid storage object!"};
_lockedClass = getText (configFile >> "CfgVehicles" >> _typeOf >> "lockedClass");
_pos = _object getVariable ["OEMPos",getPosATL _object];
_dir = getDir _object;
_vector = [vectorDir _object, vectorUp _object];
_charID = _object getVariable ["CharacterID","0"];
_objectID = _object getVariable ["ObjectID","0"];
_objectUID = _object getVariable ["ObjectUID","0"];
_ownerID = _object getVariable ["ownerPUID","0"];
//_name = if (alive _player) then {name _player;} else {"unknown player";};
_name = ["unknown player",name _player] select (alive _player);
_clientID = owner _player;
_playerUID = getPlayerUID _player;
if (isNull _player) then {diag_log "ERROR: server_changeCode called with Null player object";};
if (isNull _object) exitWith {diag_log format["ERROR: server_changeCode called with Null object by %1 (%2).",_name,_playerUID];};
_exitReason = [_this,"changeCode",_pos,_clientKey,_PlayerUID,_player] call server_verifySender;
if (_exitReason != "") exitWith {diag_log _exitReason};
_weapons = getWeaponCargo _object;
_magazines = getMagazineCargo _object;
_backpacks = getBackpackCargo _object;
if (Z_singleCurrency) then {_coins = _object getVariable [Z_MoneyVariable,0];};
[_objectID,_objectUID,_object] call server_deleteObjDirect;
_holder = _lockedClass createVehicle [0,0,0];
_holder setDir _dir;
_holder setVariable ["memDir",_dir,true];
_holder setVectorDirAndUp _vector;
_holder setPosATL _pos;
_holder setVariable ["CharacterID",_characterID,true];
_holder setVariable ["OEMPos",_pos,true];
if (DZE_permanentPlot) then {
_ownerPUID = if (_charID == "0000" || _charID == "10000") then {_playerUID} else {_ownerID};
_worldSpace = [_dir,_pos,_ownerPUID,_vector];
_holder setVariable ["ownerPUID",_ownerPUID,true];
} else {
_worldSpace = [_dir,_pos];
};
if (Z_singleCurrency) then {_holder setVariable [Z_MoneyVariable,_coins,true];};
_objectUID = _worldSpace call dayz_objectUID2;
_holder setVariable ["ObjectUID",_objectUID,true];
deleteVehicle _object;
_inventory = [_weapons,_magazines,_backpacks];
_holder setVariable ["WeaponCargo",_weapons,false];
_holder setVariable ["MagazineCargo",_magazines,false];
_holder setVariable ["BackpackCargo",_backpacks,false];
[_characterID,_holder,_worldSpace,_inventory,_player,_clientKey] call server_publishObj;
if (Z_singleCurrency) then {
_key = format["CHILD:309:%1:",_objectUID] + str _inventory + ":" + str _coins + ":";
_key call server_hiveWrite;
};
_message = format ["CHANGE CODE: %1 (%2) changed the code for %3 to %4 @%5 %6",_name,_playerUID,_lockedClass,_characterID,mapGridPosition _player,_pos];
diag_log _message;
};

View File

@@ -83,7 +83,7 @@ if (DZE_GodModeBase && {!(_class in DZE_GodModeBaseExclude)}) then {
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
if (count _inv > 0) then {
if (count _inv > 0 && {_class in ["Wooden_shed2_DZ","WoodShack2_DZ","StorageShed2_DZ","GunRack2_DZ","WoodCrate2_DZ","VaultStorage2Locked","LockboxStorage2Locked","TentStorage0","TentStorage1","TentStorage2","TentStorage3","TentStorage4""DomeTentStorage0","DomeTentStorage1","DomeTentStorage2","DomeTentStorage3","DomeTentStorage4","DesertTentStorage0","DesertTentStorage1","DesertTentStorage2","DesertTentStorage3","DesertTentStorage4","StashSmall1","StashSmall2","StashSmall3","StashSmall4","StashMedium","StashMedium1","StashMedium2","StashMedium3","StashMedium4"]}) then {
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
};

View File

@@ -50,6 +50,8 @@ spawn_mineveins = compile preprocessFileLineNumbers "\z\addons\dayz_server\compi
spawn_roadblocks = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\spawn_roadblocks.sqf";
spawn_vehicles = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\spawn_vehicles.sqf";
call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_changeCode.sqf";
server_medicalSync = {
private ["_player","_array"];
@@ -253,4 +255,4 @@ array_reduceSize = {
// Precise base building 1.0.5
call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\kk_functions.sqf";
#include "mission_check.sqf"
#include "mission_check.sqf"