From f9d8b6f2ac0c88190cbe6c056c430cf6e2977b9d Mon Sep 17 00:00:00 2001 From: ItsMuri <88394932+ItzMuri@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:16:11 +0200 Subject: [PATCH] Update client.lua --- client.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/client.lua b/client.lua index d2417b4..4239c08 100644 --- a/client.lua +++ b/client.lua @@ -871,7 +871,11 @@ local function getFuelLevel(vehicle) local updateTick = GetGameTimer() if (updateTick - lastFuelUpdate) > 2000 then lastFuelUpdate = updateTick - lastFuelCheck = math.floor(exports[Config.FuelScript]:GetFuel(vehicle)) + if Config.Fuel.enable then + lastFuelCheck = math.floor(exports[Config.Fuel.script]:GetFuel(vehicle)) + else + lastFuelCheck = Entity(vehicle).state.fuel + end end return lastFuelCheck end @@ -1048,12 +1052,22 @@ CreateThread(function() while true do if LocalPlayer.state.isLoggedIn then local ped = PlayerPedId() - if IsPedInAnyVehicle(ped, false) and not IsThisModelABicycle(GetEntityModel(GetVehiclePedIsIn(ped, false))) and not isElectric(GetVehiclePedIsIn(ped, false)) then - if exports[Config.FuelScript]:GetFuel(GetVehiclePedIsIn(ped, false)) <= 20 then -- At 20% Fuel Left + local vehicle = GetVehiclePedIsIn(ped, false) + + if IsPedInAnyVehicle(ped, false) and not IsThisModelABicycle(GetEntityModel(vehicle)) and not isElectric(vehicle) then + local fuelLevel + + if Config.Fuel.enable then + fuelLevel = exports[Config.Fuel.script]:GetFuel(vehicle) + else + fuelLevel = Entity(vehicle).state.fuel + end + + if fuelLevel <= 20 then if Menu.isLowFuelChecked then TriggerServerEvent("InteractSound_SV:PlayOnSource", "pager", 0.10) QBCore.Functions.Notify(Lang:t("notify.low_fuel"), "error") - Wait(60000) -- repeats every 1 min until empty + Wait(60000) end end end