Skip to content

Commit

Permalink
0.4.0 - Added Two New Breakdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhaddil committed Sep 12, 2024
1 parent c95bef4 commit b6e05b5
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ The FiveM Vehicle Breakdown Script adds a dynamic vehicle breakdown system to yo

- **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. The player is notified of the gasoline loss.
- **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.
- **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. After 20 seconds, the brakes are repaired.
- **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.

Expand All @@ -32,6 +32,8 @@ The FiveM Vehicle Breakdown Script adds a dynamic vehicle breakdown system to yo

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

## Requirements

- ESX Framework for FiveM.
Expand Down
12 changes: 12 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ AddEventHandler('realistic-vehicle:fuelFilterCloggedFlag', function(vehicle, isC
fuelFilterCloggedFlags[vehicle] = isClogged
end)

RegisterNetEvent('realistic-vehicle:hoodLatchFailureFlag')
AddEventHandler('realistic-vehicle:hoodLatchFailureFlag', function(vehicle, hasFailure)
hoodLatchFailureFlags[vehicle] = hasFailure
end)

Citizen.CreateThread(function()
while true do
local waitTime = 5000
Expand Down Expand Up @@ -498,6 +503,13 @@ Citizen.CreateThread(function()
end
end

for vehicle, hasFailure in pairs(hoodLatchFailureFlags) do
if hasFailure then
hasActiveFlag = true
SetVehicleDoorOpen(vehicle, 4, false, false)
end
end

Citizen.Wait(waitTime)
end
end)
47 changes: 46 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Config.BreakdownTypes = {
chance = 0.4,
duration = 20000,
action = function(vehicle)
print(GetVehicleFuelLevel(vehicle))
DebugPrint(GetVehicleFuelLevel(vehicle))
SetVehicleFuelLevel(vehicle, 9.77)
TriggerEvent('realistic-vehicle:fuelFilterCloggedFlag', vehicle, true)
if Config.ShowNotifications then
Expand All @@ -287,8 +287,53 @@ Config.BreakdownTypes = {
end)
end
},
{
name = "HoodLatchFailure",
chance = 0.5,
duration = 20000,
action = function(vehicle)
SetVehicleDoorOpen(vehicle, 4, false, false)

--For Other Scripts Incompatibility
-- TriggerEvent('realistic-vehicle:hoodLatchFailureFlag', vehicle, true)

if Config.ShowNotifications then
ESX.ShowNotification("¡El capó de tu vehículo se ha abierto debido a un fallo en los seguros!")
end

-- To set if the hood closes on its own when a timeout finishes
-- Citizen.SetTimeout(Config.BreakdownTypes[14].duration, function()
-- SetVehicleDoorShut(vehicle, 4, false)
-- TriggerEvent('realistic-vehicle:hoodLatchFailureFlag', vehicle, false)
-- if Config.ShowNotifications then
-- ESX.ShowNotification("El capó de tu vehículo ha sido cerrado.")
-- end
-- end)
end
},
{
name = "DoorFallOffFailure",
chance = 0.2,
duration = 0,
action = function(vehicle)
local doorIndex = math.random(0, 5)

if DoesVehicleHaveDoor(vehicle, doorIndex) then
SetVehicleDoorBroken(vehicle, doorIndex, false)
else
DebugPrint('¡Esa puerta no existe!')
end

if Config.ShowNotifications then
ESX.ShowNotification("¡Una de las puertas de tu vehículo se ha soltado y se ha caído!")
end
end
}

}

-- This vehicles will be excluded from the mileage probability of breakdowns

Config.ExcludedVehicles = {
"ADMINCAR",
}
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lua54 'yes'

author 'Muhaddil'
description 'Mileage-based vehicle breakdown system for ESX'
version '0.3.1'
version '0.4.0'

shared_script 'config.lua'
client_script 'client.lua'
Expand Down

0 comments on commit b6e05b5

Please sign in to comment.