Making vehicles with certain variables un-salvageable.

Inkko

Valued Member!
My issue is that I have made it so players are able craft some vehicles on my dayz 1.8.0.3 server, I have the AI mission system as well. Vehicles players make use the same variable as the AI mission system since that simplified changes for me. My issue is the materials needed to make the vehicles can be salvaged along with more then what was used to create the vehicle in the first place and I wanted to disable salvage on vehicles with that specific variable. It would also help with the AI missions aswell if those vehicles were un-salvageable too sort of a "sign" that they wont be there next restart.
 
I've tried altering the fn_selfactions and using a if statement with getting the variable of vehicles to check and make sure its not the variable I'm using but I can't seem to get it to work.
 
Here is an example that prevents people from Salvaging locked vehicles on Epoch:
http://epochmod.com/forum/index.php...abling-salvaging-for-locked-vehicles/?p=16496

You could modify it to check for Mission variable == 1 instead of checking if it is locked. Here I did it for you using the code from 1.0.8.3 fn_selfactions.sqf:
Code:
  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, "",""];
       s_player_repairActions set [count s_player_repairActions,_menu];
       if !(_cursorTarget getVariable "Mission" == 1) then {
       _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,_menu1];};
       s_player_repair_crtl = 1;
     } else {
       {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
       s_player_repair_crtl = -1;
     };
   };

lmk if it works ;)
I tested it out and it removes the salvage option from all vehicles which was what I was having trouble with. It also makes it so when you select repair, on any vehicle with the mission variable, all vehicles are un-repairable and you are stuck with the save "vehicle name" from the vehicle you tried repairing.
 
^ Salvage should show up on all vehicles except those with Mission == 1. That is what this is for:
Code:
if !(_cursorTarget getVariable "Mission" == 1) then {

Are you using a separate salvage vehicle script? 1.0.8.3 has it built in to the mod now, so it is no longer necessary to use a script like SilverShot's. Also if you have antihack make sure you have the actions allowed:
Code:
str_actions_salvageveh,str_actions_rapairveh,s_player_repairActions,s_player_repair_crtl
It should work but it doesn't for some reason lol, I'm using the built in salvage script and it works perfectly fine without any changes. But with that change to check for the mission variable or the way I tried it:
Code:
 if (_cursorTarget getVariable "Mission" != 1 ) then {
breaks the salvage portion for all vehicles and adds that weird save vehicle bug.
 
hmm weird, try this:
Code:
  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, "",""];
  s_player_repairActions set [count s_player_repairActions,_menu];
    _missionveh = (_cursorTarget getVariable "Mission" == 1);
  if !(_missionveh) then {
  _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,_menu1];};
  s_player_repair_crtl = 1;
  } else {
  {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
  s_player_repair_crtl = -1;
  };
  };
Just tried that out as well and its resulting in the same issue.
 
I'm using blurs anti-hack and I have check actions false, the salvage works perfectly fine normally. Did some tests with one of the admin tool functions and quickly checked some variables on hive cars vs mission variable cars. Using getVariable "Mission" resulted in Hive vehicles coming back null and mission vehicles coming back 1. I think I was fooling around with the addaction portion of the script and got it to show the salvage script on each type of vehicle but the menus contained nothing.
 
Maybe thats the issue now that I'm thinking about it... Could it be because the database vehicles come back null? Can a vehicle not be compared to a variable its not been assigned to in an expression and thats why it is not working?

Maybe I should try assigning the ObjectUID variable to the mission vehicles since it seems that database vehicles have that variable attached to them.
 
assign this to your vehicles
Code:
_object setVariable["fake",true,true];

then in your fn_selfActions.sqf
create a new variable
Code:
_isFake = cursorTarget getVariable ["fake",true];

then in your fn_selfActions.sqf
add that _isFake variable into the if check for salvaging.
Code:
    //Repairing Vehicles
    if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1) and !_isFake) 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;
        };
    };

Didnt not test this and it is off the top of my head but i supose that should work.
Otherwhise try playing around with the
Code:
!_isFake and _isFake
and
Code:
_isFake = cursorTarget getVariable ["fake",true];
_isFake = cursorTarget getVariable ["fake",false];
 
Well I ended up doing something different.
Code:
    //Repairing Vehicles
    if ((dayz_myCursorTarget != _cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage _cursorTarget < 1)) then {
    if (_cursorTarget getVariable "Mission" == 1) exitWith {cutText [format["Cannot repair, salvage, or siphon temporary vehicles."], "PLAIN DOWN"];};
        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;
        };
    };
My issue now is that the message is spammed and I would like it to only occur once. maybe moving the exit statement somewhere else would fix this?

Currently this seems to remove repair and salvage, I have the same exitWith in the siphon portion that removes that action aswell. So no Mission variable vehicles can be siphoned, repaired, or salvaged. I have auto refuel at gas stations so they can atleast be refueled that way.
 
Back
Top