Jump to content

[Request] Disabling salvaging for Locked Vehicles


Coco-Nuts

Recommended Posts

Hello,

 

Does anyone got a solution to disable the salvaging option when a vehicle is locked ?

I think it's the same process like "Disabling R3F_Log" tutorial.

 

I mean we can make a script like this :

 

In the file  "local_lockunlock.sqf" change this :

if (local _vehicle) then {
    if(_status) then {
        _vehicle setVehicleLock "LOCKED";
    } else {
        _vehicle setVehicleLock "UNLOCKED";
    };
};

To this :

if (local _vehicle) then {
    if(_status) then {
        _vehicle setVehicleLock "LOCKED";
        _vehicle setVariable ["salvage_disabled",true,true];
    } else {
        _vehicle setVehicleLock "UNLOCKED";
        _vehicle setVariable ["salvage_disabled",false,true];
    };
};

I know the file salvage.sqf or salvage_vehicle.sqf on the dayz_code should be modified.

 

Well, I ask your help to do this one working :)

 

Coco-Nuts

 

 

Link to comment
Share on other sites

You should be able to. I used the "R3F_LOG_disabled" variable for the R3F scripts because it's a variable they already use to disable its functionality. However I believe you could make whatever variable you like as long as you edit the scripts to check for it. If you're planning on using this trick for multiple scripts, it would be best to make your own universal variable for locked vehicles instead, such as "epoch_locked". Then add an "if" condition to the scripts you want to make use of it. For instance, the R3F heli-lift script has this to check for the "R3F_LOG_disabled" variable:

if !(_objet getVariable "R3F_LOG_disabled") then

If you made a variable for locked vehicles (ie. "epoch_locked"), you'd change the line to this:

if !(_objet getVariable "R3F_LOG_disabled") && !(_objet getVariable "epoch_locked") then

Note that the ! basically means "not". So this line means if both of these variables are not true (in other words, false) then the code within the if block will be performed. This would have to be applied to all the scripts within R3F that you want to disable for locked vehicles.

 

Heli-lift = heliporter.sqf

Towing = remorquer_deplace.sqf & remorquer_selection.sqf

Load in/View Vehicle Content = charger_deplace.sqf & charger_selection.sqf

 

So, to disable salvaging for locked vehicles, the easiest way would be to make an edited fn_selfactions.sqf. Copy it from your dayz_code.pbo in the compiles folder, along with compiles.sqf from the init folder to your mission file (if you don't already have edited copies of them in your mission file). In the fn_selfactions.sqf, find this line:

_menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];

and change it to look like this:

if !(_cursorTarget getVariable "epoch_locked") then {
	_menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
};

If you already had an edited fn_selfactions.sqf and compiles.sqf for something like self-bloodbagging, you can skip the last couple steps.

 

Edit the file path in this line in the compiles.sqf to point to your edited fn_selfactions.sqf:

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

Finally, edit the file path in this line of the init.sqf to point to your edited compiles.sqf:

call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";				//Compile regular functions

This should remove the salvage option altogether while the vehicle is locked. I haven't actually tried this myself, so I can't guarantee it'll work.

Link to comment
Share on other sites

I have this on my test server that I use to add mods and things before deploying to our live servers. Not fully tested but appears to work and does what you want (I think)

Removes the ability to salvage from a locked vehicle until the owner specifically unlocks the vehicle (even a key holder can't salvage until the vehicle is locked)

It does remove some of the realism since it wouldn't be possible in the real world but it's useful in some respects, also the vehicle can still be damaged (shot at etc) while its locked so damaging wheels is still possible to the extent they are 'removed' - there is no locked vehicle god mode.

 

You will need your own fn_selfActions.sqf file already in place, find the repairing vehicles section (around line 558 in my file)

 

 

//----------------- www.kaosdayz.com - MODIFIED REPAIR VEHICLE SCRIPT TO ONLY ALLOW REPAIR AND SALVAGE OF UNLOCKED VEHICLES -------------------------

//Repairing Vehicles
if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_isDisallowRepair) then {
_hasKey = _ownerID in _temp_keys;
_oldOwner = (_ownerID == dayz_playerUID);
if(!locked _cursorTarget) then {
if (s_player_repair_crtl < 0) then {
dayz_myCursorTarget = _cursorTarget;
_menu = dayz_myCursorTarget addAction ["Repair Vehicle", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
_menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "\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;
};
};
};
//----------------- www.kaosdayz.com - MODIFIED REPAIR VEHICLE SCRIPT TO ONLY ALLOW REPAIR AND SALVAGE OF UNLOCKED VEHICLES -------------------------

 

You could adapt it to allow the owner to salvage without the need to unlock it but I'm not sure how beneficial that would be.

Hope this helps.

 

Thanks,

 

kaotix

Link to comment
Share on other sites

I know this is partially off topic, but...

using this same method would it be able to disable air/lifting locked vehicles?  

 

I have seen methods where r3f checked as to whether the vehicle was locked or unlocked, which did stop the tow/lift of locked vehicles.  Unfortunately it also prevented tow/lift of natural spawns since the vehicle was neither locked or unlocked.

 

If so, how would I go about doing this?

Link to comment
Share on other sites

I don't have the airlift/tow scripts on my server but if you can show me the code I can implement the same thing into that code so locked vehicles cannot be towed or airlifted until they are unlocked by the owner.

 

 

Yeah not sure exactly everything you would need so I just dropped the whole mission file as it last was.

https://www.dropbox.com/s/2pdk07qpm8pjre3/dayz_mission.rar

Link to comment
Share on other sites

I don't have the airlift/tow scripts on my server but if you can show me the code I can implement the same thing into that code so locked vehicles cannot be towed or airlifted until they are unlocked by the owner.

I would need that too. is there a chance that you could still convert this? It would be great if you could do this and thus can prevent stealing locked vehicles (sry, google translate)

Link to comment
Share on other sites

Nice work guys.

 

Is there a way to make in "god mod" the car when it is locked using a script like that ? :

if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_isDisallowRepair) then {
        _hasKey = _ownerID in _temp_keys;
        _oldOwner = (_ownerID == dayz_playerUID);
        if (s_player_repair_crtl < 0) then {
            dayz_myCursorTarget = _cursorTarget;
            _menu = dayz_myCursorTarget addAction ["Repair Vehicle", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            s_player_repairActions set [count s_player_repairActions,_menu];
            if(!locked _cursorTarget) then {
            _menu1 = dayz_myCursorTarget addAction ["Salvage Vehicle", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            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;
        };
    };
Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...
  • 5 months later...
  • 4 months later...
  • 2 weeks later...

Did you ever fix this?

Hey DangerRuss, sorry for late reply man.....in a word, no. Didn't get a response here and had a fiddle around on my test server but, no joy.

 

Shame as would be a good script to add. Currently locked 100% health cars can't be salvaged but, all a player needs to do is a couple of hits with a hatchet, pistol or anything and then it becomes salvageable even if locked... 

 

Let me know if you get any luck as I would still like to add this.

Link to comment
Share on other sites

  • 9 months later...

Hey DangerRuss, sorry for late reply man.....in a word, no. Didn't get a response here and had a fiddle around on my test server but, no joy.

 

Shame as would be a good script to add. Currently locked 100% health cars can't be salvaged but, all a player needs to do is a couple of hits with a hatchet, pistol or anything and then it becomes salvageable even if locked... 

 

Let me know if you get any luck as I would still like to add this.

got this working on my epoch 1.0.5.1

salvage_vehicle.sqf:

private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"];

_vehicle = _this select 3;

{dayz_myCursorTarget removeAction _x} count s_player_repairActions;
s_player_repairActions = [];

_hitpoints = _vehicle call vehicle_getHitpoints;
{
	_damage = [_vehicle,_x] call object_getHit;
	_part = "PartGeneric";

	//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;

	if(["Engine",_x,false] call fnc_inString) then {
		_part = "PartEngine";
	};

	if(["HRotor",_x,false] call fnc_inString) then {
		_part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
	};

	if(["Fuel",_x,false] call fnc_inString) then {
		_part = "PartFueltank";
	};

	if(["Wheel",_x,false] call fnc_inString) then {
		_part = "PartWheel";
	};     

	if(["Glass",_x,false] call fnc_inString) then {
		_part = "PartGlass";
	};

	// allow removal of any lightly damaged parts
	if (_damage < 1) then {

		// Do not allow removal of engine or fueltanks
		if( _part == "PartGlass" || _part == "PartWheel" || _part == "PartEngine" || _part == "PartVRotor" || _part == "PartFueltank" || _part == "PartGeneric" ) then {

			_color = "color='#00ff00'"; // green
			if (_damage >= 0.1) then {_color = "color='#bfff00'";}; //light-green
			if (_damage >= 0.35) then {_color = "color='#ffff00'";}; //yellow
			if (_damage >= 0.65) then {_color = "color='#ff8800'";}; //orange
			if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red

			_percent = round(_damage*100);
			_string = format["<t %2>Remove%1 (%3 %4)</t>",_cmpt,_color,_percent,"%"]; //Remove - Part
			_handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
			s_player_repairActions set [count s_player_repairActions,_handle];

		};
	};

} count _hitpoints;

if(count _hitpoints > 0 ) then {
	_cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""];
	s_player_repairActions set [count s_player_repairActions,_cancel];
	s_player_repair_crtl = 1;
};

fn_selfActions.sqf (particular):

	//Repairing Vehicles
	if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair) then {
		if (s_player_repair_crtl < 0) then {
			dayz_myCursorTarget = _cursorTarget;
			_menu = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_REPAIRV", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
			s_player_repairActions set [count s_player_repairActions,_menu];
			if(!locked _cursorTarget) then {
				_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "custom\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
				s_player_repairActions set [count s_player_repairActions,_menu1];
			};
			s_player_repair_crtl = 1;
		} else {
			{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
			s_player_repair_crtl = -1;
		};
	};

 

Link to comment
Share on other sites

  • 3 weeks later...

got this working on my epoch 1.0.5.1

salvage_vehicle.sqf:

private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"];

_vehicle = _this select 3;

{dayz_myCursorTarget removeAction _x} count s_player_repairActions;
s_player_repairActions = [];

_hitpoints = _vehicle call vehicle_getHitpoints;
{
	_damage = [_vehicle,_x] call object_getHit;
	_part = "PartGeneric";

	//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;

	if(["Engine",_x,false] call fnc_inString) then {
		_part = "PartEngine";
	};

	if(["HRotor",_x,false] call fnc_inString) then {
		_part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
	};

	if(["Fuel",_x,false] call fnc_inString) then {
		_part = "PartFueltank";
	};

	if(["Wheel",_x,false] call fnc_inString) then {
		_part = "PartWheel";
	};     

	if(["Glass",_x,false] call fnc_inString) then {
		_part = "PartGlass";
	};

	// allow removal of any lightly damaged parts
	if (_damage < 1) then {

		// Do not allow removal of engine or fueltanks
		if( _part == "PartGlass" || _part == "PartWheel" || _part == "PartEngine" || _part == "PartVRotor" || _part == "PartFueltank" || _part == "PartGeneric" ) then {

			_color = "color='#00ff00'"; // green
			if (_damage >= 0.1) then {_color = "color='#bfff00'";}; //light-green
			if (_damage >= 0.35) then {_color = "color='#ffff00'";}; //yellow
			if (_damage >= 0.65) then {_color = "color='#ff8800'";}; //orange
			if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red

			_percent = round(_damage*100);
			_string = format["<t %2>Remove%1 (%3 %4)</t>",_cmpt,_color,_percent,"%"]; //Remove - Part
			_handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
			s_player_repairActions set [count s_player_repairActions,_handle];

		};
	};

} count _hitpoints;

if(count _hitpoints > 0 ) then {
	_cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false, "",""];
	s_player_repairActions set [count s_player_repairActions,_cancel];
	s_player_repair_crtl = 1;
};

fn_selfActions.sqf (particular):

	//Repairing Vehicles
	if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair) then {
		if (s_player_repair_crtl < 0) then {
			dayz_myCursorTarget = _cursorTarget;
			_menu = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_REPAIRV", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
			s_player_repairActions set [count s_player_repairActions,_menu];
			if(!locked _cursorTarget) then {
				_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "custom\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
				s_player_repairActions set [count s_player_repairActions,_menu1];
			};
			s_player_repair_crtl = 1;
		} else {
			{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
			s_player_repair_crtl = -1;
		};
	};

 

Thank you for this, great script.

Link to comment
Share on other sites

  • 4 months later...
On 11/9/2015 at 8:03 AM, Basti890 said:

got this working on my epoch 1.0.5.1

salvage_vehicle.sqf:


private ["_part","_cancel","_color","_percent","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints"];

_vehicle = _this select 3;

{dayz_myCursorTarget removeAction _x} count s_player_repairActions;
s_player_repairActions = [];

_hitpoints = _vehicle call vehicle_getHitpoints;
{
	_damage = [_vehicle,_x] call object_getHit;
	_part = "PartGeneric";

	//change "HitPart" to " - Part" rather than complicated string replace
	_cmpt = toArray (_x);
	_cmpt set [,20];
	_cmpt set [1,toArray ("-") select ];
	_cmpt set [2,20];
	_cmpt = toString _cmpt;

	if(["Engine",_x,false] call fnc_inString) then {
		_part = "PartEngine";
	};

	if(["HRotor",_x,false] call fnc_inString) then {
		_part = "PartVRotor"; //yes you need PartVRotor to fix HRotor LOL
	};

	if(["Fuel",_x,false] call fnc_inString) then {
		_part = "PartFueltank";
	};

	if(["Wheel",_x,false] call fnc_inString) then {
		_part = "PartWheel";
	};     

	if(["Glass",_x,false] call fnc_inString) then {
		_part = "PartGlass";
	};

	// allow removal of any lightly damaged parts
	if (_damage < 1) then {

		// Do not allow removal of engine or fueltanks
		if( _part == "PartGlass" || _part == "PartWheel" || _part == "PartEngine" || _part == "PartVRotor" || _part == "PartFueltank" || _part == "PartGeneric" ) then {

			_color = "color='#00ff00'"; // green
			if (_damage >= 0.1) then {_color = "color='#bfff00'";}; //light-green
			if (_damage >= 0.35) then {_color = "color='#ffff00'";}; //yellow
			if (_damage >= 0.65) then {_color = "color='#ff8800'";}; //orange
			if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red

			_percent = round(_damage*100);
			_string = format["<t %2>Remove%1 (%3 %4)</t>",_cmpt,_color,_percent,"%"]; //Remove - Part
			_handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\salvage.sqf",[_vehicle,_part,_x], , false, true, "",""];
			s_player_repairActions set [count s_player_repairActions,_handle];

		};
	};

} count _hitpoints;

if(count _hitpoints >  ) then {
	_cancel = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_CANCEL", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", , true, false, "",""];
	s_player_repairActions set [count s_player_repairActions,_cancel];
	s_player_repair_crtl = 1;
};

fn_selfActions.sqf (particular):


	//Repairing Vehicles
	if ((dayz_myCursorTarget != _cursorTarget) && _isVehicle && !_isMan && _hasToolbox && (damage _cursorTarget < 1) && !_isDisallowRepair) then {
		if (s_player_repair_crtl < ) then {
			dayz_myCursorTarget = _cursorTarget;
			_menu = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_REPAIRV", "\z\addons\dayz_code\actions\repair_vehicle.sqf",_cursorTarget, , true, false, "",""];
			s_player_repairActions set [count s_player_repairActions,_menu];
			if(!locked _cursorTarget) then {
				_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "custom\salvage_vehicle.sqf",_cursorTarget, , true, false, "",""];
				s_player_repairActions set [count s_player_repairActions,_menu1];
			};
			s_player_repair_crtl = 1;
		} else {
			{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
			s_player_repair_crtl = -1;
		};
	};

 

This script works flawlessly on my server. Epoch 1.0.5.1, No longer can players salvage locked vehicles

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...