Advertisement
Guest User

Untitled

a guest
Mar 18th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. private["_vehicle","_part","_hitpoint","_type","_selection","_array"];
  2.  
  3. if(TradeInprogress) exitWith { cutText ["Salvage 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. _isOK = false;
  14. _brokenPart = false;
  15.  
  16. //
  17. _hasToolbox = "ItemToolbox" in items player;
  18.  
  19. // moving this here because we need to know which part needed if we don't have it
  20. _nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
  21. _namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");
  22.  
  23. {_vehicle removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  24. s_player_repair_crtl = 1;
  25.  
  26. if (_hasToolbox) then {
  27.  
  28. player playActionNow "Medic";
  29.  
  30. [player,"repair",0,false] call dayz_zombieSpeak;
  31. null = [player,50,true,(getPosATL player)] spawn player_alertZombies;
  32.  
  33. r_interrupt = false;
  34. _animState = animationState player;
  35. r_doLoop = true;
  36. _started = false;
  37. _finished = false;
  38.  
  39. while {r_doLoop} do {
  40. _animState = animationState player;
  41. _isMedic = ["medic",_animState] call fnc_inString;
  42. if (_isMedic) then {
  43. _started = true;
  44. };
  45. if (_started and !_isMedic) then {
  46. r_doLoop = false;
  47. _finished = true;
  48. };
  49. if (r_interrupt) then {
  50. r_doLoop = false;
  51. };
  52. sleep 0.1;
  53. };
  54. r_doLoop = false;
  55.  
  56.  
  57. if (_finished) then {
  58.  
  59. _damage = [_vehicle,_hitpoint] call object_getHit;
  60. // _vehicle removeAction _id;
  61.  
  62. //dont allow removal of damaged parts
  63. if (_damage < 1) then {
  64.  
  65. _findPercent = (1 - _damage) * 10;
  66. if(ceil (random _findPercent) == 1) then {
  67. _isOK = true;
  68. _brokenPart = true;
  69. } else {
  70. _isOK = [player,_part] call BIS_fnc_invAdd;
  71. _brokenPart = false;
  72. };
  73.  
  74. if (_isOK) then {
  75.  
  76.  
  77.  
  78. //break the part
  79. _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
  80.  
  81. //vehicle is owned by whoever is in it, so we have to have each client try and fix it
  82. //["dayzSetFix",[_vehicle,_selection,1],_vehicle] call broadcastRpcCallIfLocal;
  83.  
  84. dayzSetFix = [_vehicle,_selection,1];
  85. publicVariable "dayzSetFix";
  86. if (local _vehicle) then {
  87. dayzSetFix call object_setFixServer;
  88. };
  89.  
  90. _vehicle setvelocity [0,0,1];
  91.  
  92. if(_brokenPart) then {
  93. //Failed!
  94. cutText [format["You have destroyed %1 while attempting to remove from %2",_namePart,_nameType], "PLAIN DOWN"];
  95. } else {
  96. //Success!
  97. cutText [format["You have successfully removed %1 from the %2",_namePart,_nameType], "PLAIN DOWN"];
  98. };
  99.  
  100.  
  101.  
  102.  
  103. } else {
  104. cutText [localize "STR_DAYZ_CODE_2", "PLAIN DOWN"];
  105. };
  106.  
  107.  
  108. };
  109.  
  110.  
  111. } else {
  112. r_interrupt = false;
  113. [objNull, player, rSwitchMove,""] call RE;
  114. player playActionNow "stop";
  115. cutText ["Canceled Salvage.", "PLAIN DOWN"];
  116. };
  117.  
  118. } else {
  119. cutText [format["You need %1 to remove this part.",_namePart], "PLAIN DOWN"];
  120. };
  121.  
  122. dayz_myCursorTarget = objNull;
  123. s_player_repair_crtl = -1;
  124.  
  125. TradeInprogress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement