Remove Parts From Vehicles v1.8

Davison Silva

New Member
Remove Parts From Vehicles

By: Unkinhead

Credits: Jaimbo

Fixed: NeverUsedID

Adapted by: Davison


Working in 1.8.0.3

Unpack your mission.pbo with PBOview (or another PBO unpacker)

Create a folder called: custom in mission files.

Copy the init.sqf from "dayz_code\system\mission" for custom folder.

in the init.sqf in the dayz_chernarus(mission.pbo) find:

Code:
#include "\z\addons\dayz_code\system\mission\init.sqf"

and replace by:

Code:
#include "custom\init.sqf"

Copy the compiles.sqf from "dayz_code\init" into your custom folder

In the init.sqf in the custom folder replace:

Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";

with

Code:
call compile preprocessFileLineNumbers "custom\compiles.sqf";

You can use the compiles.sqf to override majority of the files in "dayz_code\compile" folder. We are going to use it to override the function "fn_selfAction.sqf" so:

Copy the fn_selfActions.sqf in "dayz_code\compile" to your custom folder

Open the compiles.sqf in the custom folder and find:

Code:
fnc_usec_selfActions =        compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf";        //Checks which actions for self

Replace it with:

Code:
fnc_usec_selfActions =        compile preprocessFileLineNumbers "custom\fn_selfActions.sqf";

Now open the fn_SelfActions.sqf you need is to add this at line 7 in fn_selfaction:

Code:
private ["_hastinitem","_canPickLight","_text","_driver","_hasRawMeat","_isFuel","_menu","_isHarvested","_isVehicle","_isVehicletype","_isMan","_ownerID","_isAnimal","_isZombie","_isDestructable","_isTent","_isStash","_isMediumStash","_hasFuel20","_hasFuel5","_isAlive","_canmove","_isPlant","_rawmeat","_vehicle","_inVehicle","_hasFuelE20","_hasFuelE5","_cursorTarget","_hasbottleitem","_primaryWeapon","_currentWeapon","_hasKnife","_hasToolbox","_onLadder","_nearLight","_canDo","_part"];

In fn_SelfActions.sqf in the mission.pbo and find:

Code:
//Sleep
 
    if(_cursorTarget isKindOf "TentStorage" and _canDo and _ownerID == dayz_characterID) then {
 
        if ((s_player_sleep < 0) and (player distance _cursorTarget < 3)) then {
 
            s_player_sleep = player addAction [localize "str_actions_self_sleep", "\z\addons\dayz_code\actions\player_sleep.sqf",_cursorTarget, 0, false, true, "",""];
 
        };
 
    } else {
 
        player removeAction s_player_sleep;
 
        s_player_sleep = -1;
 
    };

Right underneath the last line above, insert(NEW CODE):

Code:
 // Remove Parts from Vehicles - By SilverShot - 1.8 fix by NeverUsedID www.die-philosoffen.com
 
    if( !_isMan and _canDo and _hasToolbox and (silver_myCursorTarget != cursorTarget) and cursorTarget isKindOf "AllVehicles" and (getDammage cursorTarget < 0.95) ) then {
 
        _vehicle = cursorTarget;
 
        //Frank aka Wofu: Added check for busline, to prevent players from removing parts from the tourbusses.
 
        _invalidVehicle = (_vehicle isKindOf "Motorcycle") or (_vehicle isKindOf "Tractor"); //or ([_vehicle] call isDPBus);
 
        if( !_invalidVehicle ) then {
 
            {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;
 
            s_player_removeActions = [];
 
            silver_myCursorTarget = _vehicle;
 
            _hitpoints = _vehicle call vehicle_getHitpoints;
 
        {
 
        _damage = [_vehicle,_x] call object_getHit;
 
        if( _damage < 0.15 ) then {
 
        //change "HitPart" to " - Part" rather than complicated string replace
 
        _cmpt = toArray (_x);
 
        _cmpt set [0,20];
 
        _cmpt set [1,toArray ("-") select 0];
 
        _cmpt set [2,20];
 
        _cmpt = toString _cmpt;
 
        _skip = true;
 
        if( _skip and _x == "HitFuel" ) then { _skip = false; _part = "PartFueltank"; _cmpt = _cmpt + "tank"};
 
        if( _skip and _x == "HitEngine" ) then { _skip = false; _part = "PartEngine"; };
 
        if( _skip and _x == "HitLFWheel" ) then { _skip = false; _part = "PartWheel"; };
 
        if( _skip and _x == "HitRFWheel" ) then { _skip = false; _part = "PartWheel"; };
 
        if( _skip and _x == "HitLBWheel" ) then { _skip = false; _part = "PartWheel"; };
 
        if( _skip and _x == "HitRBWheel" ) then { _skip = false; _part = "PartWheel"; };
 
        if( _skip and _x == "HitGlass1" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitGlass2" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitGlass3" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitGlass4" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitGlass5" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitGlass6" ) then { _skip = false; _part = "PartGlass"; };
 
        if( _skip and _x == "HitHRotor" ) then { _skip = false; _part = "PartVRotor"; };
 
        if (!_skip ) then {
 
        _string = format["<t color='#ff00ff'>Remove%1</t>",_cmpt,_color]; //Remove - Part
 
        _handle = silver_myCursorTarget addAction [_string, "custom\ss_remove.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
 
        s_player_removeActions set [count s_player_removeActions,_handle];
 
        };
 
    };
 
    } forEach _hitpoints;
 
    };
 
};

Now find:

Code:
//Engineering

And right above that line add:

Code:
//Extras
 
//Remove Parts
 
{silver_myCursorTarget removeAction _x} forEach s_player_removeActions;s_player_removeActions = [];
 
silver_myCursorTarget = objNull;

now open you text editor(Notepad, Notepad ++) copy the code:

Code:
// Remove Parts from Vehicles - By SilverShot.
 
// added anti dupingcode, dayz 1.7.7 compatibility and some description by NeverUsedID - www.die-philosoffen.com
 
private["_vehicle","_part","_hitpoint","_type","_selection","_array"];
 
_id = _this select 2;
 
_array =    _this select 3;
 
_vehicle =    _array select 0;
 
_part =        _array select 1;
 
_hitpoint = _array select 2;
 
_type = typeOf _vehicle;
 
_hasToolbox =    "ItemToolbox" in items player;
 
_nameType =        getText(configFile >> "cfgVehicles" >> _type >> "displayName");
 
_namePart =        getText(configFile >> "cfgMagazines" >> _part >> "displayName");
 
if (_hasToolbox) then {
 
    if (getDammage _vehicle < 2) then {
 
        _damage = [_vehicle,_hitpoint] call object_getHit;
 
        //check if part is not damaged and remove it
 
        if( _damage < 0.20 ) then {
 
                {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;
 
                s_player_removeActions = [];
 
                silver_myCursorTarget = objNull;
 
                _selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
 
                //check if part is engine or fueltank, otherwise vehicle will explode if damage is set to 1.
 
                if( _hitpoint == "HitEngine" or _hitpoint == "HitFuel" ) then {
 
                    _total = [_vehicle,  _selection, 0.89,  _array, "zombie", true] call fnc_veh_handleDam;
 
                } else {
 
                    // set damage to 1
 
                    _total = [_vehicle,  _selection, 1,  _array, "zombie", true] call fnc_veh_handleDam;
 
                };
 
                //play animation
 
                player playActionNow "Medic";
 
                sleep 1;
 
                [player,"repair",0,false] call dayz_zombieSpeak;
 
                null = [player,10,true,(getPosATL player)] spawn player_alertZombies;
 
                sleep 5;
 
                _vehicle setvelocity [0,0,1];
 
            //recheck damage to be sure that part is removed from vehicle
 
                _damage = [_vehicle,_hitpoint] call object_getHit;
 
                if( _damage > 0.20 ) then {
 
                        _result = [player,_part] call BIS_fnc_invAdd;
 
                        //check if there is enough space in inventar
 
                        if (_result) then {
 
                            cutText [format["You have successfully taken %1 from the %2",_namePart,_nameType], "PLAIN DOWN"];
 
                        } else {
 
                            //if not enought space say "not enough space"
 
                            cutText [localize "str_player_24", "PLAIN DOWN"];
 
                            //and add the part back to the vehicle.
 
                            [_vehicle, _selection, 0, true] call fnc_veh_handleRepair;
 
                        };
 
                };
 
            } else {
 
            cutText [format["Cannot remove %1 from %2, the part has been damaged.",_namePart,_nameType], "PLAIN DOWN"];
 
        };
 
    } else {
 
        {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;
 
        s_player_removeActions = [];
 
        silver_myCursorTarget = objNull;
 
    };
 
};
 
if( silver_myCursorTarget != objNull ) then {
 
    {silver_myCursorTarget removeAction _x} forEach s_player_removeActions;
 
    s_player_removeActions = [];
 
    silver_myCursorTarget = objNull;
 
};
 
//update vehicle in database
 
[_vehicle,_type] spawn server_updateObject;

and paste in you text editor, save as: ss_remove.sqf

copy the ss_remove.sqf to custom folder in mission.pbo

end.

any questions, just ask.:D
 
you do not have enought room for that.

it always said that but in my character he has 12 slot :eek:

after update to 1.8.0.2
 
Back
Top