dayz 1.8.0.3 vehicle salvage w/o duping

Sharkking

Valued Member!
So far only tested with 1.8.0.3 should work with any 1.8 version.

1) Addons\dayz_code\compile\fn_selfActions.sqf

find
Code:
//repairing Vehicles
uncomment the salvage part
Code:
    //Repairing Vehicles
    if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1)) then {
        if (s_player_repair_crtl < 0) then {
            dayz_myCursorTarget = _cursorTarget;
            _menu = dayz_myCursorTarget addAction [localize "str_actions_rapairveh", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            _menu1 = dayz_myCursorTarget addAction [localize "str_actions_salvageveh", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            s_player_repairActions set [count s_player_repairActions,_menu];
            s_player_repairActions set [count s_player_repairActions,_menu1];
            s_player_repair_crtl = 1;
        } else {
            {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
            s_player_repair_crtl = -1;
        };
    };

2) Addons\dayz_code\actions\salvage_vehicle.sqf

replace salvage_vehicle.sqf with http://pastebin.com/17EL5pA2 (copy and paste from different scripts, all credits to the authors)

find
Code:
        if (_damage < 0.11) then {  //allow only parts < 10% damage to be salvaged
and adjust to any value you like

3) Addons\dayz_code\actions\salvage.sqf

find
Code:
if ((_hitpoint == "HitEngine") or (_hitpoint == "HitFuel")) then {
      [_vehicle, _selection, 0.89] call fnc_veh_handleDam;
} else {
       [_vehicle, _selection, 1] call fnc_veh_handleDam;
};

replace with

Code:
if ((_hitpoint == "HitEngine") or (_hitpoint == "HitFuel")) then {
                    [_vehicle, _selection, 0.89, 0, 0, true] call fnc_veh_handleDam;
                } else {
                    [_vehicle, _selection, 1, 0, 0, true] call fnc_veh_handleDam;
                };

this fixed (for me) the behavior that vehicle parts could be removed over and over again after server restart when no player had entered the vehicle.
 
Last edited:
Code:
private ["_vehicle","_part","_hitpoint","_type","_selection","_array","_started","_finished","_animState","_isMedic","_isOK","_brokenPart","_findPercent","_damage","_hasToolbox","_nameType","_namePart"];

if (dayz_salvageInProgress) exitWith { cutText [localize "str_salvage_inprogress", "PLAIN DOWN"]; };
dayz_salvageInProgress = true;

_array =     _this select 3;
_vehicle =     _array select 0;
_part =        _array select 1;
_hitpoint = _array select 2;
_type = typeOf _vehicle; 


_isOK = false;
_brokenPart = false;
_started = false;
_finished = false;

_hasToolbox = "ItemToolbox" in items player;
//_hasCrowbar = "ItemCrowbar" in items player;

_nameType = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
_namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");

{_vehicle removeAction _x} forEach s_player_repairActions;
 s_player_repairActions = [];
s_player_repair_crtl = 1;

//if (_hasToolbox and _hasCrowbar) then {
if (_hasToolbox) then {
    player playActionNow "Medic";

    [player,"repair",0,false] call dayz_zombieSpeak;
    [player,20,true,(getPosATL player)] call player_alertZombies;

    sleep 5;
   

        _damage = [_vehicle,_hitpoint] call object_getHit;
        if (_damage < 1) then {
        _findPercent = (1 - _damage) * 10;
            if(ceil (random _findPercent) == 1) then {
                _isOK = true;
                _brokenPart = false;
            } else {
                _isOK = [player,_part] call BIS_fnc_invAdd;
                _brokenPart = false;
            };
               
            if (_isOK) then {
                _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
               
                if ((_hitpoint == "HitEngine") or (_hitpoint == "HitFuel")) then {
                    [_vehicle, _selection, 0.89, 0, 0, true] call fnc_veh_handleDam;
                } else {
                    [_vehicle, _selection, 1, 0, 0, true] call fnc_veh_handleDam;
                };
                _vehicle call fnc_veh_ResetEH;
                _vehicle setvelocity [0,0,1];
                if(_brokenPart) then {
                        cutText [format[localize "str_salvage_destroyed",_namePart,_nameType], "PLAIN DOWN"];
                } else {
                        cutText [format[localize "str_salvage_removed",_namePart,_nameType], "PLAIN DOWN"];
                };
            } else {
                cutText [localize "str_player_24", "PLAIN DOWN"];
            };
        };
} else {
    cutText ["Toolbox and Crowbar are required to salvage.", "PLAIN DOWN"];
};

dayz_myCursorTarget = objNull;
s_player_repair_crtl = -1;

dayz_salvageInProgress = false;
 
I have followed the instructions here but I do not get the option to remove parts in-game, are there some more edits missing fromm the guide ?
 
please note that you have to move the files to MPMissions folder and customize compiles.sqf and fn_selfactions.sqf (i guess it was described 100 times somewhere else).to point there
 
Thanks, I had forgotten to use the cstom fn_selfactions.sqf which I had within the missions folder. Awesome job, ty !
 
please note that you have to move the files to MPMissions folder and customize compiles.sqf and fn_selfactions.sqf (i guess it was described 100 times somewhere else).to point there

Hi Sharkking and thanks for taking the time to explain this script!
However, it would be awesome if you could include that in your original post. The fact that it has been described 100 times somewhere else does not really help.

Tried this myself and did not succeed. Move what files? Copy them out of the DayZ code to the missions folder? How do one customize compiles and self actions to point there?

Please explain more thorough.

Thanks buddy.
 
For me:
In my mission.pbo:
- In the init.sqf there is a line: call compile preprocessFileLineNumbers "Scripts\compiles.sqf"; //Compile custom compiles
This was added by me as part of the auto-bloodbag script.

- That is the folder where I need to edit the compiles.sqf file for additional scripts I add.

In the compiles.sqf (mentioned above) is the following line: fnc_usec_selfActions = compile preprocessFileLineNumbers "Scripts\fn_selfActions.sqf"; // fnc_usec_selfActions - adds custom actions to dayz code
This means that the fn_selfActions.sqf I need to edit for additional scripts I add.

So in layman's:
* The init.sqf file tells where to find the compiles.sqf
* The compiles.sqf tells where to find the fn_selfActions.sqf

I hope that makes some sense for you mate.


The problem I am having is that the vehicles don't actually have the items removed from them & it is possible to dupe unlimited parts :(
 
Back
Top