[Problem] Scripted-In Vehicles repair themselves

Deathcall

Well-Known Member
Hello everyone,

I'd like to consult with you on the following matter:

I'm working on an event for my server in which we'll populate a bridge with wreckage and abandoned cars and have people fight over resources on the bridge.

In order to make it look realistic, I've damaged most of the vehicles, setting their armor to 30% (or around that) and manually removing parts like wheels or glasses.

The problem I have is that, while on the mission editor everything is peachy, when I spawn the vehicles on the server, as soon as I approach them, they self repair completely.

I've been looking into the server_updateObject.sqf and the server_cleanup.fsm but I can't find where this behaviour is set. After fumbling on files for hours, I decided it was about time I went for help.

If anyone can shine some light on this issue, I'd be really thankful.
 
Update:

It doesn't seem to be proximity, it seems the repairing happens when STARING at the vehicle... No idea... this boggles my mind more and more.
 
This has been an issue with DayZ for as long as I have been playing it (over a year).
If you can find a solution you would be my hero and everyone else's I'm sure!
 
Are you sure we are speaking of the same problem?

I am aware that sometimes vehicles spawned in through normal means (DB entries) fix themselves for no apparent reason. Sometimes this happens after fixing a part, which then fixes everything, or maybe just coming in and out, but rarely have I seen the vehicle fixing itself just because the player looked at it...

In my case, I'm talking about vehicles I bring into the server through a script activated through admin panel commands. All the vehicles I bring in have a good amount of damage and missing parts. The problem is that looking at them intently (maybe it's when you get scroll wheel options on them) makes it so they fix themselves automatically and without exception.

Every vehicle spawned in by script does this inevitably after being looked at. This doesn't happen with vehicles spawned through the normal ways.

I am thinking that it has something to do with them not being in the DB, but I've looked through the aforementioned files in the server.pbo and I can't find a mechanic that would be responsible for completely repairing these vehicles.

I truly don't think we are on the same problem here. I've always credited the one you mentioned to lag and DB issues, but it's never something CONSTANT, it's not like you can rely on the bug happening... on my case, it's EVERY time, without fault.
 
Seems to happen to some vehicles more than others, but I have witnessed vehicles repair themselves before my eyes. Without even touching them or using the scrollwheel or anything. Simply standing near them.
Happened to me today as a matter of fact, simply approaching a policecar. It appeared in need of repair, then suddenly, all shiny and new!
 
I'm going to simplify the problem so as to eliminate any possible garbage data from the equation and just work with the core factors...

Problem is:

I create a script to spawn a vehicle someplace on the map. (createVehicle command, nothing fancy)
In the script, I set the damage of the vehicle to 0.25.
I call the script from the init.sqf ([]execVM "script.sqf")
I start the server.
I go to the vehicle.
As soon as I look at it (and get scroll wheel options on it), the vehicle resets to fully fixed.
This is not random, this happens EVERY time without exception to any kind of vehicle I spawn.
This doesn't happen consistently (or remotely often) with DB spawned vehicles.

This is annoying because I need the vehicle to look damaged. It also allows players to remove parts from the vehicle that are supposed to be broken.

Other modifications done to the vehicle, like for example blocking the driver's seat, are unaffected. Fuel is unaffected as well, but ammo gets replenished completely.

I can damage the vehicle, but if I get close to it again, it completely fixes itself once more. If the vehicle is blown up, then it remains blown up.

I've been looking at the server compile folder and the regular compile folder for the script responsible for this odd behavior. If I had to guess, I'd say that it has to be with these vehicles not registered on the DB... but I'm not sure.

If anyone has any clues, I'd really appreciate the help.
 
If the vehicles don't have defined damaged parts and have a health of < 100% then they will repair when the repair menu is opened. You must define the damaged parts so when the repair menu opens it doesn't lists everything as fine and doesn't run the repair code.
 
Thanks for the insight.

This is the complete line for one of the vehicles, this still repairs itself when approached:
Code:
  _this = createVehicle ["LandRover_CZ_EP1", [6773.7432, 2746.2935, 1.1013361], [], 0, "CAN_COLLIDE"];
  _this setDir -90.336632;
  _this setPos [6773.7432, 2746.2935, 1.1013361];
  _this setVectorUp [0,0,0.1];
  _this setVehicleArmor 0.30945283;
  _this setFuel 0;
  _this setVehicleAmmo 0;
  _this setVehicleLock "LOCKED";
  _this setHit ["wheel_1_1_steering", 1];
  _this setHit ["wheel_1_2_steering", 1];
  _this setHit ["wheel_2_1_steering", 1];
  _this setHit ["wheel_2_2_steering", 1];
  _this setHit ["Glass1", 1];
  _this setHit ["Glass2", 1];
  _this setHit ["Glass3", 1];
}

What am I missing? I think I was pretty thorough with this.
 
I've been looking into this repair thing you mention, is it possible that it's THIS script that's causing the problem?
Code:
        //Repairing Vehicles
    if ((dayz_myCursorTarget != cursorTarget) and _isVehicle and !_isMan and _hasToolbox and (damage cursorTarget < 1)) then {
        _vehicle = cursorTarget;
        {dayz_myCursorTarget removeAction _x} forEach s_player_repairActions;s_player_repairActions = [];
        dayz_myCursorTarget = _vehicle;
 
        _allFixed = true;
        _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";
            };
 
            // get every damaged part no matter how tiny damage is!
            if (_damage > 0) then {
               
                _allFixed = false;
                _color = "color='#ffff00'"; //yellow
                if (_damage >= 0.5) then {_color = "color='#ff8800'";}; //orange
                if (_damage >= 0.9) then {_color = "color='#ff0000'";}; //red
 
                _string = format["<t %2>Repair%1</t>",_cmpt,_color]; //Repair - Part
                _handle = dayz_myCursorTarget addAction [_string, "\z\addons\dayz_code\actions\repair.sqf",[_vehicle,_part,_x], 0, false, true, "",""];
                s_player_repairActions set [count s_player_repairActions,_handle];
 
            };
                   
        } forEach _hitpoints;
[B]        if (_allFixed) then {[/B]
[B]            _vehicle setDamage 0;[/B]
        };
    };

Does setDamage return ammo to a vehicle as well?
 
Back
Top