[Release] Realistic Vehicle Failure

vehicle
realistic

#1

Realistic Vehicle Failure & Repair v1.1.1 (Jan.17th 2018)

This is a mod for FiveM / GTA V that aims to create realistic vehicle failure and repair.

New in version 1.1.1: See this post

Previous versions:
New in version 1.0: See this post
New in version 0.6: See this post
New in version 0.5: See this post

Features:

Realistic Vehicle Failure

  • Makes the vehicle fail faster and more realistic.
  • Shooting windows, kicking the car, throwing baseballs or snowballs at it will NOT disable the car!
  • Shooting at the engine or fuel tank will damage the vehicle, but not necessarily disable it completely.
  • When sustaining a certain amount of damage, the car will begin to degrade quickly and finally die.
  • Car will slow down progressively as damage increases.
  • Increases visual damage a lot (Please note that visual damage doesn’t sync well to other players)
  • A vehicle that’s upside down or on its side can’t be turned over by the usual steering trick.
  • Car doesn’t just stop suddenly when hitting something, but will often degrade, smoke and sputter before dying, and finally roll to a stop.
  • Optional limp mode. If enabled, the vehicle will not die completely, but be able to drive very slowly.
  • Random tire burst. Set the desired interval (statistical probability, not exact) you want to experience a puncture.
  • Car will not catch fire or explode, not even when landing on the roof.
  • Car is still reenterable, so you can fix it with a trainer.
  • Everything is configurable so you can fine tune the behavior to your liking
  • You can still put armor on the car to improve its resistance to abuse.
  • Sunday driver feature: Smooth acceleration and braking. Easy speed control makes it much easier to drive a steady slow speed. Brake holder feature prevents vehicle from switching direction after braking, and keeps the brakelight on while holding the brake.
  • Compatibility mode. Solves some problems with other scripts that causes random vehicle failures.

Realistic Vehicle Repair

  • Type /repair in the chat to repair your vehicle. There are two types of repairs, depending on your location:

At the mechanic

  • If you are at a mechanic your vehicle will be completely fixed, as good as new.
  • Mechanics are located several places in San Andreas. Look for the blips on the map.

Not at a mechanic

  • If you are not at a mechanic, you may be able to perform a DIY emergency repair in the field.
  • You can only reattach the oil plug once or twice, but after that, the vehicle will be beyond repair.
  • An emergency repair in the field will only make the car drivable, not completely fixed. A minor accident will most likely kill the car again.
  • If you let the damaged car sit too long, the oil will drain completely, preventing further repairs.
  • Electric vehicles can not be fixed by you, only by a mechanic. Technology is complex, and chewing gum just won’t fix a dead battery.

Configuration

Lots of settings in config.lua.
Each option is explained in the file.
Be careful. Weird settings can cause weird behavior.
If you restart the script (as you should after changing the settings) exit the car first, or spawn/steal a new car after. Failure to do so may cause odd behavior of the current car.

Installation

Disable or remove other vehicle health scripts. Running two or more vehicle health scripts will give unpredictable results

FiveM Server

If you run a FiveM server, you know what to do… but these are the basic instructions, in case you forgot:

  • Copy the .lua files to a new folder in your Resources folder
  • Add a line to your config: start [foldername]
  • Restart server or
  • Refresh + start [foldername]

Where [foldername] is the folder in Resources where the .lua files are located.

Download:

Background

I have tried a bunch of vehicle damage scripts, and none of them were just perfect, so I chose to solve the problem the easy way: Learn Lua scripting and FiveM. Hope you enjoy!


[Release] Sunday Driver
/fix script like DOJ
[Release] Engine ON/OFF Toggle
Vehicle Air Control
Looking for someone to add mods to our server
[Release]DUFX
Time Extend for burning vehicles?
[Release] CarHud Modified and Better Looking (V.1.5) (Now with Race Mode and Race Mode 2) (New Update)
[Release]DUFX
#2

Moved to #development:releases


#3

You sir, you’re a legend.


#4

Awesome release, thanks for this


#5

What about the planes, helicopters and so on? Is this only for cars?


#6

Wowowowow.

Very well done good sir.


#7

The script is active for all types of vehicles.
Bicycles doesn’t seem to be able to take damage unless you bomb them.
Planes and helicopters are still able to explode if you crash them.

I have done a fair bit of testing to ensure that no vehicle types behaves completely unreasonable with the script active. But I must admit that I haven’t tested each and every vehicle in the game.


#8

Are you on the FiveM discord? I wanted to touch base w/ you on something in regards to this.


#9

Very nice script. Did a little testing and it works flawless. Very realistic.


#10

Little edit you can add…

Citizen.CreateThread(function()
	while true do
	Citizen.Wait(50)
		local ped = GetPlayerPed(-1)
		if IsPedInAnyVehicle(ped, false) then		
			local vehicle = GetVehiclePedIsUsing(ped)
			local healthEngineCurrent = GetVehicleEngineHealth(vehicle)
			local healthEngineNew = healthEngineCurrent
			local healthBodyCurrent = GetVehicleBodyHealth(vehicle)
			local healthBodyNew = healthBodyCurrent
			local healthPetrolTankCurrent = GetVehiclePetrolTankHealth(vehicle)
			local healthPetrolTankNew = healthPetrolTankCurrent 
			if healthEngineCurrent > 2 and healthPetrolTankCurrent > 2 then
				SetVehicleUndriveable(vehicle,false)
				SetVehicleEnginePowerMultiplier(vehicle, 70.0) --HERE SET POWER
			    SetVehicleEngineTorqueMultiplier(vehicle, 0.70)	-- & HERE SET TORQUE (These are my most realistic values)
			end

You can set top speed/acceleration … also affected by damage. These settings are pretty realistic but feel free to play around and have some fun :wink:


#11

i tried many different thing, but how can we set lower damage? because was driving and did an accident with other vehicle and couldn’t drive anymore.
help would be apprecieated


#12

The point of the mod is to make failure more realistic. In real life your car is often disabled in rather low speed accidents.

If you feel the car is too easily damaged, you can change one or two numbers at the top of the client.lua file:

local damageFactor = 15.0
local cascadingFailureSpeedFactor = 10

Try setting damageFactor to a lower number to make the cars more resilient to crashes.
The cascadingFailureSpeedFactor determines how fast the engine will self-destruct when the vehicle health drops below a certain point. Lowering this number will make the car work for a longer time, even after being badly damaged.

Think of it this way:
You can damage the car somewhat and it will still be drivable. But when the oil starts leaking, the car will self-destruct no matter what. It’s just a matter of time.
The first variable determines how fast you reach the oil-leak point.
The second variable determines how fast the oil will leak.

Remember to restart the script after editing!


#13

Thank you for the suggestion. Might need some refinement to avoid problems with setting the torque and power multipliers through a trainer. A simple implementation would for example prevent making cars really driftable.
Will think about it.


#14

Excellent script. Thank you!


#15

New version released. This one adds Realistic Vehicle Repair

  • Type /repair in the chat to repair your vehicle. There are two types of repairs, depending on your location:

At the mechanic

  • If you are at a mechanic your vehicle will be completely fixed, as good as new.
  • Mechanics are located several places in San Andreas. Look for the blips on the map.

Not at a mechanic

  • If you are not at a mechanic, you may be able to perform a DIY emergency repair in the field.
  • You can only reattach the oil plug once or twice, but after that, the vehicle will be beyond repair.
  • An emergency repair in the field will only make the car drivable, not completely fixed. A minor accident will most likely kill the car again.
  • If you let the damaged car sit too long, the oil will drain completely, preventing further repairs.
  • Electric vehicles can not be fixed by you, only by a mechanic. Technology is complex, and chewing gum just won’t fix a dead battery.

Download from GitHub, link in original post.


#16

Hey, Love your work! Is it possible to increase the time it takes to die? Make the vehicle damage (cascade) slower, and it dies much slower than in 6-7 seconds?
Thanks!


#17

Yes, totally configurable, see post #12


#18

Hi, perfect script, very realistic. but when vehicles is repaired by mechanic. the car will still not drive. So i cant use it… im using vRPex.


#19

Just to be sure: You got a green message “The mechanic repaired your car” when repairing?
Otherwise you might not have been close enough to a mechanic.
If you /repair when not at a mechanic, the car propably was too far gone to revive.

If you did get the green message, then were you able to repair it using another script like /fix or using a trainer?


#20

We have done some testing. Whenever you shoot the front tire a few times then shoot the back tire like 2-3 times the car blows up. Im almost positive it has to do with this script as i couldn’t replicate it without it.