Jump to content

[Tutorial/Release] Disable the salvage vehicle option while in trader city


WAE

Recommended Posts

Hey guys, firstly, I would like to apologise for anything wrong in this thread. It's currently nearly 6am in the morning and I haven't slept :D Also, there's the fact that I haven't tested this much, so if you discover any bugs (not that there will be), let me know. If there is an easier way to do this too, like a variable in the init.sqf, pls be quiet, I didn't notice :P

 

Basically, I've been playing on Epoch with some members of the community I am apart of, and we have seen many complaints of salvaging from vehicles while in trader zones in side chat. For our server, we would like to completely remove this and after tweaking the salvage vehicle script, I thought I'd release it here as a helping hand for other server admins/owners. Also, excuse me if this has already been done. I know it's simple, but I haven't actually searched that thoroughly on the forums, I did a quick search and didn't find anything, so I ended up here!

 

Step 1) Download the two attached files and put them in the root of your mission file in a folder called custom.

 

Step 2a) If you already have a custom compiles and fn_selfActions, skip this, otherwise, move onto 2b & 2c.

 

Step 2b I) To create a custom fn_selfActions (which is what we need), you're going to need a custom compiles.sqf file. To do this, go to @DayZ_Epoch\addons and open dayz_code.pbo with any PBO software. For this example, I'm using PBO Manager.

 

Step 2b II) Inside this PBO, extract the file located at this directory: init\compiles.sqf to the "custom" folder in your mission root directory.

 

Step 2b III) In your init.sqf file, replace the following:

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

With:

call compile preprocessFileLineNumbers "custom\compiles.sqf"; //Compile regular functions

You've now got a custom compiles.sqf

 

Step 2c I) For a custom fn_selfActions.sqf, copy the file in the dayz_code PBO located at compile\fn_selfActions.sqf to the "custom" folder in your mission directory.

 

Step 2c II) In your compiles.sqf that you recently just copied, change the following:

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

To:

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

You've now got a custom compiles and fn_selfActions.sqf

 

After creating your custom files, it's time to get on with the actual script its self!

 

Step 3) In your fn_selfActions.sqf, replace the following:

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

With:

_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "custom\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];

That code will be located somewhere around here:

//Repairing Vehicles
	if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_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, "",""];
//			_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
            _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,_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;
		};
	};

I have commented out the old code in case I need to replace it, but yours should look similar to that.

 

Step 4) [Optional] If you used a different folder name to the one I said to use, the following lines need to be updated with the new names:

 

In salvage_vehicle.sqf:

_handle = dayz_myCursorTarget addAction [_string, "custom\salvage.sqf",[_vehicle,_part,_x], 0, false, true, "",""];

Replace that with whatever your folder name is.

 

And you're done!

 

Let me know what you think of this, I think it's quite handy and simple to do.

 

DOWNLOAD:

 

Salvage.sqf: http://www.mediafire.com/view/s8a3feya8d9g8ac/salvage.sqf

Salvage_vehicle.sqf: http://www.mediafire.com/view/13xfk7sccovy32m/salvage_vehicle.sqf

 

Sorry they are not github links, I have no clue how to use it :P

 

Link to comment
Share on other sites

why not just remove the option via selfAction if the player is in tradezone? most server have some sort of tradezone that sets a variable on the player when they enter a trade zone. In the selfAction just test if that variable is true and if it is, don't show the salvage option if that's what you want?

 

A guy actually messaged me about this, basically, I made this script for my server and shared it. We all preferred to have the vehicle show up then tell the user they are not allowed to salvage from it otherwise we could probably end up having bug reports submitted saying that salvage doesn't work, there are dumb people like that in the world :D But yeah, you can change it if you want, just did it this way because this is how we preferred it.

 

 

It was actually fun to read this , its  a nice script ,i will put it in my server , The DAYZ NECROPOLIS DEV. Team Says thanks!!

http://www.speedtest.net/result/3444525156.png

 

 

Thanks man! <3

Link to comment
Share on other sites

There's a much easier way to do this using safezones WAE.

 

Set a new variable in variables.sqf:

inSafeZone = false;

then in fn_selfActions.sqf set the variable:

if (!inSafeZone) then {
			_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
			s_player_repairActions set [count s_player_repairActions,_menu1];
			};

credits to maca for this.

Link to comment
Share on other sites

There's a much easier way to do this using safezones WAE.

 

Set a new variable in variables.sqf:

inSafeZone = false;

then in fn_selfActions.sqf set the variable:

if (!inSafeZone) then {
			_menu1 = dayz_myCursorTarget addAction [localize "STR_EPOCH_PLAYER_SALVAGEV", "\z\addons\dayz_code\actions\salvage_vehicle.sqf",_cursorTarget, 0, true, false, "",""];
			s_player_repairActions set [count s_player_repairActions,_menu1];
			};

credits to maca for this.

 

I know it's easier, just read the reply above yours that I posted to some other guy, I did it like I did because of a reason lol.

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

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...