From 332a552d8e929f3075baf33638f50c52dba00292 Mon Sep 17 00:00:00 2001 From: Maximus7474 Date: Sat, 4 Oct 2025 11:44:32 +0200 Subject: [PATCH 1/5] feat(data): vehicle class list & model list to define fuel consumption --- data/vehicles.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 data/vehicles.lua diff --git a/data/vehicles.lua b/data/vehicles.lua new file mode 100644 index 0000000..1b71ea8 --- /dev/null +++ b/data/vehicles.lua @@ -0,0 +1,28 @@ +return { + -- Modifies the fuel consumption rate of all vehicles + -- see [`SET_FUEL_CONSUMPTION_RATE_MULTIPLIER`](https://docs.fivem.net/natives/?_0x845F3E5C). + [0] = 9.0, -- Compact + [1] = 10.0, -- Sedan + [2] = 11.0, -- SUV + [3] = 10.0, -- Coupe + [4] = 12.0, -- Muscle + [5] = 11.5, -- Sports Classic + [6] = 12.5, -- Sports + [7] = 14.0, -- Super + [8] = 7.0, -- Motorcycle + [9] = 11.5, -- Offroad + [10] = 13.0, -- Industrial + [11] = 11.0, -- Utility + [12] = 10.5, -- Van + [14] = 6.0, -- Boat + [15] = 15.0, -- Helicopter + [16] = 16.0, -- Plane + [17] = 10.5, -- Service + [18] = 9.0, -- Emergency + [19] = 13.5, -- Military + [20] = 14.5, -- Commercial (trucks) + models = { + [GetHashKey('tug')] = 14.0, + [GetHashKey('kosatka')] = 16.0, + }, +} From 38bceed92564f2657a7e0255f7834f8465dc7873 Mon Sep 17 00:00:00 2001 From: Maximus7474 Date: Sat, 4 Oct 2025 11:46:00 +0200 Subject: [PATCH 2/5] refactor(client/init): use global or vehicle based consumption rates --- client/init.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/client/init.lua b/client/init.lua index 278af5e..8159f03 100644 --- a/client/init.lua +++ b/client/init.lua @@ -1,9 +1,12 @@ local config = require 'config' +local vehicles = require 'data.vehicles' if not config then return end SetFuelConsumptionState(true) -SetFuelConsumptionRateMultiplier(config.globalFuelConsumptionRate) +if config.globalFuelConsumptionRate then + SetFuelConsumptionRateMultiplier(config.globalFuelConsumptionRate) +end AddTextEntry('fuelHelpText', locale('fuel_help')) AddTextEntry('petrolcanHelpText', locale('petrolcan_help')) @@ -18,6 +21,7 @@ require 'client.stations' local function startDrivingVehicle() local vehicle = cache.vehicle + local vehicleModel = GetEntityModel(vehicle) if not DoesVehicleUseFuel(vehicle) then return end @@ -28,6 +32,16 @@ local function startDrivingVehicle() while not vehState.fuel do Wait(0) end end + -- Create locallized value for the thread to define the consumptionRate + local consumptionRate = config.globalFuelConsumptionRate + if type(vehicles.models[vehicleModel]) == 'number' then + consumptionRate = vehicles.models[vehicleModel] + else + local class = GetVehicleClass(vehicle) + + consumptionRate = vehicles[class] + end + SetVehicleFuelLevel(vehicle, vehState.fuel) local fuelTick = 0 @@ -35,7 +49,7 @@ local function startDrivingVehicle() while cache.seat == -1 do if GetIsVehicleEngineRunning(vehicle) then if not DoesEntityExist(vehicle) then return end - SetFuelConsumptionRateMultiplier(config.globalFuelConsumptionRate) + SetFuelConsumptionRateMultiplier(consumptionRate) local fuelAmount = tonumber(vehState.fuel) local newFuel = GetVehicleFuelLevel(vehicle) From c5710273c56bfadd1329ca9d0060c7e207ac7035 Mon Sep 17 00:00:00 2001 From: Maximus7474 Date: Sat, 4 Oct 2025 11:46:57 +0200 Subject: [PATCH 3/5] doc(config): detailed values accepted for globalFuelConsumptionRate to define if it uses global or vehicle specific consumption rates --- config.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.lua b/config.lua index c1c8011..7a5ca67 100644 --- a/config.lua +++ b/config.lua @@ -38,7 +38,8 @@ return { refillPrice = 800, }, - ---Modifies the fuel consumption rate of all vehicles - see [`SET_FUEL_CONSUMPTION_RATE_MULTIPLIER`](https://docs.fivem.net/natives/?_0x845F3E5C). + -- Setting this to a number, will use a global rate for all vehicles, setting it to false will use the data in `data/vehicles.lua` + -- Modifies the fuel consumption rate of all vehicles - see [`SET_FUEL_CONSUMPTION_RATE_MULTIPLIER`](https://docs.fivem.net/natives/?_0x845F3E5C). globalFuelConsumptionRate = 10.0, -- Gas pump models From c3b96ea8ed82012676101aa88902b98bba69a4b9 Mon Sep 17 00:00:00 2001 From: Maximus7474 Date: Sat, 4 Oct 2025 12:04:03 +0200 Subject: [PATCH 4/5] tweak(fxmanifest): use globbing for data files --- fxmanifest.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 8936d7b..a97fa36 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -27,7 +27,7 @@ client_script 'client/init.lua' files { 'locales/*.json', - 'data/stations.lua', + 'data/*.lua', 'client/*.lua', } From ec38ca1dcc68a2bd7bdbf76aa75b470eaa666aa1 Mon Sep 17 00:00:00 2001 From: Maximus7474 Date: Sat, 4 Oct 2025 12:07:24 +0200 Subject: [PATCH 5/5] tweak(data/vehicles): added specific consumption values for seasharks --- data/vehicles.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/vehicles.lua b/data/vehicles.lua index 1b71ea8..268ab37 100644 --- a/data/vehicles.lua +++ b/data/vehicles.lua @@ -24,5 +24,8 @@ return { models = { [GetHashKey('tug')] = 14.0, [GetHashKey('kosatka')] = 16.0, + [GetHashKey('seashark')] = 3.0, + [GetHashKey('seashark2')] = 3.0, + [GetHashKey('seashark3')] = 3.0, }, }