Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_repairDoor.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Re-locks the door mainly for the federal reserve structures.
  8. */
  9. private ["_building","_doors","_door","_cP","_cpRate","_ui","_title","_titleText","_locked"];
  10. _building = param [0,objNull,[objNull]];
  11. if (isNull _building) exitWith {};
  12. if (!(_building isKindOf "House_F")) exitWith {hint localize "STR_ISTR_Bolt_NotNear";};
  13.  
  14. _doors = 1;
  15. _doors = FETCH_CONFIG2(getNumber,"CfgVehicles",(typeOf _building),"NumberOfDoors");
  16. _door = 0;
  17. //Find the nearest door
  18. for "_i" from 1 to _doors do {
  19. _selPos = _building selectionPosition format ["Door_%1_trigger",_i];
  20. _worldSpace = _building modelToWorld _selPos;
  21. if (player distance _worldSpace < 5) exitWith {_door = _i;};
  22. };
  23.  
  24. if (_door isEqualTo 0) exitWith {hint localize "STR_Cop_NotaDoor"}; //Not near a door to be broken into.
  25. _doorN = _building getVariable [format ["bis_disabled_Door_%1",_door],0];
  26. if (_doorN isEqualTo 1) exitWith {hint localize "STR_House_FedDoor_Locked"};
  27. life_action_inUse = true;
  28.  
  29. closeDialog 0;
  30. //Setup the progress bar
  31. disableSerialization;
  32. _title = localize "STR_Cop_RepairingDoor";
  33. "progressBar" cutRsc ["life_progress","PLAIN"];
  34. _ui = uiNamespace getVariable "life_progress";
  35. _progressBar = _ui displayCtrl 38201;
  36. _titleText = _ui displayCtrl 38202;
  37. _titleText ctrlSetText format ["%2 (1%1)...","%",_title];
  38. _progressBar progressSetPosition 0.01;
  39. _cP = 0.01;
  40.  
  41. switch (typeOf _building) do {
  42. case "Land_Reserve_Federale_Smith": {_cpRate = 0.008;};
  43. case "Land_Reserve_Federale_Smith";
  44. case "Land_Reserve_Federale_Smith": {_cpRate = 0.005;};
  45. default {_cpRate = 0.08;}
  46. };
  47.  
  48. for "_i" from 0 to 1 step 0 do {
  49. if (animationState player != "AinvPknlMstpSnonWnonDnon_medic_1") then {
  50. [player,"AinvPknlMstpSnonWnonDnon_medic_1",true] remoteExecCall ["life_fnc_animSync",RCLIENT];
  51. player switchMove "AinvPknlMstpSnonWnonDnon_medic_1";
  52. player playMoveNow "AinvPknlMstpSnonWnonDnon_medic_1";
  53. };
  54. uiSleep 0.26;
  55. if (isNull _ui) then {
  56. "progressBar" cutRsc ["life_progress","PLAIN"];
  57. _ui = uiNamespace getVariable "life_progress";
  58. };
  59. _cP = _cP + _cpRate;
  60. _progressBar progressSetPosition _cP;
  61. _titleText ctrlSetText format ["%3 (%1%2)...",round(_cP * 100),"%",_title];
  62. if (_cP >= 1 || !alive player) exitWith {};
  63. if (life_interrupted) exitWith {};
  64. };
  65.  
  66. //Kill the UI display and check for various states
  67. "progressBar" cutText ["","PLAIN"];
  68. player playActionNow "stop";
  69. if (!alive player) exitWith {life_action_inUse = false;};
  70. if (life_interrupted) exitWith {life_interrupted = false; titleText[localize "STR_NOTF_ActionCancel","PLAIN"]; life_action_inUse = false;};
  71. life_action_inUse = false;
  72.  
  73. _building animateSource [format ["Door_%1_source", _door], 0];
  74. _building setVariable [format ["bis_disabled_Door_%1",_door],1,true]; //Lock the door.
  75.  
  76. _locked = true;
  77. for "_i" from 1 to _doors do {
  78. if ((_building getVariable [format ["bis_disabled_Door_%1",_i],0]) isEqualTo 0) exitWith {_locked = false};
  79. };
  80.  
  81. if (_locked) then {
  82. _building setVariable ["locked",true,true];
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement