[FREE] FiveM-MilageVehicleFailure

[FREE] FiveM Vehicle Breakdown Script

Overview

FiveM-MilageVehicleFailure

The FiveM Vehicle Breakdown Script adds a dynamic vehicle breakdown system to your FiveM server. This script introduces random vehicle malfunctions based on the number of kilometers driven. The malfunctions include engine failures, tire bursts, power loss and more! It also features a debug mode for easier testing and adjustment.

Features

  • Motor Failure: Completely disables the vehicle’s engine by turning it off and reducing engine health to zero. (This is disabled by default) After 30 seconds, the engine cools down and returns to normal.

  • Tire Burst: Randomly causes one of the vehicle’s tires to burst, if the tires can burst. The player is notified when a tire has burst.

  • Power Loss: Significantly reduces the engine power of the vehicle for 20 seconds. After that, the power is restored to its normal level.

  • Petrol Loss: Causes a fuel leak in the vehicle, reducing the fuel level and potentially turning off the engine if it runs too low. The player is notified of the gasoline loss.

  • Transmission Failure: Temporarily disables the transmission by turning off the engine and reducing engine health. After 25 seconds, the transmission is repaired, and the engine is turned back on.

  • Battery Drain: Drains the vehicle’s battery completely, turning off the engine. After 60 seconds, the battery recharges and the engine restarts. A flag can be activated or deactivated for this failure.

  • Radiator Leak: Increases the engine temperature by 50 degrees due to a radiator leak. After 30 seconds, the leak is sealed, and the temperature returns to normal.

  • Brake Failure: Activates the vehicle’s brakes and handbrake, simulating brake failure. The vehicle becomes immobile until the brakes are repaired after 20 seconds.

  • Suspension Damage: Lowers the suspension height of the vehicle due to damage. After 30 seconds, the suspension is repaired, and the height returns to normal.

  • Alternator Failure: Reduces the battery health due to alternator malfunction. After 30 seconds, the alternator is repaired, and battery health improves.

  • Transmission Fluid Leak: Causes a leak in the transmission fluid, reducing its health. After 25 seconds, the leak is repaired, and transmission health is restored.

  • Clutch Failure: Temporarily lowers the clutch’s efficiency, affecting gear shifting. After 20 seconds, the clutch is repaired.

  • Fuel Filter Clogged: Decreases the vehicle’s fuel level by 50 units due to a clogged fuel filter. After 20 seconds, the filter is cleaned, and fuel level is restored.

  • Door Fall Off Failure: Randomly causes one of the vehicle’s doors to fall off. The player is notified when a door falls off.

Update 0.7.0

  • Introduced a new braking system: if excessive braking occurs, the brakes will temporarily become non-functional.

Update 0.7.1

  • Improved manageBrakeTemperature function: added class-based values for brake temperature gain, maximum brake temperature, and cooling rate, with enhanced logic to prevent temperature increase when the vehicle is in the air, providing more realistic brake temperature management across different vehicle classes.
  • Added a new configuration option, Config.ApplyDamageAll, allowing selection of crash damage application to either the engine only or to the engine, petrol tank, and body.

Update 0.7.5

  • Introduced a new NUI that displays the current vehicle mileage, automatically updating every 10 seconds with smooth animations.
  • Implemented an icon and sound alert for when the brake temperature exceeds 80% of the maximum value.

Update 0.7.6

  • Added that if a vehicle isn’t owned, it doesn’t save its mileage.

Update 0.7.61

  • Fixed a bug where the brake warning icon could get stuck.

Requirements

  • ESX or QBCore Framework for FiveM.
  • A SQL database to store vehicle kilometer data.

Installation

  1. Download the Script

    GitHub Repository

    Clone the repository to your FiveM server or download the files manually.

    git clone https://github.com/muhaddil/FiveM-MilageVehicleFailure.git
    
  2. Place the Files

    Move the script files into your server’s resources directory.

  3. Add the Script to server.cfg

    Ensure the script is started in your server.cfg by adding the following line:

    ensure FiveM-MilageVehicleFailure
    
  4. Set up the DataBase

    Ensure that your database includes the necessary table. Use the following SQL to create the vehicle_kilometers table:

    CREATE TABLE IF NOT EXISTS vehicle_kilometers (
    plate VARCHAR(8) NOT NULL PRIMARY KEY,
    kilometers DOUBLE NOT NULL DEFAULT 0
    );
    
  5. Enjoy!

    The script now must work, edit the config.lua file to meet you requirements!

Code is accessible Yes
Subscription-based No
Lines (approximately) 1732 lines
Requirements ESX & SQL
Support Yes
8 Likes

really nice work and thank you making it free

1 Like

ALTER TABLE owned_vehicles
ADD COLUMN adv_stats JSON DEFAULT NULL;

hi having some problems here i got this error on my console any fix for it ??

You are using the external vehicle mileage configured to the cd_garage script mileage system.

Set this to false:
Config.UseExternalMileageSystem = false

And implement the SQL.

Edit: Made a new version where this option comes disabled by default.

1 Like

I do not recommend doing that because if Config.UseExternalMileageSystem is set to true, the mileage will not be updated automatically. Mileage updates only occur in the default mode I created (for incompatibility issues).

thank you i didnt see it

any way to eliminate the cars behavior on different terrains?

1 Like

I didn’t think in that! I will do it as soon as I can!

Edit: To disable or enable the car physics (you need to install the latest update) modify this line in the Config.lua (line 30):
Config.EnableCarPhysics = true

Sorry, is there a way to stop the car from leaking gas when it has a dent?

Yes, you can edit the client.lua file in the line 375. Simply comment out the SetVehiclePetrolTankHealth(vehicle, newPetrolTankHealth) code. Or better if you set it like this so you ensure that it neves leaks any gas SetVehiclePetrolTankHealth(vehicle, 4000).

1 Like

Perfect, now there are no problems anymore.

1 Like

Update 0.7.7

  • Added new damageMultipliers config for each vehicle class and organized server-side code.

Full Changelog: Comparing v0.7.61-beta...v0.7.7-beta · Muhaddil/FiveM-MilageVehicleFailure · GitHub

Will it conflict with JG Mechanic resources

I don’t see why this would cause any conflict, although it might involve the servicing part of the script. However, since my script deals with different breakdowns, I don’t see any issues arising (I haven’t tested it with that script).