Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"];
  2.  
  3. // [ _trader_id, _category, _action ];
  4. // _activatingPlayer = _this select 1;
  5.  
  6. _vehicle = _this select 3;
  7.  
  8. {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  9. // dayz_myCursorTarget = _vehicle;
  10.  
  11. //_allFixed = true;
  12. _hitpoints = _vehicle call vehicle_getHitpoints;
  13. //diag_log format["DEBUG SALVAGE: %1", _hitpoints];
  14. {
  15. _damage = [_vehicle,_x] call object_getHit;
  16. _part = "PartGeneric";
  17.  
  18. //change "HitPart" to " - Part" rather than complicated string replace
  19. _cmpt = toArray (_x);
  20. _cmpt set [0,20];
  21. _cmpt set [1,toArray ("-") select 0];
  22. _cmpt set [2,20];
  23. _cmpt = toString _cmpt;
  24.  
  25. if(["Engine",_x,false] call fnc_inString) then {
  26. _part = "PartEngine";
  27. };
  28.  
  29. if(["HRotor",_x,false] call fnc_inString) then {
  30. _part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
  31. };
  32.  
  33. if(["Fuel",_x,false] call fnc_inString) then {
  34. _part = "PartFueltank";
  35. };
  36.  
  37. if(["Wheel",_x,false] call fnc_inString) then {
  38. _part = "PartWheel";
  39. };
  40.  
  41. if(["Glass",_x,false] call fnc_inString) then {
  42. _part = "PartGlass";
  43. };
  44.  
  45. // allow removal of any lightly damaged parts
  46. if (_damage < 1 ) then {
  47.  
  48. // Do not allow removal of engine or fueltanks
  49. if( _part == "PartGlass" or _part == "PartWheel" or _part == "PartEngine" or _part == "PartVRotor" or _part == "PartFueltank" or _part == "PartGeneric" ) then {
  50.  
  51. _color = "color='#ffff00'"; //yellow
  52. if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
  53. if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red
  54.  
  55. _percent = round(_damage*100);
  56. _string = format["<t %2>Remove%1 (%3 %4)</t>",_cmpt,_color,_percent,"%"]; //Remove - Part
  57. _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
  58. s_player_repairActions set [count s_player_repairActions,_handle];
  59.  
  60. };
  61. };
  62.  
  63. } forEach _hitpoints;
  64.  
  65. if(count _hitpoints > 0 ) then {
  66.  
  67. _cancel = dayz_myCursorTarget addAction ["Cancel", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""];
  68. s_player_repairActions set [count s_player_repairActions,_cancel];
  69. s_player_repair_crtl = 1;
  70. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement