Advertisement
Guest User

ori_upgrade

a guest
Jul 13th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. private ["_isOk","_vehicle","_part","_hitpoint","_type","_selection","_array","_started","_finished","_animState","_isMedic","_num_removed","_damage","_dis","_sfx","_allFixed","_id","_hasToolbox","_section","_nameType","_namePart","_hitpoints","_mt","_nameClass1","_st","_cfg","_tc"];
  2.  
  3. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_92") , "PLAIN DOWN"]; };
  4. DZE_ActionInProgress = true;
  5.  
  6. _id = _this select 2;
  7. _array = _this select 3;
  8.  
  9. _vehicle = _array select 0;
  10. _part = _array select 1;
  11. _hitpoint = _array select 2;
  12. _type = typeOf _vehicle;
  13. _selection = "";
  14. _st = "";
  15. _hasToolbox = "ItemToolbox" in items player;
  16. _section = _part in magazines player;
  17.  
  18. // moving this here because we need to know which part needed if we don't have it
  19. _nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
  20. _namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");
  21. _isOk = true;
  22. s_player_repair_crtl = 1;
  23.  
  24. if (_section && _hasToolbox) then {
  25.  
  26. player playActionNow "Medic";
  27. _sfx = "repair";
  28. _dis=0;
  29. [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
  30. [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
  31.  
  32. r_interrupt = false;
  33. _animState = animationState player;
  34. r_doLoop = true;
  35. _started = false;
  36. _finished = false;
  37.  
  38. while {r_doLoop} do {
  39. _animState = animationState player;
  40. _isMedic = ["medic",_animState] call fnc_inString;
  41. if (_isMedic) then {
  42. _started = true;
  43. };
  44. if (_started && !_isMedic) then {
  45. r_doLoop = false;
  46. _finished = true;
  47. };
  48. if (r_interrupt) then {
  49. r_doLoop = false;
  50. };
  51. sleep 0.1;
  52. };
  53. r_doLoop = false;
  54.  
  55. if (_finished) then {
  56. player removeMagazine _part;
  57.  
  58. _cfg = configFile >> "CfgVehicles" >> typeof _vehicle >> "AnimationSources";
  59. _tc = count _cfg;
  60. for "_mti" from 0 to _tc-1 do {
  61. _mt = (_cfg select _mti);
  62. _st = configName(_mt);
  63. if (_st==_hitpoint) then { _selection = _st; };
  64. };
  65.  
  66. //Damage 0 = Upgrade | Damage 1 = Kein Upgrade
  67. PVDZE_veh_SFix = [_vehicle,_selection,0];
  68. publicVariable "PVDZE_veh_SFix";
  69. if (local _vehicle) then {
  70. PVDZE_veh_SFix call object_setFixServer;
  71. };
  72.  
  73. player playActionNow "Medic";
  74. sleep 1;
  75.  
  76. _dis=20;
  77. _sfx = "repair";
  78. [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
  79. [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
  80. sleep 5;
  81. _vehicle setvelocity [0,0,1];
  82.  
  83. //Success!
  84. cutText [format[(localize "str_epoch_player_166"),_namePart,_nameType], "PLAIN DOWN"];
  85. } else {
  86. r_interrupt = false;
  87. if (vehicle player == player) then {
  88. [objNull, player, rSwitchMove,""] call RE;
  89. player playActionNow "stop";
  90. };
  91. cutText [(localize "str_epoch_player_93"), "PLAIN DOWN"];
  92. };
  93.  
  94. } else {
  95. cutText [format[(localize "str_epoch_player_167"),_namePart], "PLAIN DOWN"];
  96. };
  97.  
  98. {dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
  99. dayz_myCursorTarget = objNull;
  100.  
  101. //check if repaired fully
  102. _hitpoints = _vehicle call vehicle_getHitpoints;
  103. _allFixed = true;
  104. {
  105. _damage = [_vehicle,_x] call object_getHit;
  106. if (_damage > 0) exitWith {
  107. _allFixed = false;
  108. };
  109. } count _hitpoints;
  110.  
  111. //update if repaired
  112. if (_allFixed) then {
  113. _vehicle setDamage 0;
  114. //["PVDZE_veh_Update",[_vehicle,"repair"]] call callRpcProcedure;
  115. PVDZE_veh_SFix = [_vehicle,_selection,0];
  116. publicVariable "PVDZE_veh_SFix";
  117. if (local _vehicle) then {
  118. PVDZE_veh_SFix call object_setFixServer;
  119. };
  120. };
  121.  
  122. s_player_repair_crtl = -1;
  123.  
  124. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement