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) 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 diff --git a/data/vehicles.lua b/data/vehicles.lua new file mode 100644 index 0000000..268ab37 --- /dev/null +++ b/data/vehicles.lua @@ -0,0 +1,31 @@ +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, + [GetHashKey('seashark')] = 3.0, + [GetHashKey('seashark2')] = 3.0, + [GetHashKey('seashark3')] = 3.0, + }, +} 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', }