Skip to content

False "no_fuel" notification right after vehicle spawn #149

@Loost77

Description

@Loost77

Description of the bug

When spawning a vehicle (garage, dealership test drive, or admin spawn), the player sometimes receives a "no_fuel" notification, even though the vehicle actually has fuel.
The notification disappears right after, once the fuel syncs correctly.

Steps to reproduce

  1. Spawn a vehicle from garage, dealership or as admin.
  2. Notice that sometimes a "no_fuel" notification pops up.
  3. A second later, the fuel level shows correctly and the car has fuel.

Expected behavior

The notification should not appear if the fuel value has not yet been synced from the server.

Actual behavior

A false "no_fuel" notification is displayed briefly right after spawn, then the fuel HUD corrects itself.

Possible cause

In client/cl_fuel.lua, the thread that shuts off the engine checks:

if vehFuelLevel <= vehFuelShutoffLevel then
    QBCore.Functions.Notify(Lang:t("no_fuel"), 'error', 3500)

Suggested fix

Add a condition to ignore invalid fuel values at spawn:

if vehFuelLevel and vehFuelLevel > 0.1 and vehFuelLevel <= vehFuelShutoffLevel then
    -- shut off engine and notify
end

Environment

cdn-fuel version: [2.1.9]
Framework: [QBCore]
Server build: [3095]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions