Advertisement
Guest User

Untitled

a guest
Mar 18th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. private["_vehicle","_part","_hitpoint","_type","_selection","_array"];
  2.  
  3. if(TradeInprogress) exitWith { cutText ["Repair already in progress." , "PLAIN DOWN"]; };
  4. TradeInprogress = true;
  5.  
  6. _id = _this select 2;
  7. _array = _this select 3;
  8. _vehicle = _array select 0;
  9. _part = _array select 1;
  10. _hitpoint = _array select 2;
  11. _type = typeOf _vehicle;
  12.  
  13. //
  14. _hasToolbox = "ItemToolbox" in items player;
  15. _section = _part in magazines player;
  16.  
  17. // moving this here because we need to know which part needed if we don't have it
  18. _nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
  19. _namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");
  20.  
  21. s_player_repair_crtl = 1;
  22.  
  23. if (_section and _hasToolbox) then {
  24.  
  25. player playActionNow "Medic";
  26.  
  27. _dis=20;
  28. _sfx = "repair";
  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 and !_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.  
  56. if (_finished) then {
  57.  
  58. _damage = [_vehicle,_hitpoint] call object_getHit;
  59. _vehicle removeAction _id;
  60.  
  61. //dont waste loot on undamaged parts
  62. if (_damage > 0) then {
  63.  
  64. player removeMagazine _part;
  65.  
  66. //Fix the part
  67. _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
  68.  
  69. //vehicle is owned by whoever is in it, so we have to have each client try and fix it
  70. dayzSetFix = [_vehicle,_selection,0];
  71. publicVariable "dayzSetFix";
  72. if (local _vehicle) then {
  73. dayzSetFix call object_setFixServer;
  74. };
  75.  
  76. _vehicle setvelocity [0,0,1];
  77.  
  78. //Success!
  79. cutText [format["You have successfully attached %1 to the %2",_namePart,_nameType], "PLAIN DOWN"];
  80.  
  81. };
  82.  
  83. } else {
  84. r_interrupt = false;
  85. [objNull, player, rSwitchMove,""] call RE;
  86. player playActionNow "stop";
  87. cutText ["Canceled Repair.", "PLAIN DOWN"];
  88. };
  89.  
  90. } else {
  91. cutText [format["You need %1 to repair this",_namePart], "PLAIN DOWN"];
  92. };
  93.  
  94. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  95. dayz_myCursorTarget = objNull;
  96.  
  97. //check if repaired fully
  98. _hitpoints = _vehicle call vehicle_getHitpoints;
  99. _allFixed = true;
  100. {
  101. _damage = [_vehicle,_x] call object_getHit;
  102. if (_damage > 0) exitWith {
  103. _allFixed = false;
  104. };
  105. } forEach _hitpoints;
  106.  
  107. //update if repaired
  108. if (_allFixed) then {
  109. _vehicle setDamage 0;
  110. ["dayzUpdateVehicle",[_vehicle,"repair"]] call callRpcProcedure;
  111. dayzSetFix = [_vehicle,_selection,0];
  112. publicVariable "dayzSetFix";
  113. if (local _vehicle) then {
  114. dayzSetFix call object_setFixServer;
  115. };
  116. };
  117.  
  118. s_player_repair_crtl = -1;
  119.  
  120. TradeInprogress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement