diff --git a/client/fuel_cl.lua b/client/fuel_cl.lua
index aba327b..e54dafc 100644
--- a/client/fuel_cl.lua
+++ b/client/fuel_cl.lua
@@ -583,6 +583,7 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
if Config.FuelDebug then
print('cdn-fuel:client:FinalMenu', purchasetype)
end
+ -- TODO Handle purchaseType of `full`
if RefuelingType == nil then
FetchStationInfo("all")
Wait(Config.WaitTime)
@@ -596,6 +597,18 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
end
end
local money = nil
+ if purchasetype == "full" then
+ if Config.FillUpWithBank then
+ money = QBCore.Functions.GetPlayerData().money['bank']
+ end
+ if Config.FillUpWithCash then
+ if money == nil then
+ money = QBCore.Functions.GetPlayerData().money['cash']
+ else
+ money = money + QBCore.Functions.GetPlayerData().money['cash']
+ end
+ end
+ end
if purchasetype == "bank" then money = QBCore.Functions.GetPlayerData().money['bank'] elseif purchasetype == 'cash' then money = QBCore.Functions.GetPlayerData().money['cash'] end
if not Config.PlayerOwnedGasStationsEnabled then
FuelPrice = (1 * Config.CostMultiplier)
@@ -684,24 +697,34 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
if not fuel then if Config.FuelDebug then print("Fuel Is Nil! #1") end return end
fuelAmount = tonumber(fuel[5])
else
+ if (purchasetype ~= "full") then
+ fuel = lib.inputDialog('Gas Station', {
+ { type = "input", label = 'Gasoline Price', default = '$'.. FuelPrice .. ' Per Liter', disabled = true },
+ { type = "input", label = 'Current Fuel', default = finalfuel .. ' Per Liter', disabled = true },
+ { type = "input", label = 'Required For A Full Tank', default = maxfuel, disabled = true },
+ { type = "slider", label = 'Full Tank Cost: $' ..wholetankcostwithtax.. '', default = maxfuel, min = 0, max = maxfuel },
+ })
+ if not fuel then if Config.FuelDebug then print("Fuel Is Nil! #2") end return end
+ fuelAmount = tonumber(fuel[4])
+ else
+ -- They want to fill up the tank completely...
+ fuelAmount = maxfuel;
+ end
+ end
+ else
+ if (purchasetype ~= "full") then
fuel = lib.inputDialog('Gas Station', {
- { type = "input", label = 'Gasoline Price', default = '$'.. FuelPrice .. ' Per Liter', disabled = true },
- { type = "input", label = 'Current Fuel', default = finalfuel .. ' Per Liter', disabled = true },
+ { type = "input", label = 'Gasoline Price', default = '$'.. FuelPrice .. ' Per Liter',disabled = true },
+ { type = "input", label = 'Current Fuel', default = finalfuel .. ' Per Liter',disabled = true },
{ type = "input", label = 'Required For A Full Tank', default = maxfuel, disabled = true },
- { type = "slider", label = 'Full Tank Cost: $' ..wholetankcostwithtax.. '', default = maxfuel, min = 0, max = maxfuel },
- })
- if not fuel then if Config.FuelDebug then print("Fuel Is Nil! #2") end return end
+ { type = "slider", label = 'Full Tank Cost: $' ..wholetankcostwithtax.. '', default = maxfuel, min = 0, max = maxfuel},
+ });
+ if not fuel then if Config.FuelDebug then print("Fuel Is Nil! #3") end return end
fuelAmount = tonumber(fuel[4])
+ else
+ -- They want to fill up the tank completely...
+ fuelAmount = maxfuel;
end
- else
- fuel = lib.inputDialog('Gas Station', {
- { type = "input", label = 'Gasoline Price', default = '$'.. FuelPrice .. ' Per Liter',disabled = true },
- { type = "input", label = 'Current Fuel', default = finalfuel .. ' Per Liter',disabled = true },
- { type = "input", label = 'Required For A Full Tank', default = maxfuel, disabled = true },
- { type = "slider", label = 'Full Tank Cost: $' ..wholetankcostwithtax.. '', default = maxfuel, min = 0, max = maxfuel},
- })
- if not fuel then if Config.FuelDebug then print("Fuel Is Nil! #3") end return end
- fuelAmount = tonumber(fuel[4])
end
if fuel then
if not fuelAmount then print("Fuel Amount Nil") return end
@@ -743,6 +766,27 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
}}
})
else
+ if (purchasetype ~= "full") then
+ fuel = exports['qb-input']:ShowInput({
+ header = "Select the Amount of Fuel
Current Price: $" ..
+ FuelPrice .. " / Liter
Current Fuel: " .. finalfuel .. " Liters
Full Tank Cost: $" ..
+ wholetankcostwithtax .. "",
+ submitText = Lang:t("input_insert_nozzle"),
+ inputs = { {
+ type = 'number',
+ isRequired = true,
+ name = 'amount',
+ text = 'The Tank Can Hold ' .. maxfuel .. ' More Liters.'
+ }}
+ })
+ else
+ -- They want to fill up the tank completely...
+ fuel = {};
+ fuel.amount = maxfuel;
+ end
+ end
+ else
+ if (purchasetype ~= "full") then
fuel = exports['qb-input']:ShowInput({
header = "Select the Amount of Fuel
Current Price: $" ..
FuelPrice .. " / Liter
Current Fuel: " .. finalfuel .. " Liters
Full Tank Cost: $" ..
@@ -755,20 +799,11 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
text = 'The Tank Can Hold ' .. maxfuel .. ' More Liters.'
}}
})
+ else
+ -- They want to fill up the tank completely...
+ fuel = {};
+ fuel.amount = maxfuel;
end
- else
- fuel = exports['qb-input']:ShowInput({
- header = "Select the Amount of Fuel
Current Price: $" ..
- FuelPrice .. " / Liter
Current Fuel: " .. finalfuel .. " Liters
Full Tank Cost: $" ..
- wholetankcostwithtax .. "",
- submitText = Lang:t("input_insert_nozzle"),
- inputs = { {
- type = 'number',
- isRequired = true,
- name = 'amount',
- text = 'The Tank Can Hold ' .. maxfuel .. ' More Liters.'
- }}
- })
end
if fuel then
if not fuel.amount then if Config.FuelDebug then print("fuel.amount = nil") end return end
@@ -880,6 +915,15 @@ RegisterNetEvent('cdn-fuel:client:SendMenuToServer', function(type)
args = 'bank',
}
},
+ {
+ header = Lang:t("menu_header_pay_full"),
+ txt = Lang:t("menu_pay_full"),
+ icon = "fas fa-fill",
+ params = {
+ event = "cdn-fuel:client:FinalMenu",
+ args = 'full',
+ }
+ },
{
header = Lang:t("menu_header_close"),
txt = Lang:t("menu_refuel_cancel"),
@@ -908,6 +952,8 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
purchasetype = data.purchasetype
elseif data.purchasetype == "cash" then
purchasetype = "cash"
+ elseif data.purchasetype == "full" then
+ purchasetype = "full"
else
purchasetype = RefuelPurchaseType
end
diff --git a/locales/en.lua b/locales/en.lua
index f9464ec..03f48a8 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -84,9 +84,11 @@ local Translations = {
menu_header_cash = "Cash",
menu_header_bank = "Bank",
+ menu_header_pay_full = "Fill me up",
menu_header_close = "Cancel",
menu_pay_with_cash = "Pay with cash. \nYou have: $",
- menu_pay_with_bank = "Pay with bank.",
+ menu_pay_with_bank = "Pay with bank.",
+ menu_pay_full = "Fill up my gas tank fully...",
menu_refuel_header = "Gas Station",
menu_refuel_accept = "I would like to purchase the fuel.",
menu_refuel_cancel = "I actually don't want fuel anymore.",
diff --git a/server/fuel_sv.lua b/server/fuel_sv.lua
index 0487188..ec8acb6 100644
--- a/server/fuel_sv.lua
+++ b/server/fuel_sv.lua
@@ -88,9 +88,22 @@ RegisterNetEvent("cdn-fuel:server:PayForFuel", function(amount, purchasetype, Fu
elseif purchasetype == "cash" then
moneyremovetype = "cash"
end
+ local cash = Player.PlayerData.money['cash']
+ local bank = Player.PlayerData.money['bank']
local payString = Lang:t("menu_pay_label_1") ..FuelPrice..Lang:t("menu_pay_label_2")
if electric then payString = Lang:t("menu_electric_payment_label_1") ..FuelPrice..Lang:t("menu_electric_payment_label_2") end
- Player.Functions.RemoveMoney(moneyremovetype, total, payString)
+ if (purchasetype ~= "full") then
+ Player.Functions.RemoveMoney(moneyremovetype, total, payString)
+ else
+ if (total <= cash) then
+ Player.Functions.RemoveMoney("cash", total, payString)
+ elseif (total > cash) then
+ -- Need to take money from bank
+ total = total - cash;
+ Player.Functions.RemoveMoney("cash", cash, payString)
+ Player.Functions.RemoveMoney("bank", total, payString)
+ end
+ end
end)
RegisterNetEvent("cdn-fuel:server:purchase:jerrycan", function(purchasetype)
@@ -237,4 +250,4 @@ CreateThread(function()
updatePath = "/CodineDev/cdn-fuel"
resourceName = "cdn-fuel ("..GetCurrentResourceName()..")"
PerformHttpRequest("https://raw.githubusercontent.com"..updatePath.."/master/version", checkVersion, "GET")
-end)
\ No newline at end of file
+end)
diff --git a/shared/config.lua b/shared/config.lua
index e527867..f920806 100644
--- a/shared/config.lua
+++ b/shared/config.lua
@@ -5,6 +5,8 @@ Config.ShowNearestGasStationOnly = true -- When enabled, only the nearest gas st
Config.LeaveEngineRunning = false -- When true, the vehicle's engine will be left running upon exit if the player *HOLDS* F.
Config.VehicleBlowUp = true -- When true, there will be a configurable chance of the vehicle blowing up, if you fuel while the engine is on.
Config.BlowUpChance = 5 -- Percentage for Chance of Engine Explosion (Default: 5% or 5)
+Config.FillUpWithBank = true -- Use player's bank to fill up tank
+Config.FillUpWithCash = true -- Use player's cash to fill up tank
Config.CostMultiplier = 3 -- Amount to multiply 1 by. This indicates fuel price. (Default: $3.0/l or 3.0)
Config.GlobalTax = 15.0 -- The tax, in %, that people will be charged at the pump. (Default: 15% or 15.0)
Config.FuelNozzleExplosion = false -- When true, it enables the fuel pump exploding when players run away with the nozzle. Highly recommeded to be false.