LogoMonarch Development

Client

Here you'll find all client functions

How to set/get fuel?

First you need to retrieve the vehicle entity handle (with ox_lib cache.vehicle)

Retrieve Vehicle Entity
    local playerPed = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(playerPed, false)

Then you need to set the statebag for get/set the fuel

Statebag Setup
    -- previous locals to get the vehicle entity
    Entity(vehicle).state.fuel

Now you can get or set the value of the Statebag in this ways

Get Fuel Level
    local playerPed = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(playerPed, false)
    
    local fuel = Entity(vehicle).state.fuel
Set Fuel Level
    local playerPed = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(playerPed, false)
    
    Entity(vehicle).state.fuel = 100
Set Fuel Level (with server replication)
    local playerPed = PlayerPedId()
    local vehicle = GetVehiclePedIsIn(playerPed, false)
    
    Entity(vehicle).state:set("fuel", 100, true)