Skip to content

Commit

Permalink
re-implemented blacklisted vehicles. closing #20
Browse files Browse the repository at this point in the history
  • Loading branch information
InZidiuZ committed May 8, 2019
1 parent e1f020d commit 39eec6f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
11 changes: 10 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Config.FuelDecor = "_FUEL_LEVEL"
Config.DisableKeys = {0, 22, 23, 24, 29, 30, 31, 37, 44, 56, 82, 140, 166, 167, 168, 170, 288, 289, 311, 323}

-- Want to use the HUD? Turn this to true.
Config.EnableHUD = false
Config.EnableHUD = true

-- Configure blips here. Turn both to false to disable blips all together.
Config.ShowNearestGasStationOnly = true
Expand Down Expand Up @@ -45,6 +45,15 @@ Config.PumpModels = {
[-164877493] = true
}

-- Blacklist certain vehicles. Use names or hashes. https://wiki.gtanet.work/index.php?title=Vehicle_Models
Config.Blacklist = {
"Adder",
276773164
}

-- Do you want the HUD removed from showing in blacklisted vehicles?
Config.RemoveHUDForBlacklistedVehicle = true

-- Class multipliers. If you want SUVs to use less fuel, you can change it to anything under 1.0, and vise versa.
Config.Classes = {
[0] = 1.0, -- Compacts
Expand Down
33 changes: 29 additions & 4 deletions source/fuel_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local currentFuel = 0.0
local currentCost = 0.0
local currentCash = 1000
local fuelSynced = false
local inBlacklisted = false

function ManageFuelUsage(vehicle)
if not DecorExistOn(vehicle, Config.FuelDecor) then
Expand All @@ -33,6 +34,18 @@ end
Citizen.CreateThread(function()
DecorRegister(Config.FuelDecor, 1)

for i = 1, #Config.Blacklist do
if type(Config.Blacklist[i]) == 'string' then
Config.Blacklist[GetHashKey(Config.Blacklist[i])] = true
else
Config.Blacklist[Config.Blacklist[i]] = true
end
end

for i = #Config.Blacklist, 1, -1 do
table.remove(Config.Blacklist, i)
end

while true do
Citizen.Wait(1000)

Expand All @@ -41,11 +54,23 @@ Citizen.CreateThread(function()
if IsPedInAnyVehicle(ped) then
local vehicle = GetVehiclePedIsIn(ped)

if GetPedInVehicleSeat(vehicle, -1) == ped then
if Config.Blacklist[GetEntityModel(vehicle)] then
inBlacklisted = true
else
inBlacklisted = false
end

if not inBlacklisted and GetPedInVehicleSeat(vehicle, -1) == ped then
ManageFuelUsage(vehicle)
end
else
fuelSynced = false
if fuelSynced then
fuelSynced = false
end

if inBlacklisted then
inBlacklisted = false
end
end
end
end)
Expand Down Expand Up @@ -269,7 +294,7 @@ Citizen.CreateThread(function()
elseif isNearPump then
local stringCoords = GetEntityCoords(isNearPump)

if currentCash > 100 then
if currentCash > Config.JerryCanCost then
DrawText3Ds(stringCoords.x, stringCoords.y, stringCoords.z + 1.2, Config.Strings.PurchaseJerryCan)

if IsControlJustReleased(0, 38) then
Expand Down Expand Up @@ -382,7 +407,7 @@ if Config.EnableHUD then

local ped = PlayerPedId()

if IsPedInAnyVehicle(ped) then
if IsPedInAnyVehicle(ped) and not (Config.RemoveHUDForBlacklistedVehicle and inBlacklisted) then
local vehicle = GetVehiclePedIsIn(ped)
local speed = GetEntitySpeed(vehicle)

Expand Down

0 comments on commit 39eec6f

Please sign in to comment.