Add logging failed safe/lockbox and door lock/unlock/failed code attempts (#1853)

* Add logging failed safe/lockbox and door lock/unlock/failed code attempts

This adds logging for both safes and lockboxes for failed code attempts.

Also adds logging for locking, unlocking and failed code attempts for
doors.

"salival (playerUID) FAILED unlocking LockBox with code: Red11 (actual:
Red57) @110069 [11044.4,8438.32,0.652]"
"salival (playerUID) UNLOCKED LockBox with code: Green22 @110069
[11040.6,8438.91,0.834]"
"salival (playerUID) PACKED LockBox with code: Green22 @110069
[11040.6,8438.91,0.834]"
"salival (playerUID) UNLOCKED CinderWallDoorSmallLocked_DZ with code:
559 @110069 [11015.4,8458.74,5.272]"
"salival (playerUID) LOCKED CinderWallDoorSmallLocked_DZ with code: 559
@110069 [11015.4,8458.74,5.272]"
"salival (playerUID) FAILED unlocking CinderWallDoorSmallLocked_DZ with
code: EYESCAN (actual: 559) @110069 [11015.4,8458.74,5.272]"
"salival (playerUID) FAILED unlocking CinderWallDoorSmallLocked_DZ with
code: 100 (actual: 559) @110069 [11015.4,8458.74,5.272]"
"salival (playerUID) UNLOCKED CinderWallDoorSmallLocked_DZ with code:
559 @110069 [11015.4,8458.74,5.272]"
"salival (playerUID) LOCKED CinderWallDoorSmallLocked_DZ with code: 559
@110069 [11015.4,8458.74,5.272]"

* Revert wrong hinge type

* Remove unused DZE_Lock_Door

* Rework

* Remove redundant code, Make single currency costs use BIS_fnc_numberText

* Rework

* Add changelog line
This commit is contained in:
oiad
2017-01-06 10:45:10 +13:00
committed by ebayShopper
parent 731175f46b
commit d0257b3c7d
7 changed files with 106 additions and 78 deletions

View File

@@ -1,8 +1,9 @@
private ["_backpacks","_charID","_clientID","_dir","_holder","_lockCode","_lockColor","_lockedClass","_magazines","_name","_obj","_objectID","_objectUID","_ownerID","_packedClass","_player","_playerUID","_pos","_status","_statusText","_type","_unlockedClass","_vector","_weapons"];
private ["_backpacks","_charID","_clientID","_dir","_holder","_lockCode","_lockColor","_lockedClass","_magazines","_name","_obj","_objectID","_objectUID","_ownerID","_packedClass","_player","_playerUID","_pos","_status","_statusText","_type","_unlockedClass","_vector","_weapons","_message","_suppliedCode","_fnc_lockCode"];
_player = _this select 0;
_obj = _this select 1;
_status = _this select 2;
if (count _this > 3) then {_suppliedCode = _this select 3;};
_name = if (alive _player) then {name _player} else {"Dead Player"};
_type = typeOf _obj;
@@ -13,7 +14,7 @@ _charID = _obj getVariable ["CharacterID","0"];
_objectID = _obj getVariable ["ObjectID","0"];
_objectUID = _obj getVariable ["ObjectUID","0"];
_ownerID = _obj getVariable ["ownerPUID","0"];
_lockCode = "0";
_lockCode = _charID;
// Player may have disconnected or died before message send. Attempt lock/unlock/pack/save procedure anyway
if (isNull _player) then {diag_log "ERROR: server_handleSafeGear called with Null player object";};
@@ -22,15 +23,21 @@ _clientID = owner _player;
_playerUID = getPlayerUID _player;
_statusText = switch (_status) do {
case 0: {"UNLOCKED"};
case 1: {"LOCKED"};
case 2: {"PACKED"};
case 0: {"UNLOCKED"}; // unlock safe/lockbox
case 1: {"LOCKED"}; // lock safe/lockbox
case 2: {"PACKED"}; // pack safe/lockbox
case 3: {"FAILED unlocking"}; // failed unlock safe/lockbox
case 4: {"LOCKED"}; // lock door
case 5: {"UNLOCKED"}; // unlock door
case 6: {"FAILED unlocking"}; // failed unlocking door
};
if (isNull _obj) exitWith {
diag_log format["ERROR: server_handleSafeGear called with Null safe object by %1(%2). %3 attempt failed.",_name,_playerUID,_statusText];
dze_waiting = "fail";
_clientID publicVariableClient "dze_waiting";
diag_log format["ERROR: server_handleSafeGear called with Null object by %1 (%2). %3 attempt failed.",_name,_playerUID,_statusText];
if (_status < 3) then {
dze_waiting = "fail";
_clientID publicVariableClient "dze_waiting";
};
};
switch (_status) do {
@@ -104,27 +111,46 @@ switch (_status) do {
};
};
_type = switch _type do {
case "VaultStorage";
case "VaultStorageLocked": {
_lockCode = _charID;
"Safe"
};
case "LockboxStorage";
case "LockboxStorageLocked": {
_lockColor = "";
_lockCode = parseNumber _charID;
_lockCode = _lockCode - 10000;
if (_lockCode <= 99) then { _lockColor = "Red"; };
if (_lockCode >= 100 && _lockCode <= 199) then { _lockColor = "Green"; _lockCode = _lockCode - 100; };
if (_lockCode >= 200) then { _lockColor = "Blue"; _lockCode = _lockCode - 200; };
if (_lockCode <= 9) then { _lockCode = format["0%1", _lockCode]; };
_lockCode = format ["%1%2",_lockColor,_lockCode];
"LockBox"
_fnc_lockCode = {
private ["_color","_code"];
if (_this == "") exitWith {0};
_color = "";
_code = if (typeName _this == "STRING") then {parseNumber _this} else {_this};
_code = _code - 10000;
if (_code <= 99) then {_color = localize "STR_TEAM_RED";};
if (_code >= 100 && _code <= 199) then {_color = localize "STR_TEAM_GREEN"; _code = _code - 100;};
if (_code >= 200) then {_color = localize "STR_TEAM_BLUE"; _code = _code - 200;};
if (_code <= 9) then {_code = format["0%1", _code];};
_code = format ["%1%2",_color,_code];
_code
};
if (_status < 4) then {
_type = switch _type do {
case "VaultStorage";
case "VaultStorageLocked": {
"Safe"
};
case "LockboxStorage";
case "LockboxStorageLocked": {
_lockCode = _charID call _fnc_lockCode;
if (_status == 3) then {_suppliedCode = _suppliedCode call _fnc_lockCode;};
"LockBox"
};
};
};
diag_log format["%1 (%2) %3 %4 with code: %5 @%6 (%7)",_name,_playerUID,_statusText,_type,_lockCode,mapGridPosition _pos,_pos];
if (_statusText == "FAILED unlocking") then {
_message = format["%1 (%2) %3 %4 with code: %5 (actual: %8) @%6 %7",_name,_playerUID,_statusText,_type,_suppliedCode,mapGridPosition _pos,_pos,_lockCode];
} else {
_message = format["%1 (%2) %3 %4 with code: %5 @%6 %7",_name,_playerUID,_statusText,_type,_lockCode,mapGridPosition _pos,_pos];
};
dze_waiting = "success";
_clientID publicVariableClient "dze_waiting";
diag_log _message;
if (_status < 3) then {
dze_waiting = "success";
_clientID publicVariableClient "dze_waiting";
};