Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update client.lua #125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down