Advertisement
MGT

player_unlockDoor.sqf

MGT
Jan 4th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 3.32 KB | None | 0 0
  1. /*
  2.     DayZ Unlock Door
  3.     Usage: [_obj] call player_unlockDoor;
  4.     Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
  5.     Modified for Zupa's DoorManagement.
  6. */
  7. private ["_display","_obj","_objectCharacterID","_hasAccess"];
  8.  
  9. if (!isNil "DZE_DYN_UnlockDoorInprogress") exitWith {localize "str_epoch_player_21" call dayz_rollingMessages;};
  10.  
  11. DZE_DYN_UnlockDoorInprogress = true;
  12.  
  13. // find display and check the door opening method
  14. _doorMethod = '';
  15. _displayCombo = findDisplay 41144;
  16. _displayEye = findDisplay 61144;
  17. if(!isNull _displayEye) then {_display = _displayEye; _doorMethod = "Eye";};
  18. if(!isNull _displayCombo) then {_display = _displayCombo; _doorMethod = "Combo";};
  19.  
  20. if (!isNull dayz_selectedDoor) then {
  21.     if (!isNil 'KeyCodeTryTimer') then {
  22.         if (diag_tickTime > KeyCodeTryTimer) then {
  23.             KeyCodeTry = nil;
  24.             KeyCodeTryTimer = nil;
  25.         };
  26.     };
  27.    
  28.     _obj = dayz_selectedDoor; // our target
  29.     _notNearestPlayer = _obj call dze_isnearest_player;
  30.    
  31.     if (_notNearestPlayer) then {
  32.         // close display since another player is closer
  33.         _display closeDisplay 2;
  34.         localize "STR_EPOCH_ACTIONS_16" call dayz_rollingMessages;
  35.     } else {
  36.         // get object combination
  37.         _objectCharacterID  = _obj getVariable ["CharacterID","0"];
  38.        
  39.         if(DZE_doorManagement) then {
  40.             // Check player access
  41.             _hasAccess = [player, _obj] call FNC_check_access;
  42.             if (
  43.                 (_hasAccess select 0) or // door owner
  44.                 (_hasAccess select 2) or // plot owner
  45.                 (_hasAccess select 3) or // plot friend
  46.                 (_hasAccess select 4) or // plot admin
  47.                 (_hasAccess select 5) or // door friend
  48.                 (_hasAccess select 6)    // door admin
  49.             ) then {
  50.                 DZE_Lock_Door = dayz_selectedDoor getVariable['CharacterID','0'];
  51.             };
  52.         };
  53.        
  54.        
  55.        
  56.         // Check combination
  57.         if (DZE_Lock_Door == _objectCharacterID) then {
  58.             [player,"combo_unlock",0,false] call dayz_zombieSpeak;
  59.  
  60.             // close display
  61.             _display closeDisplay 2;
  62.  
  63.             // unlock if locked
  64.             if (_obj animationPhase "Open_hinge" == 0) then {
  65.                 _obj animate ["Open_hinge", 1];
  66.             };
  67.             if (_obj animationPhase "Open_latch" == 0) then {
  68.                 _obj animate ["Open_latch", 1];
  69.             };
  70.            
  71.             if(_doorMethod == "Eye") then {
  72.                 localize "STR_EPOCH_DOORACCESS_SUCCESS" call dayz_rollingMessages;
  73.             };
  74.            
  75.             KeyCodeTry = nil;
  76.         } else {
  77.             ["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
  78.             DZE_Lock_Door = "";
  79.             [player,"combo_locked",0,false] call dayz_zombieSpeak;
  80.             [player,20,true,(getPosATL player)] spawn player_alertZombies;
  81.  
  82.             if (isNil 'KeyCodeTry') then {KeyCodeTry = 0;};
  83.             KeyCodeTry = KeyCodeTry + 1;
  84.  
  85.             if (!isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;};
  86.             if (KeyCodeTry >= ((round(random 4)) + 4)) then {  
  87.                 if (isNil 'KeyCodeTryTimer') then {KeyCodeTryTimer = diag_tickTime+10;};   
  88.                 localize "str_epoch_player_19" call dayz_rollingMessages;
  89.                 // Too many players with macros not to run this kaboom
  90.                 bomb = "GrenadeHand" createVehicle [(getpos player select 0),( getpos player select 1), 20];
  91.                 _display closeDisplay 2;
  92.             };
  93.  
  94.             if(_doorMethod == "Eye") then {
  95.                 localize "STR_EPOCH_DOORACCESS_FAILURE" call dayz_rollingMessages;
  96.                 _display closeDisplay 2;
  97.             };
  98.         };
  99.     };
  100. } else {
  101.     // close display since no target
  102.     _display closeDisplay 2;
  103. };
  104. DZE_DYN_UnlockDoorInprogress = nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement