From 52b91d8ad85a769b3760f0afeb91cfe426ef388e Mon Sep 17 00:00:00 2001
From: dnelyk <95599217+dnelyk@users.noreply.github.com>
Date: Thu, 25 May 2023 21:01:59 -0700
Subject: [PATCH 1/5] feat(Fixes: Emergency Discount Now Will Give the Station
Money for Purchases, Blip Color Issue. | Additions: Move Get Closest Vehicle
to Local Function)
@Blip Color Issue: https://github.com/CodineDev/cdn-fuel/pull/56
---
client/electric_cl.lua | 8 ++--
client/fuel_cl.lua | 88 ++++++++++++++++++++++++++++++++----------
client/utils.lua | 26 ++++++++++++-
3 files changed, 95 insertions(+), 27 deletions(-)
diff --git a/client/electric_cl.lua b/client/electric_cl.lua
index 1b100de..d39a4d6 100644
--- a/client/electric_cl.lua
+++ b/client/electric_cl.lua
@@ -81,7 +81,7 @@ if Config.ElectricVehicleCharging then
local money = nil
if purchasetype == "bank" then money = QBCore.Functions.GetPlayerData().money['bank'] elseif purchasetype == 'cash' then money = QBCore.Functions.GetPlayerData().money['cash'] end
FuelPrice = (1 * Config.ElectricChargingPrice)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
-- Police Discount Math --
if Config.EmergencyServicesDiscount['enabled'] == true and (Config.EmergencyServicesDiscount['emergency_vehicles_only'] == false or (Config.EmergencyServicesDiscount['emergency_vehicles_only'] == true and GetVehicleClass(vehicle) == 18)) then
@@ -205,7 +205,7 @@ if Config.ElectricVehicleCharging then
end)
RegisterNetEvent('cdn-fuel:client:electric:SendMenuToServer', function()
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local vehiclename = GetEntityModel(vehicle)
AwaitingElectricCheck = true
FoundElectricVehicle = false
@@ -340,7 +340,7 @@ if Config.ElectricVehicleCharging then
if amount < 1 then return end
if amount < 10 then fuelamount = string.sub(amount, 1, 1) else fuelamount = string.sub(amount, 1, 2) end
local FuelPrice = (Config.ElectricChargingPrice * 1)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
-- Police Discount Math --
if Config.EmergencyServicesDiscount['enabled'] == true and (Config.EmergencyServicesDiscount['emergency_vehicles_only'] == false or (Config.EmergencyServicesDiscount['emergency_vehicles_only'] == true and GetVehicleClass(vehicle) == 18)) then
@@ -394,7 +394,7 @@ if Config.ElectricVehicleCharging then
end
local refillCost = (fuelamount * FuelPrice) + GlobalTax(fuelamount*FuelPrice)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local ped = PlayerPedId()
local time = amount * Config.RefuelTime
if amount < 10 then time = 10 * Config.RefuelTime end
diff --git a/client/fuel_cl.lua b/client/fuel_cl.lua
index e0956b0..6ab73cd 100644
--- a/client/fuel_cl.lua
+++ b/client/fuel_cl.lua
@@ -20,15 +20,20 @@ local GasStationBlips = {} -- Used for managing blips on the client, so labels c
local RefuelingType = nil
local PlayerInSpecialFuelZone = false
local Rope = nil
+local CachedFuelPrice = nil
-- Debug ---
if Config.FuelDebug then
RegisterCommand('setfuel', function(source, args)
if args[1] == nil then print("You forgot to put a fuel level!") return end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
SetFuel(vehicle, tonumber(args[1]))
QBCore.Functions.Notify(Lang:t("set_fuel_debug")..' '..args[1]..'L', 'success')
end, false)
+
+ RegisterCommand('getCachedFuelPrice', function ()
+ print(CachedFuelPrice)
+ end, false)
end
-- Functions
@@ -309,6 +314,7 @@ if Config.RenewedPhonePayment then
end
if discount ~= 0 then
if discount == 100 then
+ CachedFuelPrice = FuelPrice
FuelPrice = 0
if Config.FuelDebug then
print("Your discount for Emergency Services is set @ "..discount.."% so fuel is free!")
@@ -318,6 +324,7 @@ if Config.RenewedPhonePayment then
if Config.FuelDebug then
print(FuelPrice, FuelPrice*discount)
end
+ CachedFuelPrice = FuelPrice
FuelPrice = FuelPrice - (FuelPrice*discount)
if Config.FuelDebug then
@@ -339,7 +346,7 @@ if Config.RenewedPhonePayment then
if QBCore.Functions.GetPlayerData().money['bank'] <= total then
QBCore.Functions.Notify(Lang:t("not_enough_money"), "error")
else
- TriggerServerEvent('cdn-fuel:server:PayForFuel', total, "bank", FuelPrice)
+ TriggerServerEvent('cdn-fuel:server:PayForFuel', total, "bank", FuelPrice, false, CachedFuelPrice)
RefuelPossible = true
RefuelPossibleAmount = amount
RefuelCancelledFuelCost = FuelPrice
@@ -592,7 +599,7 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
if not Config.PlayerOwnedGasStationsEnabled then
FuelPrice = (1 * Config.CostMultiplier)
end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local curfuel = GetFuel(vehicle)
local finalfuel
if curfuel < 10 then finalfuel = string.sub(curfuel, 1, 1) else finalfuel = string.sub(curfuel, 1, 2) end
@@ -636,6 +643,7 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
if Config.FuelDebug then print("Before we apply the discount the FuelPrice is: $"..FuelPrice) end
if discount ~= 0 then
if discount == 100 then
+ CachedFuelPrice = FuelPrice
FuelPrice = 0
if Config.FuelDebug then
print("Your discount for Emergency Services is set @ "..discount.."% so fuel is free!")
@@ -645,6 +653,7 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
if Config.FuelDebug then
print("Math( Current Fuel Price: "..FuelPrice.. " - " ..FuelPrice * discount.. "<<-- FuelPrice * Discount)")
end
+ CachedFuelPrice = FuelPrice
FuelPrice = (FuelPrice) - (FuelPrice*discount)
if Config.FuelDebug then
print("Your discount for Emergency Services is set @ "..discount.."%. Setting new price to: $"..FuelPrice)
@@ -785,7 +794,7 @@ RegisterNetEvent('cdn-fuel:client:FinalMenu', function(purchasetype)
end)
RegisterNetEvent('cdn-fuel:client:SendMenuToServer', function(type)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local NotElectric = false
if Config.ElectricVehicleCharging then
local isElectric = GetCurrentVehicleType(vehicle)
@@ -918,7 +927,7 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
amount = tonumber(amount)
if amount < 1 then return end
if amount < 10 then fuelamount = string.sub(amount, 1, 1) else fuelamount = string.sub(amount, 1, 2) end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
if Config.AirAndWaterVehicleFueling['enabled'] then
local vehClass = GetVehicleClass(vehicle)
if vehClass == 14 then
@@ -956,6 +965,7 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
if Config.FuelDebug then print("Before we apply the discount the FuelPrice is: $"..FuelPrice) end
if discount ~= 0 then
if discount == 100 then
+ CachedFuelPrice = FuelPrice
FuelPrice = 0
if Config.FuelDebug then
print("Your discount for Emergency Services is set @ | "..discount.."% | so fuel is free!")
@@ -966,6 +976,7 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
print("Math( Current Fuel Price: "..FuelPrice.. " - " ..FuelPrice * discount.. "<<-- FuelPrice * Discount)")
end
+ CachedFuelPrice = FuelPrice
FuelPrice = FuelPrice - (FuelPrice*discount)
if Config.FuelDebug then
@@ -1019,13 +1030,23 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
local remainingamount = (amount - Refuelamount)
MoneyToGiveBack = (GlobalTax(remainingamount * RefuelCancelledFuelCost) + (remainingamount * RefuelCancelledFuelCost))
TriggerServerEvent("cdn-fuel:server:phone:givebackmoney", MoneyToGiveBack)
+ CachedFuelPrice = nil
else
- TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice)
+ TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, false, CachedFuelPrice)
+ CachedFuelPrice = nil
end
if RefuelingType == nil then
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", finalrefuelamount, ReserveLevels, CurrentLocation)
- TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", finalrefuelamount, StationBalance, CurrentLocation, FuelPrice)
+ if CachedFuelPrice ~= nil then
+ if Config.FuelDebug then
+ print("We have a cached price: $"..CachedFuelPrice..", we will credit this to the gas station.")
+ end
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", finalrefuelamount, StationBalance, CurrentLocation, CachedFuelPrice)
+ CachedFuelPrice = nil
+ else
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", finalrefuelamount, StationBalance, CurrentLocation, FuelPrice)
+ end
end
end
local curfuel = GetFuel(vehicle)
@@ -1060,7 +1081,7 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
}) then
refueling = false
if purchasetype == "cash" then
- TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice)
+ TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, false, CachedFuelPrice)
elseif purchasetype == "bank" then
if Config.NPWD then
exports["npwd"]:createNotification({ -- You can change this export to your own notification
@@ -1074,7 +1095,7 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
})
end
if not Config.RenewedPhonePayment or purchasetype == "cash" then
- TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice)
+ TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, false, CachedFuelPrice)
end
end
local curfuel = GetFuel(vehicle)
@@ -1087,7 +1108,15 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
if RefuelingType == nil then
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", fuelamount, ReserveLevels, CurrentLocation)
- TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, FuelPrice)
+ if CachedFuelPrice ~= nil then
+ if Config.FuelDebug then
+ print("We have a cached price: $"..CachedFuelPrice..", we will credit this to the gas station.")
+ end
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, CachedFuelPrice)
+ CachedFuelPrice = nil
+ else
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, FuelPrice)
+ end
else
if Config.FuelDebug then print("Config.PlayerOwnedGasStationsEnabled == false or Config.UnlimitedFuel == true, this means reserves will not be changed.") end
end
@@ -1127,7 +1156,15 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
if RefuelingType == nil then
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", fuelamount, ReserveLevels, CurrentLocation)
- TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, FuelPrice)
+ if CachedFuelPrice ~= nil then
+ if Config.FuelDebug then
+ print("We have a cached price: $"..CachedFuelPrice..", we will credit this to the gas station.")
+ end
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, CachedFuelPrice)
+ CachedFuelPrice = nil
+ else
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", fuelamount, StationBalance, CurrentLocation, FuelPrice)
+ end
else
if Config.FuelDebug then print("Config.PlayerOwnedGasStationsEnabled == false or Config.UnlimitedFuel == true, this means reserves will not be changed.") end
end
@@ -1156,7 +1193,7 @@ end)
RegisterNetEvent('cdn-fuel:jerrycan:refuelmenu', function(itemData)
if IsPedInAnyVehicle(PlayerPedId(), false) then QBCore.Functions.Notify(Lang:t("cannot_refuel_inside"), 'error') return end
if Config.FuelDebug then print("Item Data: " .. json.encode(itemData)) end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local vehiclecoords = GetEntityCoords(vehicle)
local pedcoords = GetEntityCoords(PlayerPedId())
if GetVehicleBodyHealth(vehicle) < 100 then QBCore.Functions.Notify(Lang:t("vehicle_is_damaged"), 'error') return end
@@ -1381,7 +1418,7 @@ RegisterNetEvent('cdn-fuel:client:purchasejerrycan', function()
end)
RegisterNetEvent('cdn-fuel:jerrycan:refuelvehicle', function(data)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local vehfuel = math.floor(GetFuel(vehicle))
local maxvehrefuel = (100 - math.ceil(vehfuel))
local itemData = data.itemData
@@ -1391,7 +1428,7 @@ RegisterNetEvent('cdn-fuel:jerrycan:refuelvehicle', function(data)
else
jerrycanfuelamount = itemData.info.gasamount
end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local NotElectric = false
if Config.ElectricVehicleCharging then
local isElectric = GetCurrentVehicleType(vehicle)
@@ -1548,7 +1585,11 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, 'jerrycan')
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", tonumber(refuelAmount), ReserveLevels, CurrentLocation)
- TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuelAmount), StationBalance, CurrentLocation, FuelPrice)
+ if CachedFuelPrice ~= nil then
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuelAmount), StationBalance, CurrentLocation, CachedFuelPrice)
+ else
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuelAmount), StationBalance, CurrentLocation, FuelPrice)
+ end
else
if Config.FuelDebug then print("Config.PlayerOwnedGasStationsEnabled == false or Config.UnlimitedFuel == true, this means reserves will not be changed.") end
end
@@ -1605,13 +1646,18 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
if RefuelingType == nil then
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", tonumber(refuel.amount), ReserveLevels, CurrentLocation)
- TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuel.amount), StationBalance, CurrentLocation, FuelPrice)
+ if CachedFuelPrice ~= nil then
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuel.amount), StationBalance, CurrentLocation, CachedFuelPrice)
+ else
+ TriggerServerEvent('cdn-fuel:station:server:updatebalance', "add", tonumber(refuel.amount), StationBalance, CurrentLocation, FuelPrice)
+ end
+
else
if Config.FuelDebug then print("Config.PlayerOwnedGasStationsEnabled == false or Config.UnlimitedFuel == true, this means reserves will not be changed.") end
end
end
local total = (tonumber(refuel.amount) * FuelPrice) + GlobalTax(tonumber(refuel.amount) * FuelPrice)
- TriggerServerEvent('cdn-fuel:server:PayForFuel', total, "cash", FuelPrice)
+ TriggerServerEvent('cdn-fuel:server:PayForFuel', total, "cash", FuelPrice, false, CachedFuelPrice)
end, function() -- Play When Cancel
SetEntityVisible(fuelnozzle, true, 0)
DeleteObject(JerrycanProp)
@@ -1644,7 +1690,7 @@ end
RegisterNetEvent('cdn-syphoning:syphon:menu', function(itemData)
if IsPedInAnyVehicle(PlayerPedId(), false) then QBCore.Functions.Notify(Lang:t("syphon_inside_vehicle"), 'error') return end
if Config.SyphonDebug then print("Item Data: " .. json.encode(itemData)) end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local vehiclename = GetEntityModel(vehicle)
local vehiclecoords = GetEntityCoords(vehicle)
local pedcoords = GetEntityCoords(PlayerPedId())
@@ -1765,7 +1811,7 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
local reason = data.reason
if Config.SyphonDebug then print('Item Data Syphon: ' .. json.encode(data.itemData)) end
if Config.SyphonDebug then print('Reason: ' .. reason) end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local NotElectric = false
if Config.ElectricVehicleCharging then
local isElectric = GetCurrentVehicleType(vehicle)
@@ -1790,7 +1836,7 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
if HasSyphon then
local fitamount = (Config.SyphonKitCap - currentsyphonamount)
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local vehiclecoords = GetEntityCoords(vehicle)
local pedcoords = GetEntityCoords(PlayerPedId())
if #(vehiclecoords - pedcoords) > 2.5 then return end
@@ -2188,7 +2234,7 @@ CreateThread(function()
CreateThread(function()
while PlayerInSpecialFuelZone do
Wait(3000)
- vehicle = QBCore.Functions.GetClosestVehicle()
+ vehicle = GetClosestVehicle()
end
end)
diff --git a/client/utils.lua b/client/utils.lua
index 0f72e84..bf19f97 100644
--- a/client/utils.lua
+++ b/client/utils.lua
@@ -71,8 +71,8 @@ function CreateBlip(coords, label)
SetBlipSprite(blip, electricbolt) -- This is where the fuel thing will get changed into the electric bolt instead of the pump.
SetBlipColour(blip, 5)
else
- SetBlipColour(blip, 4)
SetBlipSprite(blip, 361)
+ SetBlipColour(blip, 4)
end
SetBlipScale(blip, 0.6)
SetBlipDisplay(blip, 4)
@@ -83,11 +83,33 @@ function CreateBlip(coords, label)
return blip
end
+function GetClosestVehicle(coords)
+ local ped = PlayerPedId()
+ local vehicles = GetGamePool('CVehicle')
+ local closestDistance = -1
+ local closestVehicle = -1
+ if coords then
+ coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
+ else
+ coords = GetEntityCoords(ped)
+ end
+ for i = 1, #vehicles, 1 do
+ local vehicleCoords = GetEntityCoords(vehicles[i])
+ local distance = #(vehicleCoords - coords)
+ if closestDistance == -1 or closestDistance > distance then
+ closestVehicle = vehicles[i]
+ closestDistance = distance
+ end
+ end
+ return closestVehicle, closestDistance
+end
+
+
function IsPlayerNearVehicle()
if Config.FuelDebug then
print("Checking if player is near a vehicle!")
end
- local vehicle = QBCore.Functions.GetClosestVehicle()
+ local vehicle = GetClosestVehicle()
local closestVehCoords = GetEntityCoords(vehicle)
if #(GetEntityCoords(PlayerPedId(), closestVehCoords)) > 3.0 then
return true
From 11a21be86c3bf28baad8d1a5538d84407fc386f2 Mon Sep 17 00:00:00 2001
From: dnelyk <95599217+dnelyk@users.noreply.github.com>
Date: Thu, 25 May 2023 21:46:18 -0700
Subject: [PATCH 2/5] feat(Fix: Syphoning Issues | Remove: NPWD "Support" as
there are issues with it.)
---
client/electric_cl.lua | 11 ----------
client/fuel_cl.lua | 27 +++--------------------
client/station_cl.lua | 50 ------------------------------------------
shared/config.lua | 3 +--
4 files changed, 4 insertions(+), 87 deletions(-)
diff --git a/client/electric_cl.lua b/client/electric_cl.lua
index d39a4d6..e0b9607 100644
--- a/client/electric_cl.lua
+++ b/client/electric_cl.lua
@@ -461,17 +461,6 @@ if Config.ElectricVehicleCharging then
if purchasetype == "cash" then
TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, true)
elseif purchasetype == "bank" then
- if Config.NPWD then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:electricityPaidFor",
- appId = "BANK",
- content = "You have paid $"..refillCost.." for electric at $"..FuelPrice.." per KWh + tax",
- secondaryTitle = "New Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- end
TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, true)
end
local curfuel = GetFuel(vehicle)
diff --git a/client/fuel_cl.lua b/client/fuel_cl.lua
index 6ab73cd..7e37e03 100644
--- a/client/fuel_cl.lua
+++ b/client/fuel_cl.lua
@@ -1083,17 +1083,6 @@ RegisterNetEvent('cdn-fuel:client:RefuelVehicle', function(data)
if purchasetype == "cash" then
TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, false, CachedFuelPrice)
elseif purchasetype == "bank" then
- if Config.NPWD then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:fuelPaidFor",
- appId = "BANK",
- content = "You have paid $"..refillCost.." for fuel at $"..FuelPrice.." Per Liter + tax",
- secondaryTitle = "New Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- end
if not Config.RenewedPhonePayment or purchasetype == "cash" then
TriggerServerEvent('cdn-fuel:server:PayForFuel', refillCost, purchasetype, FuelPrice, false, CachedFuelPrice)
end
@@ -1330,17 +1319,6 @@ RegisterNetEvent('cdn-fuel:client:jerrycanfinalmenu', function(purchasetype)
Moneyamount = QBCore.Functions.GetPlayerData().money['cash']
end
if Moneyamount > math.ceil(Config.JerryCanPrice + GlobalTax(Config.JerryCanPrice)) then
- if purchasetype == 'bank' and Config.NPWD then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:JerryCanBought",
- appId = "BANK",
- content = "You have paid $"..math.ceil(Config.JerryCanPrice + GlobalTax(Config.JerryCanPrice)).." for a jerry can",
- secondaryTitle = "New Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- end
TriggerServerEvent('cdn-fuel:server:purchase:jerrycan', purchasetype)
else
if purchasetype == 'bank' then QBCore.Functions.Notify(Lang:t("not_enough_money_in_bank"), 'error') end
@@ -1934,13 +1912,14 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
anim = Config.StealAnim,
flags = 1,
}, {}, {}, function() -- Play When Done
- if GetFuel(vehicle) >= syphonAmount then
+ if GetFuel(vehicle) >= tonumber(syphon.amount) then
PoliceAlert(GetEntityCoords(PlayerPedId()))
QBCore.Functions.Notify(Lang:t("syphon_success"), 'success')
SetFuel(vehicle, removeamount)
local syphonData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
- TriggerServerEvent('cdn-fuel:info', "add", tonumber(syphonAmount), srcPlayerData, syphonData)
+ TriggerServerEvent('cdn-fuel:info', "add", tonumber(syphon.amount), srcPlayerData, syphonData)
+ StopAnimTask(PlayerPedId(), Config.StealAnimDict, Config.StealAnim, 1.0)
else
QBCore.Functions.Notify(Lang:t("menu_syphon_vehicle_empty"), 'error')
end
diff --git a/client/station_cl.lua b/client/station_cl.lua
index fc3e367..85c6af0 100644
--- a/client/station_cl.lua
+++ b/client/station_cl.lua
@@ -1183,56 +1183,6 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
end
end)
- if Config.NPWD then
- RegisterNetEvent('cdn-fuel:client:buysellStationNPWDNotif', function(type, totalcost, location)
- if type == "buy" then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:stationPaidFor",
- appId = "BANK",
- content = "You have paid $"..totalcost.." for " .. location,
- secondaryTitle = "New Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- elseif type == "sell" then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:stationSell",
- appId = "BANK",
- content = "You have recieved $"..totalcost.." for selling " .. location,
- secondaryTitle = "New Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- end
- end)
-
- RegisterNetEvent('cdn-fuel:client:StationTransfersNPWDNotif', function(type, totalcost, location)
- if type == "deposit" then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:stationDeposit",
- appId = "BANK",
- content = "You have depositted $"..totalcost.." into " .. location,
- secondaryTitle = "Deposit Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- elseif type == "withdraw" then
- exports["npwd"]:createNotification({ -- You can change this export to your own notification
- notisId = "npwd:stationWithdraw",
- appId = "BANK",
- content = "You have withdrawn $"..totalcost.." from " .. location,
- secondaryTitle = "Withdraw Transaction",
- keepOpen = false,
- duration = 15000,
- path = "/BANK",
- })
- end
- end)
- end -- Config.NPWD
-
-- Threads
CreateThread(function() -- Spawn the Peds for Gas Stations when the resource starts.
SpawnGasStationPeds()
diff --git a/shared/config.lua b/shared/config.lua
index a4407fd..a1bea4f 100644
--- a/shared/config.lua
+++ b/shared/config.lua
@@ -5,7 +5,7 @@ Config.ShowNearestGasStationOnly = true -- When enabled, only the nearest gas st
Config.LeaveEngineRunning = true -- 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.CostMultiplier = 3.0 -- Amount to multiply 1 by. This indicates fuel price. (Default: $3.0/l or 3.0)
+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.
Config.FuelDecor = "_FUEL_LEVEL" -- Do not touch! (Default: "_FUEL_LEVEL")
@@ -54,7 +54,6 @@ Config.VehicleShutoffOnLowFuel = { -- If enabled, vehicles will turn off when th
-- Phone --
Config.RenewedPhonePayment = false -- Enables use of Renewed-Phone Payment System and Notifications
-Config.NPWD = false -- Enables phone notifications for New-Phone-Who-Dis.
-- Syphoning --
Config.UseSyphoning = false -- Follow the Syphoning Install Guide to enable this option!
From 8e1475b7f844280c71bd1720847a3ed94a784d62 Mon Sep 17 00:00:00 2001
From: dnelyk <95599217+dnelyk@users.noreply.github.com>
Date: Fri, 26 May 2023 18:07:24 -0700
Subject: [PATCH 3/5] feat(Alter Config to Reflect Version and Latest
Additions, Add Config Option for Owners having to Pick Up their own fuel.)
---
README.md | 23 ++-
client/fuel_cl.lua | 290 ++++++++++++++++++++++-------------
client/station_cl.lua | 345 ++++++++++++++++++++++++++++++++++--------
server/station_sv.lua | 66 +++++++-
4 files changed, 536 insertions(+), 188 deletions(-)
diff --git a/README.md b/README.md
index 7035ed3..270ea17 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,23 @@
![Codine Development Fuel Script Banner](https://i.imgur.com/qVOMMvW.png)
-# _CDN-Fuel (2.1.1)_
+# _CDN-Fuel (2.1.2)_
A highly in-depth fuel system for **FiveM** with support for the **QBCore Framework & QBox Remastered**.
# _Lastest Patch Information_
*Additions:*
-- Emergency Services Discounts (Config Enabled)
-- Air & Water Vehicle Fueling (Config Enabled)
-- Hose Attached To Nozzle (Config Enabled)
-- OX Library Support (Menu/Input/Inventory/Target) Additions.
-- QBox Framework now supported.
-- Electric Vehicles turn off when at 0 fuel. (Config Enabled)
+- Various Optimizations Throughout
+- Config Option for Having Owners Pickup Reserves they Purchase
*Fixes:*
-- Bank Payment Double Taxing Payments.
-- Paleto Locations PolyZone issue.
-- Fix Electric Vehicles Not Stopping On 0 Fuel
-- Fix Emergency Services Discounts
-- Fix Polyzone for MRPD Helicopter Refuel
+- Blip Color on Normal Blip not working.
+- [Jerry Can Flipped Orientation](https://github.com/dnelyk/cdn-grub-updates/assets/95599217/0489397e-99c9-43d9-8aab-0d4a45463cfd)
+- Various Syphoning Issues (Item Data / Input / Menu etc)
+- Various Jerry Can Issues (Similar to Syphon Issues)
+- Station Owners Not Recieving Full Price on Discounted Purchases
+
+*Removals:*
+- NPWD "Support" as there are various large issues.
diff --git a/client/fuel_cl.lua b/client/fuel_cl.lua
index 7e37e03..1e9b1bb 100644
--- a/client/fuel_cl.lua
+++ b/client/fuel_cl.lua
@@ -237,6 +237,7 @@ CreateThread(function()
TriggerEvent('cdn-fuel:stations:updatelocation', station_id)
end
else
+ TriggerEvent('cdn-fuel:stations:updatelocation', nil)
inGasStation = false
end
end)
@@ -502,7 +503,7 @@ RegisterNetEvent('cdn-fuel:client:grabnozzle', function()
end
end
holdingnozzle = true
- Citizen.CreateThread(function()
+ CreateThread(function()
while holdingnozzle do
local currentcoords = GetEntityCoords(ped)
local dist = #(grabbednozzlecoords - currentcoords)
@@ -1228,7 +1229,7 @@ RegisterNetEvent('cdn-fuel:jerrycan:refuelmenu', function(itemData)
title = Lang:t("menu_header_jerry_can"),
options = {
{
- title = Lang:t("menu_header_refuel_jerry_can"),
+ title = Lang:t("menu_header_refuel_vehicle"),
event = 'cdn-fuel:jerrycan:refuelvehicle',
args = {itemData = itemData},
disabled = nogas,
@@ -1396,6 +1397,7 @@ RegisterNetEvent('cdn-fuel:client:purchasejerrycan', function()
end)
RegisterNetEvent('cdn-fuel:jerrycan:refuelvehicle', function(data)
+ local ped = PlayerPedId()
local vehicle = GetClosestVehicle()
local vehfuel = math.floor(GetFuel(vehicle))
local maxvehrefuel = (100 - math.ceil(vehfuel))
@@ -1425,82 +1427,154 @@ RegisterNetEvent('cdn-fuel:jerrycan:refuelvehicle', function(data)
maxvehrefuel = Config.JerryCanCap
end
if maxvehrefuel >= jerrycanfuelamount then maxvehrefuel = jerrycanfuelamount elseif maxvehrefuel < jerrycanfuelamount then maxvehrefuel = maxvehrefuel end
- local refuel = exports['qb-input']:ShowInput({
- header = Lang:t("input_select_refuel_header"),
- submitText = Lang:t("input_refuel_submit"),
- inputs = {
- {
- type = 'number',
- isRequired = true,
- name = 'amount',
- text = Lang:t("input_max_fuel_footer_1") .. maxvehrefuel .. Lang:t("input_max_fuel_footer_2")
+ -- Need to Convert to OX --
+ if Config.Ox.Input then
+ local refuel = lib.inputDialog(Lang:t("input_select_refuel_header"), {Lang:t("input_max_fuel_footer_1") .. maxvehrefuel .. Lang:t("input_max_fuel_footer_2")})
+ if not refuel then return end
+ local refuelAmount = tonumber(refuel[1])
+ --
+ if refuel and refuelAmount then
+ if tonumber(refuelAmount) == 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return elseif tonumber(refuelAmount) < 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return end
+ if tonumber(refuelAmount) > jerrycanfuelamount then QBCore.Functions.Notify(Lang:t("jerry_can_not_enough_fuel"), 'error') return end
+ local refueltimer = Config.RefuelTime * tonumber(refuelAmount)
+ if tonumber(refuelAmount) < 10 then refueltimer = Config.RefuelTime * 10 end
+ if vehfuel + tonumber(refuelAmount) > 100 then QBCore.Functions.Notify(Lang:t("tank_cannot_fit"), 'error') return end
+ local refuelAmount = tonumber(refuelAmount)
+ JerrycanProp = CreateObject(joaat('w_am_jerrycan'), 1.0, 1.0, 1.0, true, true, false)
+ local lefthand = GetPedBoneIndex(ped, 18905)
+ AttachEntityToEntity(JerrycanProp, ped, lefthand, 0.11 --[[Left - Right (Kind of)]] , 0.0 --[[Up - Down]], 0.25 --[[Forward - Backward]], 15.0, 170.0, 90.42, 0, 1, 0, 1, 0, 1)
+ if Config.Ox.Progress then
+ if lib.progressCircle({
+ duration = refueltimer,
+ label = Lang:t("prog_refueling_vehicle"),
+ position = 'bottom',
+ useWhileDead = false,
+ canCancel = true,
+ disable = {
+ car = true,
+ move = true,
+ combat = true
+ },
+ anim = {
+ dict = Config.JerryCanAnimDict,
+ clip = Config.JerryCanAnim
+ },
+ }) then
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
+ local JerryCanItemData = data.itemData
+ local srcPlayerData = QBCore.Functions.GetPlayerData()
+ TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuelAmount), srcPlayerData, JerryCanItemData)
+ SetFuel(vehicle, (vehfuel + refuelAmount))
+ else
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
+ end
+ else
+ QBCore.Functions.Progressbar('refuel_gas', Lang:t("prog_refueling_vehicle"), refueltimer, false, true, { -- Name | Label | Time | useWhileDead | canCancel
+ disableMovement = true,
+ disableCarMovement = true,
+ disableMouse = false,
+ disableCombat = true,
+ }, {
+ animDict = Config.JerryCanAnimDict,
+ anim = Config.JerryCanAnim,
+ flags = 17,
+ }, {}, {}, function() -- Play When Done
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
+ local JerryCanItemData = data.itemData
+ local srcPlayerData = QBCore.Functions.GetPlayerData()
+ TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuelAmount), srcPlayerData, JerryCanItemData)
+ SetFuel(vehicle, (vehfuel + refuelAmount))
+ end, function() -- Play When Cancel
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
+ end, "jerrycan")
+ end
+ end
+ else
+ local refuel = exports['qb-input']:ShowInput({
+ header = Lang:t("input_select_refuel_header"),
+ submitText = Lang:t("input_refuel_submit"),
+ inputs = {
+ {
+ type = 'number',
+ isRequired = true,
+ name = 'amount',
+ text = Lang:t("input_max_fuel_footer_1") .. maxvehrefuel .. Lang:t("input_max_fuel_footer_2")
+ }
}
- }
- })
- if refuel then
- if tonumber(refuel.amount) == 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return elseif tonumber(refuel.amount) < 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return end
- if tonumber(refuel.amount) > jerrycanfuelamount then QBCore.Functions.Notify(Lang:t("jerry_can_not_enough_fuel"), 'error') return end
- local refueltimer = Config.RefuelTime * tonumber(refuel.amount)
- if tonumber(refuel.amount) < 10 then refueltimer = Config.RefuelTime * 10 end
- if vehfuel + tonumber(refuel.amount) > 100 then QBCore.Functions.Notify(Lang:t("tank_cannot_fit"), 'error') return end
- local refuelAmount = tonumber(refuel.amount)
- JerrycanProp = CreateObject(joaat('w_am_jerrycan'), 1.0, 1.0, 1.0, true, true, false)
- local lefthand = GetPedBoneIndex(PlayerPedId(), 18905)
- AttachEntityToEntity(JerrycanProp, PlayerPedId(), lefthand, 0.11 --[[Left - Right (Kind of)]] , 0.05--[[Up - Down]], 0.27 --[[Forward - Backward]], -15.0, 170.0, -90.42, 0, 1, 0, 1, 0, 1)
- if Config.Ox.Progress then
- if lib.progressCircle({
- duration = refueltimer,
- label = Lang:t("prog_refueling_vehicle"),
- position = 'bottom',
- useWhileDead = false,
- canCancel = true,
- disable = {
- car = true,
- move = true,
- combat = true
- },
- anim = {
- dict = Config.JerryCanAnimDict,
- clip = Config.JerryCanAnim
- },
- }) then
- DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
- QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
- local JerryCanItemData = data.itemData
- local srcPlayerData = QBCore.Functions.GetPlayerData()
- TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuelAmount), srcPlayerData, JerryCanItemData)
- SetFuel(vehicle, (vehfuel + refuelAmount))
- else
- DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
- QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
+ })
+ if refuel then
+ if tonumber(refuel.amount) == 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return elseif tonumber(refuel.amount) < 0 then QBCore.Functions.Notify(Lang:t("more_than_zero"), 'error') return end
+ if tonumber(refuel.amount) > jerrycanfuelamount then QBCore.Functions.Notify(Lang:t("jerry_can_not_enough_fuel"), 'error') return end
+ local refueltimer = Config.RefuelTime * tonumber(refuel.amount)
+ if tonumber(refuel.amount) < 10 then refueltimer = Config.RefuelTime * 10 end
+ if vehfuel + tonumber(refuel.amount) > 100 then QBCore.Functions.Notify(Lang:t("tank_cannot_fit"), 'error') return end
+ JerrycanProp = CreateObject(joaat('w_am_jerrycan'), 1.0, 1.0, 1.0, true, true, false)
+ local lefthand = GetPedBoneIndex(ped, 18905)
+ AttachEntityToEntity(JerrycanProp, ped, lefthand, 0.11 --[[Left - Right (Kind of)]] , 0.0 --[[Up - Down]], 0.25 --[[Forward - Backward]], 15.0, 170.0, 90.42, 0, 1, 0, 1, 0, 1)
+ if Config.Ox.Progress then
+ if lib.progressCircle({
+ duration = refueltimer,
+ label = Lang:t("prog_refueling_vehicle"),
+ position = 'bottom',
+ useWhileDead = false,
+ canCancel = true,
+ disable = {
+ car = true,
+ move = true,
+ combat = true
+ },
+ anim = {
+ dict = Config.JerryCanAnimDict,
+ clip = Config.JerryCanAnim
+ },
+ }) then
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
+ local JerryCanItemData = data.itemData
+ local srcPlayerData = QBCore.Functions.GetPlayerData()
+ TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuel.amount), srcPlayerData, JerryCanItemData)
+ SetFuel(vehicle, (vehfuel + refuel.amount))
+ else
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
+ end
+ else
+ QBCore.Functions.Progressbar('refuel_gas', Lang:t("prog_refueling_vehicle"), refueltimer, false, true, { -- Name | Label | Time | useWhileDead | canCancel
+ disableMovement = true,
+ disableCarMovement = true,
+ disableMouse = false,
+ disableCombat = true,
+ }, {
+ animDict = Config.JerryCanAnimDict,
+ anim = Config.JerryCanAnim,
+ flags = 17,
+ }, {}, {}, function() -- Play When Done
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
+ local JerryCanItemData = data.itemData
+ local srcPlayerData = QBCore.Functions.GetPlayerData()
+ TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuel.amount), srcPlayerData, JerryCanItemData)
+ SetFuel(vehicle, (vehfuel + refuel.amount))
+ end, function() -- Play When Cancel
+ DeleteObject(JerrycanProp)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
+ end, "jerrycan")
end
- else
- QBCore.Functions.Progressbar('refuel_gas', Lang:t("prog_refueling_vehicle"), refueltimer, false, true, { -- Name | Label | Time | useWhileDead | canCancel
- disableMovement = true,
- disableCarMovement = true,
- disableMouse = false,
- disableCombat = true,
- }, {
- animDict = Config.JerryCanAnimDict,
- anim = Config.JerryCanAnim,
- flags = 17,
- }, {}, {}, function() -- Play When Done
- DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
- QBCore.Functions.Notify(Lang:t("jerry_can_success_vehicle"), 'success')
- local JerryCanItemData = data.itemData
- local srcPlayerData = QBCore.Functions.GetPlayerData()
- TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuel.amount), srcPlayerData, JerryCanItemData)
- SetFuel(vehicle, (vehfuel + refuel.amount))
- end, function() -- Play When Cancel
- DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
- QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
- end, "jerrycan")
end
end
+
else
QBCore.Functions.Notify(Lang:t("need_electric_charger"), 'error', 7500) return
end
@@ -1521,8 +1595,11 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
else
jerrycanfuelamount = itemData.info.gasamount
end
+
+ local ped = PlayerPedId()
+
if Config.Ox.Input then
- local JerryCanMaxRefuel = (Config.JerryCanCap - itemData.metadata.cdn_fuel)
+ local JerryCanMaxRefuel = (Config.JerryCanCap - jerrycanfuelamount)
local refuel = lib.inputDialog(Lang:t("input_select_refuel_header"), {Lang:t("input_max_fuel_footer_1") .. JerryCanMaxRefuel .. Lang:t("input_max_fuel_footer_2")})
if not refuel then return end
local refuelAmount = tonumber(refuel[1])
@@ -1536,8 +1613,8 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
if not CanAfford(price, "cash") then QBCore.Functions.Notify(Lang:t("not_enough_money_in_cash"), 'error') return end
JerrycanProp = CreateObject(joaat('w_am_jerrycan'), 1.0, 1.0, 1.0, true, true, false)
- local lefthand = GetPedBoneIndex(PlayerPedId(), 18905)
- AttachEntityToEntity(JerrycanProp, PlayerPedId(), lefthand, 0.11 --[[Left - Right]] , 0.05--[[Up - Down]], 0.27 --[[Forward - Backward]], -15.0, 170.0, -90.42, 0, 1, 0, 1, 0, 1)
+ local lefthand = GetPedBoneIndex(ped, 18905)
+ AttachEntityToEntity(JerrycanProp, ped, lefthand, 0.11 --[[Left - Right]] , 0.05--[[Up - Down]], 0.27 --[[Forward - Backward]], -15.0, 170.0, -90.42, 0, 1, 0, 1, 0, 1)
SetEntityVisible(fuelnozzle, false, 0)
if lib.progressCircle({
duration = refueltimer,
@@ -1557,10 +1634,15 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
}) then
SetEntityVisible(fuelnozzle, true, 0)
DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("jerry_can_success"), 'success')
local srcPlayerData = QBCore.Functions.GetPlayerData()
- TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, 'jerrycan')
+ if Config.Ox.Inventory then
+ TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, 'jerrycan')
+ else
+ TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, itemData)
+ end
+
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", tonumber(refuelAmount), ReserveLevels, CurrentLocation)
if CachedFuelPrice ~= nil then
@@ -1576,7 +1658,7 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
else
SetEntityVisible(fuelnozzle, true, 0)
DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end
end
@@ -1601,8 +1683,8 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
local price = (tonumber(refuel.amount) * FuelPrice) + GlobalTax(tonumber(refuel.amount) * FuelPrice)
if not CanAfford(price, "cash") then QBCore.Functions.Notify(Lang:t("not_enough_money_in_cash"), 'error') return end
JerrycanProp = CreateObject(joaat('w_am_jerrycan'), 1.0, 1.0, 1.0, true, true, false)
- local lefthand = GetPedBoneIndex(PlayerPedId(), 18905)
- AttachEntityToEntity(JerrycanProp, PlayerPedId(), lefthand, 0.11 --[[Left - Right]] , 0.05 --[[Up - Down]], 0.27 --[[Forward - Backward]], -15.0, 170.0, -90.42, 0, 1, 0, 1, 0, 1)
+ local lefthand = GetPedBoneIndex(ped, 18905)
+ AttachEntityToEntity(JerrycanProp, ped, lefthand, 0.11 --[[Left - Right]] , 0.05 --[[Up - Down]], 0.27 --[[Forward - Backward]], -15.0, 170.0, -90.42, 0, 1, 0, 1, 0, 1)
SetEntityVisible(fuelnozzle, false, 0)
QBCore.Functions.Progressbar('refuel_gas', Lang:t("prog_jerry_can_refuel"), refueltimer, false,true, { -- Name | Label | Time | useWhileDead | canCancel
disableMovement = true,
@@ -1616,11 +1698,15 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
}, {}, {}, function() -- Play When Done
SetEntityVisible(fuelnozzle, true, 0)
DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("jerry_can_success"), 'success')
local jerryCanData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
- TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuel.amount), srcPlayerData, jerryCanData)
+ if Config.Ox.Inventory then
+ TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, 'jerrycan')
+ else
+ TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, jerryCanData)
+ end
if RefuelingType == nil then
if Config.PlayerOwnedGasStationsEnabled and not Config.UnlimitedFuel then
TriggerServerEvent('cdn-fuel:station:server:updatereserves', "remove", tonumber(refuel.amount), ReserveLevels, CurrentLocation)
@@ -1639,7 +1725,7 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
end, function() -- Play When Cancel
SetEntityVisible(fuelnozzle, true, 0)
DeleteObject(JerrycanProp)
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end, "jerrycan")
end
@@ -1787,6 +1873,7 @@ end)
RegisterNetEvent('cdn-syphoning:syphon', function(data)
local reason = data.reason
+ local ped = PlayerPedId()
if Config.SyphonDebug then print('Item Data Syphon: ' .. json.encode(data.itemData)) end
if Config.SyphonDebug then print('Reason: ' .. reason) end
local vehicle = GetClosestVehicle()
@@ -1816,7 +1903,7 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
local fitamount = (Config.SyphonKitCap - currentsyphonamount)
local vehicle = GetClosestVehicle()
local vehiclecoords = GetEntityCoords(vehicle)
- local pedcoords = GetEntityCoords(PlayerPedId())
+ local pedcoords = GetEntityCoords(ped)
if #(vehiclecoords - pedcoords) > 2.5 then return end
local cargasamount = GetFuel(vehicle)
local maxsyphon = math.floor(GetFuel(vehicle))
@@ -1861,9 +1948,9 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
clip = Config.StealAnim
},
}) then
- StopAnimTask(PlayerPedId(), Config.StealAnimDict, Config.StealAnim, 1.0)
+ StopAnimTask(ped, Config.StealAnimDict, Config.StealAnim, 1.0)
if GetFuel(vehicle) >= syphonAmount then
- PoliceAlert(GetEntityCoords(PlayerPedId()))
+ PoliceAlert(GetEntityCoords(ped))
QBCore.Functions.Notify(Lang:t("syphon_success"), 'success')
SetFuel(vehicle, removeamount)
local syphonData = data.itemData
@@ -1873,8 +1960,8 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
QBCore.Functions.Notify(Lang:t("menu_syphon_vehicle_empty"), 'error')
end
else
- PoliceAlert(GetEntityCoords(PlayerPedId()))
- StopAnimTask(PlayerPedId(), Config.StealAnimDict, Config.StealAnim, 1.0)
+ PoliceAlert(GetEntityCoords(ped))
+ StopAnimTask(ped, Config.StealAnimDict, Config.StealAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end
end
@@ -1913,19 +2000,19 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
flags = 1,
}, {}, {}, function() -- Play When Done
if GetFuel(vehicle) >= tonumber(syphon.amount) then
- PoliceAlert(GetEntityCoords(PlayerPedId()))
+ PoliceAlert(GetEntityCoords(ped))
QBCore.Functions.Notify(Lang:t("syphon_success"), 'success')
SetFuel(vehicle, removeamount)
local syphonData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
TriggerServerEvent('cdn-fuel:info', "add", tonumber(syphon.amount), srcPlayerData, syphonData)
- StopAnimTask(PlayerPedId(), Config.StealAnimDict, Config.StealAnim, 1.0)
+ StopAnimTask(ped, Config.StealAnimDict, Config.StealAnim, 1.0)
else
QBCore.Functions.Notify(Lang:t("menu_syphon_vehicle_empty"), 'error')
end
end, function() -- Play When Cancel
- PoliceAlert(GetEntityCoords(PlayerPedId()))
- StopAnimTask(PlayerPedId(), Config.StealAnimDict, Config.StealAnim, 1.0)
+ PoliceAlert(GetEntityCoords(ped))
+ StopAnimTask(ped, Config.StealAnimDict, Config.StealAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end, "syphoningkit")
end
@@ -1949,7 +2036,6 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
if tonumber(refuelAmount) + tonumber(cargasamount) > 100 then QBCore.Functions.Notify(Lang:t("tank_cannot_fit"), 'error') return end
local refueltimer = Config.RefuelTime * tonumber(refuelAmount)
if tonumber(refuelAmount) < 10 then refueltimer = Config.RefuelTime * 10 end
-
if lib.progressCircle({
duration = refueltimer,
label = Lang:t("prog_refueling_vehicle"),
@@ -1966,14 +2052,14 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
clip = Config.JerryCanAnim
},
}) then
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("syphon_success_vehicle"), 'success')
SetFuel(vehicle, cargasamount + tonumber(refuelAmount))
local syphonData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuelAmount), srcPlayerData, syphonData)
else
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end
end
@@ -2006,14 +2092,14 @@ RegisterNetEvent('cdn-syphoning:syphon', function(data)
anim = Config.JerryCanAnim,
flags = 17,
}, {}, {}, function() -- Play When Done
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("syphon_success_vehicle"), 'success')
SetFuel(vehicle, cargasamount + tonumber(refuel.amount))
local syphonData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
TriggerServerEvent('cdn-fuel:info', "remove", tonumber(refuel.amount), srcPlayerData, syphonData)
end, function() -- Play When Cancel
- StopAnimTask(PlayerPedId(), Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
+ StopAnimTask(ped, Config.JerryCanAnimDict, Config.JerryCanAnim, 1.0)
QBCore.Functions.Notify(Lang:t("cancelled"), 'error')
end, "syphoningkit")
end
@@ -2098,12 +2184,12 @@ RegisterNetEvent('cdn-fuel:client:grabnozzle:special', function()
SetEntityDrawOutline(SpecialFuelNozzleObj --[[ Entity ]], true --[[ boolean ]])
end
end
- Citizen.CreateThread(function()
+ CreateThread(function()
while HoldingSpecialNozzle do
local currentcoords = GetEntityCoords(ped)
local dist = #(grabbednozzlecoords - currentcoords)
TargetCreated = true
- if dist > Config.AirAndWaterVehicleFueling['nozzle_length'] or IsPedInAnyVehicle(PlayerPedId(), false) then
+ if dist > Config.AirAndWaterVehicleFueling['nozzle_length'] or IsPedInAnyVehicle(ped, false) then
HoldingSpecialNozzle = false
DeleteObject(SpecialFuelNozzleObj)
QBCore.Functions.Notify(Lang:t("nozzle_cannot_reach"), 'error')
@@ -2576,6 +2662,8 @@ if Config.VehicleShutoffOnLowFuel['shutOffLevel'] == 0 then
Config.VehicleShutoffOnLowFuel['shutOffLevel'] = 0.55
end
+-- This loop does use quite a bit of performance, but, is needed due to electric vehicles running without fuel & normal vehicles driving backwards!
+-- You can remove if you need the performance, but we believe it is very important.
CreateThread(function()
while true do
Wait(0)
diff --git a/client/station_cl.lua b/client/station_cl.lua
index 85c6af0..012822c 100644
--- a/client/station_cl.lua
+++ b/client/station_cl.lua
@@ -3,7 +3,21 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
local QBCore = exports[Config.Core]:GetCoreObject()
local PedsSpawned = false
+ -- These are for fuel pickup:
+ local CreatedEventHandler = false
+ local locationSwapHandler
+ local spawnedTankerTrailer
+ local spawnedDeliveryTruck
+ local ReservePickupData = {}
+
-- Functions
+ local function RequestAndLoadModel(model)
+ RequestModel(model)
+ while not HasModelLoaded(model) do
+ Wait(5)
+ end
+ end
+
local function UpdateStationInfo(info)
if Config.FuelDebug then print("Fetching Information for Location #" ..CurrentLocation) end
QBCore.Functions.TriggerCallback('cdn-fuel:server:fetchinfo', function(result)
@@ -28,23 +42,20 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
-- Fuel Station's Balance --
if info == "all" or info == "balance" then
StationBalance = v.balance
- if Config.FuelDebug then print("Successfully Fetched: Balance") end
+ if Config.FuelDebug then print("Successfully Fetched: Balance") end
end
----------------
end
end
end, CurrentLocation)
- end exports(UpdateStationInfo, UpdateStationInfo)
+ end exports(UpdateStationInfo, UpdateStationInfo)
local function SpawnGasStationPeds()
if not Config.GasStations or not next(Config.GasStations) or PedsSpawned then return end
for i = 1, #Config.GasStations do
local current = Config.GasStations[i]
current.pedmodel = type(current.pedmodel) == 'string' and joaat(current.pedmodel) or current.pedmodel
- RequestModel(current.pedmodel)
- while not HasModelLoaded(current.pedmodel) do
- Wait(0)
- end
+ RequestAndLoadModel(current.pedmodel)
local ped = CreatePed(0, current.pedmodel, current.pedcoords.x, current.pedcoords.y, current.pedcoords.z, current.pedcoords.h, false, false)
FreezeEntityPosition(ped, true)
SetEntityInvincible(ped, true)
@@ -66,10 +77,43 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
PedsSpawned = true
end
- -- Events
+ local function GenerateRandomTruckModel()
+ local possibleTrucks = Config.PossibleDeliveryTrucks
+ if possibleTrucks then
+ return possibleTrucks[math.random(#possibleTrucks)]
+ end
+ end
+
+ local function SpawnPickupVehicles()
+ local trailer = GetHashKey('tanker')
+ local truckToSpawn = GetHashKey(GenerateRandomTruckModel())
+ if truckToSpawn then
+ RequestAndLoadModel(truckToSpawn)
+ RequestAndLoadModel(trailer)
+ spawnedDeliveryTruck = CreateVehicle(truckToSpawn, Config.DeliveryTruckSpawns['truck'], true, false)
+ spawnedTankerTrailer = CreateVehicle(trailer, Config.DeliveryTruckSpawns['trailer'], true, false)
+ SetModelAsNoLongerNeeded(truckToSpawn) -- removes model from game memory as we no longer need it
+ SetModelAsNoLongerNeeded(trailer) -- removes model from game memory as we no longer need it
+ SetEntityAsMissionEntity(spawnedDeliveryTruck, 1, 1)
+ SetEntityAsMissionEntity(spawnedTankerTrailer, 1, 1)
+ AttachVehicleToTrailer(spawnedDeliveryTruck, spawnedTankerTrailer, 15.0)
+ -- Now our vehicle is spawned.
+ if spawnedDeliveryTruck ~= 0 and spawnedTankerTrailer ~= 0 then
+ TriggerEvent("vehiclekeys:client:SetOwner", QBCore.Functions.GetPlate(spawnedDeliveryTruck))
+ return true
+ else
+ return false
+ end
+ end
+ end
+
+ -- Events
RegisterNetEvent('cdn-fuel:stations:updatelocation', function(updatedlocation)
- if Config.FuelDebug then if CurrentLocation == nil then CurrentLocation = 0 end print('Location: '..CurrentLocation..' has been replaced with a new location: ' ..updatedlocation) end
- CurrentLocation = updatedlocation
+ if Config.FuelDebug then if CurrentLocation == nil then CurrentLocation = 0 end
+ if updatedlocation == nil then updatedlocation = 0 end
+ print('Location: '..CurrentLocation..' has been replaced with a new location: ' ..updatedlocation)
+ end
+ CurrentLocation = updatedlocation or 0
end)
RegisterNetEvent('cdn-fuel:stations:client:buyreserves', function(data)
@@ -80,6 +124,173 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if Config.FuelDebug then print("^5Attempting Purchase of ^2"..amount.. "^5 Fuel Reserves for location #"..location.."! Purchase Price: ^2"..price) end
end)
+ RegisterNetEvent('cdn-fuel:station:client:initiatefuelpickup', function(amountBought, finalReserveAmountAfterPurchase, location)
+ if amountBought and finalReserveAmountAfterPurchase and location then
+ ReservePickupData = nil
+ ReservePickupData = {
+ finalAmount = finalReserveAmountAfterPurchase,
+ amountBought = amountBought,
+ location = location,
+ }
+
+ if SpawnPickupVehicles() then
+ QBCore.Functions.Notify('Your fuel order is available for pickup! Take a look at your GPS to find the pickup!', 'success')
+ SetNewWaypoint(Config.DeliveryTruckSpawns['truck'].x, Config.DeliveryTruckSpawns['truck'].y)
+ SetUseWaypointAsDestination(true)
+ ReservePickupData.blip = CreateBlip(vector3(Config.DeliveryTruckSpawns['truck'].x, Config.DeliveryTruckSpawns['truck'].y, Config.DeliveryTruckSpawns['truck'].z), "Truck Pickup")
+ SetBlipColour(ReservePickupData.blip, 5)
+
+ -- Create Zone
+ ReservePickupData.PolyZone = PolyZone:Create(Config.DeliveryTruckSpawns.PolyZone.coords, {
+ name = "cdn_fuel_zone_delivery_truck_pickup",
+ minZ = Config.DeliveryTruckSpawns.PolyZone.minz,
+ maxZ = Config.DeliveryTruckSpawns.PolyZone.maxz,
+ debugPoly = Config.PolyDebug
+ })
+
+ -- Setup onPlayerInOut Events for zone that is created.
+ ReservePickupData.PolyZone:onPlayerInOut(function(isPointInside)
+ if isPointInside then
+ if Config.FuelDebug then
+ print("Player has arrived at the pickup location!")
+ end
+ RemoveBlip(ReservePickupData.blip)
+ ReservePickupData.blip = nil
+ CreateThread(function()
+ local ped = PlayerPedId()
+ local alreadyHasTruck = false
+ local hasArrivedAtLocation = false
+ local VehicleDelivered = false
+ local EndAwaitListener = false
+ local stopNotifyTemp = false
+ local AwaitingInput = false
+ while true do
+ Wait(100)
+ if VehicleDelivered then break end
+ if IsPedInAnyVehicle(ped, false) then
+ if GetVehiclePedIsIn(ped, false) == spawnedDeliveryTruck then
+ if Config.FuelDebug then
+ print("Player is inside of the delivery truck!")
+ end
+
+ if not alreadyHasTruck then
+ local loc = {}
+ loc.x, loc.y = Config.GasStations[ReservePickupData.location].pedcoords.x, Config.GasStations[ReservePickupData.location].pedcoords.y
+ SetNewWaypoint(loc.x, loc.y)
+ SetUseWaypointAsDestination(true)
+ alreadyHasTruck = true
+ else
+ if not CreatedEventHandler then
+ local function AwaitInput()
+ if AwaitingInput then return end
+ AwaitingInput = true
+ if Config.FuelDebug then print("Executing function `AwaitInput()`") end
+ CreateThread(function()
+ while true do
+ Wait(0)
+ if EndAwaitListener or not hasArrivedAtLocation then
+ AwaitingInput = false
+ break
+ end
+ if IsControlJustReleased(2, 38) then
+ local distBetweenTruckAndTrailer = #(GetEntityCoords(spawnedDeliveryTruck) - GetEntityCoords(spawnedTankerTrailer))
+ if distBetweenTruckAndTrailer > 10.0 then
+ distBetweenTruckAndTrailer = nil
+ if not stopNotifyTemp then
+ QBCore.Functions.Notify('The trailer is not attached to the truck or is too far!', 'error', 7500)
+ end
+ stopNotifyTemp = true
+ Wait(1000)
+ stopNotifyTemp = false
+ else
+ EndAwaitListener = true
+ local ped = PlayerPedId()
+ VehicleDelivered = true
+ -- Handle Vehicle Dropoff
+ -- Remove PolyZone --
+ ReservePickupData.PolyZone:destroy()
+ ReservePickupData.PolyZone = nil
+ -- Get Ped Out of Vehicle if Inside --
+ if IsPedInAnyVehicle(ped, true) and GetVehiclePedIsIn(ped, false) == spawnedDeliveryTruck then
+ TaskLeaveVehicle(
+ ped --[[ Ped ]],
+ spawnedDeliveryTruck --[[ Vehicle ]],
+ 1 --[[ flags | integer ]]
+ )
+ Wait(5000)
+ end
+
+ if Config.Ox.DrawText then
+ lib.hideTextUI()
+ else
+ exports[Config.Core]:HideText()
+ end
+
+ -- Remove Vehicle --
+ DeleteEntity(spawnedDeliveryTruck)
+ DeleteEntity(spawnedTankerTrailer)
+ -- Send Data to Server to Put Into Station --
+ TriggerServerEvent('cdn-fuel:station:server:fuelpickup:finished', ReservePickupData.location)
+ -- Remove Handler
+ RemoveEventHandler(locationSwapHandler)
+ AwaitingInput = false
+ CreatedEventHandler = false
+ ReservePickupData = nil
+ ReservePickupData = {}
+ -- Break Loop
+ break
+ end
+ end
+ end
+ end)
+ AwaitingInput = true
+ end
+ locationSwapHandler = AddEventHandler('cdn-fuel:stations:updatelocation', function(location)
+ if location == nil or location ~= ReservePickupData.location then
+ hasArrivedAtLocation = false
+ if Config.Ox.DrawText then
+ lib.hideTextUI()
+ else
+ exports[Config.Core]:HideText()
+ end
+ -- Break Listener
+ EndAwaitListener = true
+ Wait(50)
+ EndAwaitListener = false
+ else
+ hasArrivedAtLocation = true
+ if Config.Ox.DrawText then
+ lib.showTextUI("[E] Drop Off Truck", {
+ position = 'left-center'
+ })
+ else
+ exports[Config.Core]:DrawText("[E] Drop Off Truck", 'left')
+ end
+ -- Add Listner for Keypress
+ AwaitInput()
+ end
+ end)
+ end
+ end
+ end
+ end
+ end
+ end)
+ else
+
+ end
+ end)
+ else
+ -- This is just a worst case scenario event, if the vehicles somehow do not spawn.
+ TriggerServerEvent('cdn-fuel:station:server:fuelpickup:failed', location)
+ end
+ else
+ if Config.FuelDebug then
+ print("An error has occurred. The amountBought / finalReserveAmountAfterPurchase / location is nil: `cdn-fuel:station:client:initiatefuelpickup`")
+ end
+ end
+ end)
+
RegisterNetEvent('cdn-fuel:stations:client:purchaselocation', function(data)
local location = data.location
local CitizenID = QBCore.Functions.GetPlayerData().citizenid
@@ -98,7 +309,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if not IsOwned then
TriggerServerEvent('cdn-fuel:server:buyStation', location, CitizenID)
- elseif IsOwned then
+ elseif IsOwned then
QBCore.Functions.Notify(Lang:t("station_already_owned"), 'error', 7500)
end
end)
@@ -163,8 +374,8 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
event = 'cdn-fuel:stations:client:buyreserves',
args = {
location = location,
- price = price,
- amount = amount,
+ price = price,
+ amount = amount,
}
},
{
@@ -188,20 +399,20 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
},
{
header = Lang:t("menu_station_reserves_purchase_header")..price,
- txt = Lang:t("menu_station_reserves_purchase_footer")..price.."!",
+ txt = Lang:t("menu_station_reserves_purchase_footer")..price.."!",
icon = "fas fa-usd",
params = {
event = "cdn-fuel:stations:client:buyreserves",
args = {
location = location,
- price = price,
- amount = amount,
+ price = price,
+ amount = amount,
},
},
},
{
header = Lang:t("menu_header_close"),
- txt = Lang:t("menu_station_reserves_cancel_footer"),
+ txt = Lang:t("menu_station_reserves_cancel_footer"),
icon = "fas fa-times-circle",
params = {
event = "qb-menu:closeMenu",
@@ -215,7 +426,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
end)
RegisterNetEvent('cdn-fuel:stations:client:purchasereserves', function(data)
- CanOpen = false
+ local CanOpen = false
local location = data.location
QBCore.Functions.TriggerCallback('cdn-fuel:server:isowner', function(result)
local CitizenID = QBCore.Functions.GetPlayerData().citizenid
@@ -243,9 +454,9 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
{ type = "input", label = 'Required Reserves',
default = Config.MaxFuelReserves - Currentreserveamount,
disabled = true },
- { type = "slider", label = 'Full Reserve Cost: $' ..GlobalTax((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice) + ((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice).. '',
- default = Config.MaxFuelReserves - Currentreserveamount,
- min = 0,
+ { type = "slider", label = 'Full Reserve Cost: $' ..math.ceil(GlobalTax((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice) + ((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice)).. '',
+ default = Config.MaxFuelReserves - Currentreserveamount,
+ min = 0,
max = Config.MaxFuelReserves - Currentreserveamount
},
})
@@ -261,20 +472,20 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if (Reservebuyamount + Currentreserveamount) > Config.MaxFuelReserves then
QBCore.Functions.Notify(Lang:t("station_reserve_cannot_fit"), "error")
else
- if GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice) <= bankmoney then
- local price = GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice)
+ if math.ceil(GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice)) <= bankmoney then
+ local price = math.ceil(GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice))
if Config.FuelDebug then print("Price: "..price) end
TriggerEvent("cdn-fuel:stations:client:purchasereserves:final", location, price, amount)
-
+
else
QBCore.Functions.Notify(Lang:t("not_enough_money_in_bank"), 'error', 7500)
end
- end
+ end
end
else
local reserves = exports['qb-input']:ShowInput({
header = Lang:t("input_purchase_reserves_header_1") .. Lang:t("input_purchase_reserves_header_2") .. Currentreserveamount .. Lang:t("input_purchase_reserves_header_3") ..
- GlobalTax((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice) + ((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice) .. "",
+ math.ceil(GlobalTax((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice) + ((Config.MaxFuelReserves - Currentreserveamount) * Config.FuelReservesPrice)) .. "",
submitText = Lang:t("input_purchase_reserves_submit_text"),
inputs = { {
type = 'number',
@@ -293,21 +504,21 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if (Reservebuyamount + Currentreserveamount) > Config.MaxFuelReserves then
QBCore.Functions.Notify(Lang:t("station_reserve_cannot_fit"), "error")
else
- if GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice) <= bankmoney then
- local price = GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice)
+ if math.ceil(GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice)) <= bankmoney then
+ local price = math.ceil(GlobalTax(Reservebuyamount * Config.FuelReservesPrice) + (Reservebuyamount * Config.FuelReservesPrice))
if Config.FuelDebug then print("Price: "..price) end
TriggerEvent("cdn-fuel:stations:client:purchasereserves:final", location, price, amount)
-
+
else
QBCore.Functions.Notify(Lang:t("not_enough_money_in_bank"), 'error', 7500)
end
- end
+ end
end
end
end
end)
- RegisterNetEvent('cdn-fuel:stations:client:changefuelprice', function(data)
+ RegisterNetEvent('cdn-fuel:stations:client:changefuelprice', function(data)
CanOpen = false
local location = data.location
QBCore.Functions.TriggerCallback('cdn-fuel:server:isowner', function(result)
@@ -330,8 +541,8 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
default = '$'.. Comma_Value(StationFuelPrice) .. ' Per Liter',
disabled = true },
{ type = "number", label = 'Enter New Fuel Price Per Liter',
- default = StationFuelPrice,
- min = Config.MinimumFuelPrice,
+ default = StationFuelPrice,
+ min = Config.MinimumFuelPrice,
max = Config.MaxFuelPrice
},
})
@@ -347,7 +558,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_price_too_high"), "error")
else
TriggerServerEvent("cdn-fuel:station:server:updatefuelprice", NewFuelPrice, CurrentLocation)
- end
+ end
end
else
local fuelprice = exports['qb-input']:ShowInput({
@@ -370,7 +581,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_price_too_high"), "error")
else
TriggerServerEvent("cdn-fuel:station:server:updatefuelprice", NewFuelPrice, CurrentLocation)
- end
+ end
end
end
end
@@ -431,7 +642,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
},
{
header = Lang:t("menu_sell_station_header_accept"),
- txt = Lang:t("menu_sell_station_footer_accept")..SalePrice..".",
+ txt = Lang:t("menu_sell_station_footer_accept")..SalePrice..".",
icon = "fas fa-usd",
params = {
event = "cdn-fuel:stations:client:sellstation",
@@ -443,7 +654,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
},
{
header = Lang:t("menu_header_close"),
- txt = Lang:t("menu_sell_station_footer_close"),
+ txt = Lang:t("menu_sell_station_footer_close"),
icon = "fas fa-times-circle",
params = {
event = "qb-menu:closeMenu",
@@ -487,14 +698,14 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if not NewNameName then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500) return end
NewName = NewNameName
if type(NewName) ~= "string" then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error') return end
- if Config.ProfanityList[NewName] then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500)
+ if Config.ProfanityList[NewName] then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500)
-- You can add logs for people that put prohibited words into the name changer if wanted, and here is where you would do it.
- return
+ return
end
if string.len(NewName) > Config.NameChangeMaxChar then QBCore.Functions.Notify(Lang:t("station_name_too_long"), 'error') return end
if string.len(NewName) < Config.NameChangeMinChar then QBCore.Functions.Notify(Lang:t("station_name_too_short"), 'error') return end
Wait(100)
- TriggerServerEvent("cdn-fuel:station:server:updatelocationname", NewName, CurrentLocation)
+ TriggerServerEvent("cdn-fuel:station:server:updatelocationname", NewName, CurrentLocation)
end
else
local NewName = exports['qb-input']:ShowInput({
@@ -512,14 +723,14 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if not NewName.newname then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500) return end
NewName = NewName.newname
if type(NewName) ~= "string" then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error') return end
- if Config.ProfanityList[NewName] then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500)
+ if Config.ProfanityList[NewName] then QBCore.Functions.Notify(Lang:t("station_name_invalid"), 'error', 7500)
-- You can add logs for people that put prohibited words into the name changer if wanted, and here is where you would do it.
- return
+ return
end
if string.len(NewName) > Config.NameChangeMaxChar then QBCore.Functions.Notify(Lang:t("station_name_too_long"), 'error') return end
if string.len(NewName) < Config.NameChangeMinChar then QBCore.Functions.Notify(Lang:t("station_name_too_short"), 'error') return end
Wait(100)
- TriggerServerEvent("cdn-fuel:station:server:updatelocationname", NewName, CurrentLocation)
+ TriggerServerEvent("cdn-fuel:station:server:updatelocationname", NewName, CurrentLocation)
end
end
end
@@ -556,7 +767,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = true, -- puts arrow to the right
event = 'cdn-fuel:stations:client:purchasereserves',
args = {
- location = location,
+ location = location,
},
metadata = {
{label = 'Reserve Stock: ', value = ReserveLevels..Lang:t("menu_manage_reserves_footer_1")..Config.MaxFuelReserves},
@@ -570,7 +781,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:changefuelprice',
args = {
- location = location,
+ location = location,
},
metadata = {
{label = 'Current Fuel Price: ', value = "$"..Comma_Value(StationFuelPrice)..Lang:t("input_alter_fuel_price_header_2")},
@@ -599,7 +810,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:sellstation:menu',
args = {
- location = location,
+ location = location,
},
},
{
@@ -634,7 +845,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
params = {
event = "cdn-fuel:stations:client:purchasereserves",
args = {
- location = location,
+ location = location,
}
},
disabled = ReservesNotBuyable,
@@ -646,7 +857,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
params = {
event = "cdn-fuel:stations:client:changefuelprice",
args = {
- location = location,
+ location = location,
}
},
disabled = CanNotChangeFuelPrice,
@@ -670,18 +881,18 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
},
{
header = Lang:t("menu_sell_station_header_accept"),
- txt = Lang:t("menu_manage_sell_station_footer")..math.percent(Config.GasStationSellPercentage, GasStationCost),
+ txt = Lang:t("menu_manage_sell_station_footer")..math.percent(Config.GasStationSellPercentage, GasStationCost),
icon = "fas fa-usd",
params = {
event = "cdn-fuel:stations:client:sellstation:menu",
args = {
- location = location,
+ location = location,
}
},
},
{
header = Lang:t("menu_header_close"),
- txt = Lang:t("menu_manage_close"),
+ txt = Lang:t("menu_manage_close"),
icon = "fas fa-times-circle",
params = {
event = "qb-menu:closeMenu",
@@ -721,7 +932,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:WithdrawFunds',
args = {
- location = location,
+ location = location,
}
},
{
@@ -731,7 +942,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:DepositFunds',
args = {
- location = location,
+ location = location,
}
},
{
@@ -741,7 +952,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:managemenu',
args = {
- location = location,
+ location = location,
}
},
{
@@ -770,7 +981,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
params = {
event = "cdn-fuel:stations:client:WithdrawFunds",
args = {
- location = location,
+ location = location,
}
},
},
@@ -781,18 +992,18 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
params = {
event = "cdn-fuel:stations:client:DepositFunds",
args = {
- location = location,
+ location = location,
}
},
},
{
header = Lang:t("menu_manage_company_funds_return_header"),
- txt = Lang:t("menu_manage_company_funds_return_footer"),
+ txt = Lang:t("menu_manage_company_funds_return_footer"),
icon = "fas fa-circle-left",
params = {
event = "cdn-fuel:stations:client:managemenu",
args = {
- location = location,
+ location = location,
}
},
},
@@ -843,7 +1054,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_withdraw_too_much"), 'error', 7500)
else
TriggerServerEvent('cdn-fuel:station:server:Withdraw', amount, location, StationBalance)
- end
+ end
end
else
local Withdraw = exports['qb-input']:ShowInput({
@@ -868,7 +1079,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_withdraw_too_much"), 'error', 7500)
else
TriggerServerEvent('cdn-fuel:station:server:Withdraw', amount, location, StationBalance)
- end
+ end
end
end
end
@@ -916,7 +1127,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_deposity_too_much"), "error")
else
TriggerServerEvent('cdn-fuel:station:server:Deposit', amount, location, StationBalance)
- end
+ end
end
else
local Deposit = exports['qb-input']:ShowInput({
@@ -940,7 +1151,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
QBCore.Functions.Notify(Lang:t("station_deposity_too_much"), "error")
else
TriggerServerEvent('cdn-fuel:station:server:Deposit', amount, location, StationBalance)
- end
+ end
end
end
end
@@ -964,7 +1175,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
PlayerOwnsAStation = false
end
end)
-
+
Wait(Config.WaitTime)
if PlayerOwnsAStation == true then
@@ -990,7 +1201,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
arrow = true, -- puts arrow to the right
event = 'cdn-fuel:stations:client:purchaselocation',
args = {
- location = location,
+ location = location,
},
metadata = {
{label = 'Station Cost: $', value = Comma_Value(costofstation)..Lang:t("menu_purchase_station_header_2")},
@@ -1028,13 +1239,13 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
params = {
event = "cdn-fuel:stations:client:purchaselocation",
args = {
- location = location,
+ location = location,
}
}
},
{
header = Lang:t("menu_header_close"),
- txt = Lang:t("menu_purchase_station_cancel_footer"),
+ txt = Lang:t("menu_purchase_station_cancel_footer"),
icon = "fas fa-times-circle",
params = {
event = "qb-menu:closeMenu",
@@ -1098,7 +1309,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
{
title = Lang:t("menu_ped_manage_location_header"),
description = Lang:t("menu_ped_manage_location_footer"),
- icon = "fas fa-gas-pump",
+ icon = "fas fa-gas-pump",
arrow = false, -- puts arrow to the right
event = 'cdn-fuel:stations:client:managemenu',
args = CurrentLocation,
@@ -1139,7 +1350,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
{
header = Config.GasStations[CurrentLocation].label,
isMenuHeader = true,
- icon = "fas fa-gas-pump",
+ icon = "fas fa-gas-pump",
},
{
header = Lang:t("menu_ped_manage_location_header"),
diff --git a/server/station_sv.lua b/server/station_sv.lua
index 746c1c1..17c16ec 100644
--- a/server/station_sv.lua
+++ b/server/station_sv.lua
@@ -2,7 +2,8 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
-- Variables
local QBCore = exports[Config.Core]:GetCoreObject()
-
+ local FuelPickupSent = {} -- This is in case of an issue with vehicles not spawning when picking up vehicles.
+
-- Functions
local function GlobalTax(value)
local tax = (value / 100 * Config.GlobalTax)
@@ -58,7 +59,6 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if Player.Functions.RemoveMoney("bank", CostOfStation, Lang:t("station_purchased_location_payment_label")..Config.GasStations[location].label) then
MySQL.Async.execute('UPDATE fuel_stations SET owned = ? WHERE `location` = ?', {1, location})
MySQL.Async.execute('UPDATE fuel_stations SET owner = ? WHERE `location` = ?', {CitizenID, location})
- if Config.NPWD then TriggerClientEvent('cdn-fuel:client:buysellStationNPWDNotif', src, "buy", comma_value(CostOfStation), Config.GasStations[location].label) end
end
end)
@@ -71,7 +71,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
MySQL.Async.execute('UPDATE fuel_stations SET owned = ? WHERE `location` = ?', {0, location})
MySQL.Async.execute('UPDATE fuel_stations SET owner = ? WHERE `location` = ?', {0, location})
TriggerClientEvent('QBCore:Notify', src, Lang:t("station_sold_success"), 'success')
- if Config.NPWD then TriggerClientEvent('cdn-fuel:client:buysellStationNPWDNotif', src, "sell", comma_value(SalePrice), Config.GasStations[location].label) end
+
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("station_cannot_sell"), 'error')
end
@@ -86,7 +86,6 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
MySQL.Async.execute('UPDATE fuel_stations SET balance = ? WHERE `location` = ?', {setamount, location})
Player.Functions.AddMoney("bank", amount, Lang:t("station_withdraw_payment_label")..Config.GasStations[location].label)
TriggerClientEvent('QBCore:Notify', src, Lang:t("station_success_withdrew_1")..amount..Lang:t("station_success_withdrew_2"), 'success')
- if Config.NPWD then TriggerClientEvent('cdn-fuel:client:StationTransfersNPWDNotif', src, "deposit", comma_value(setamount), Config.GasStations[location].label) end
end)
RegisterNetEvent('cdn-fuel:station:server:Deposit', function(amount, location, StationBalance)
@@ -97,7 +96,6 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if Player.Functions.RemoveMoney("bank", amount, Lang:t("station_deposit_payment_label")..Config.GasStations[location].label) then
MySQL.Async.execute('UPDATE fuel_stations SET balance = ? WHERE `location` = ?', {setamount, location})
TriggerClientEvent('QBCore:Notify', src, Lang:t("station_success_deposit_1")..amount..Lang:t("station_success_deposit_2"), 'success')
- if Config.NPWD then TriggerClientEvent('cdn-fuel:client:StationTransfersNPWDNotif', src, "deposit", comma_value(setamount), Config.GasStations[location].label) end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("station_cannot_afford_deposit")..amount.."!", 'success')
end
@@ -149,9 +147,10 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if Config.FuelDebug then print('Successfully executed the previous SQL Update!') end
end)
+
RegisterNetEvent('cdn-fuel:stations:server:buyreserves', function(location, price, amount)
local location = location
- local price = price
+ local price = math.ceil(price)
local amount = amount
local src = source
local Player = QBCore.Functions.GetPlayer(src)
@@ -179,13 +178,64 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
end
if Config.FuelDebug then print("Attempting Sale Server Side for location: #"..location.." for Price: $"..price) end
if ReserveBuyPossible and Player.Functions.RemoveMoney("bank", price, "Purchased"..amount.."L of Reserves for: "..Config.GasStations[location].label.." @ $"..Config.FuelReservesPrice.." / L!") then
- MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {NewAmount, location})
- if Config.FuelDebug then print("SQL Execute Update: fuel_station level to: "..NewAmount.. " Math: ("..amount.." + "..OldAmount.." = "..NewAmount) end
+ if not Config.OwnersPickupFuel then
+ MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {NewAmount, location})
+ if Config.FuelDebug then print("SQL Execute Update: fuel_station level to: "..NewAmount.. " Math: ("..amount.." + "..OldAmount.." = "..NewAmount) end
+ else
+ FuelPickupSent[location] = {
+ ['src'] = src,
+ ['refuelAmount'] = NewAmount,
+ ['amountBought'] = amount,
+ }
+ TriggerClientEvent('cdn-fuel:station:client:initiatefuelpickup', src, amount, NewAmount, location)
+ if Config.FuelDebug then print("Initiating a Fuel Pickup for Location: "..location.." with for the amount of "..NewAmount.." | Triggered By: Source: "..src) end
+ end
+
elseif ReserveBuyPossible then
TriggerClientEvent('QBCore:Notify', src, Lang:t("not_enough_money"), 'error')
end
end)
+ RegisterNetEvent('cdn-fuel:station:server:fuelpickup:failed', function(location)
+ local src = source
+ if location then
+ if FuelPickupSent[location] then
+ local cid = QBCore.Functions.GetPlayer(src).PlayerData.citizenid
+ MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {FuelPickupSent[location]['refuelAmount'], location})
+ TriggerClientEvent('QBCore:Notify', src, "Ron Oil has just dropped off the fuel to your station!", 'success')
+ -- This will print player information just in case someone figures out a way to exploit this.
+ print("User encountered an error with fuel pickup, so we are updating the fuel level anyways, and cancelling the pickup. SQL Execute Update: fuel_station level to: "..FuelPickupSent[location].refuelAmount.. " | Source: "..src.." | Citizen Id: "..cid..".")
+ FuelPickupSent[location] = nil
+ else
+ if Config.FuelDebug then
+ print("`cdn-fuel:station:server:fuelpickup:failed` | FuelPickupSent[location] is not valid! Location: "..location)
+ end
+ -- They are probably exploiting in some way/shape/form.
+ end
+ end
+ end)
+
+ RegisterNetEvent('cdn-fuel:station:server:fuelpickup:finished', function(location)
+ local src = source
+ if location then
+ if FuelPickupSent[location] then
+ local cid = QBCore.Functions.GetPlayer(src).PlayerData.citizenid
+ MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {FuelPickupSent[location].refuelAmount, location})
+ TriggerClientEvent('QBCore:Notify', src, 'Your reserves have been filled to: '..tostring(tonumber(FuelPickupSent[location].refuelAmount)).."L", 'success')
+ -- This will print player information just in case someone figures out a way to exploit this.
+ if Config.FuelDebug then
+ print("User successfully dropped off fuel truck, so we are updating the fuel level and clearing the pickup table. SQL Execute Update: fuel_station level to: "..FuelPickupSent[location].refuelAmount.. " | Source: "..src.." | Citizen Id: "..cid..".")
+ end
+ FuelPickupSent[location] = nil
+ else
+ if Config.FuelDebug then
+ print("FuelPickupSent[location] is not valid! Location: "..location)
+ end
+ -- They are probably exploiting in some way/shape/form.
+ end
+ end
+ end)
+
RegisterNetEvent('cdn-fuel:station:server:updatelocationname', function(newName, location)
local src = source
if Config.FuelDebug then print('Attempting to set name for Location #'..location..' to: '..newName) end
From 61064f76b933e37f9014eb30f771686f16c15a41 Mon Sep 17 00:00:00 2001
From: dnelyk <95599217+dnelyk@users.noreply.github.com>
Date: Fri, 26 May 2023 18:26:08 -0700
Subject: [PATCH 4/5] feat(Locales, Version Updated)
Also, lined out Config.AirAndWaterVehicleFueling[19] due to a confliction issue with Gabz's Trooper PD.
---
client/station_cl.lua | 8 ++--
locales/de.lua | 7 ++++
locales/ee.lua | 7 ++++
locales/en.lua | 7 ++++
locales/es.lua | 9 ++++-
locales/fr.lua | 7 ++++
server/station_sv.lua | 4 +-
shared/config.lua | 93 +++++++++++++++++++++++++++----------------
version | 2 +-
9 files changed, 102 insertions(+), 42 deletions(-)
diff --git a/client/station_cl.lua b/client/station_cl.lua
index 012822c..0110b92 100644
--- a/client/station_cl.lua
+++ b/client/station_cl.lua
@@ -134,7 +134,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
}
if SpawnPickupVehicles() then
- QBCore.Functions.Notify('Your fuel order is available for pickup! Take a look at your GPS to find the pickup!', 'success')
+ QBCore.Functions.Notify(Lang:t("fuel_order_ready"), 'success')
SetNewWaypoint(Config.DeliveryTruckSpawns['truck'].x, Config.DeliveryTruckSpawns['truck'].y)
SetUseWaypointAsDestination(true)
ReservePickupData.blip = CreateBlip(vector3(Config.DeliveryTruckSpawns['truck'].x, Config.DeliveryTruckSpawns['truck'].y, Config.DeliveryTruckSpawns['truck'].z), "Truck Pickup")
@@ -197,7 +197,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if distBetweenTruckAndTrailer > 10.0 then
distBetweenTruckAndTrailer = nil
if not stopNotifyTemp then
- QBCore.Functions.Notify('The trailer is not attached to the truck or is too far!', 'error', 7500)
+ QBCore.Functions.Notify(Lang:t("trailer_too_far"), 'error', 7500)
end
stopNotifyTemp = true
Wait(1000)
@@ -260,11 +260,11 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
else
hasArrivedAtLocation = true
if Config.Ox.DrawText then
- lib.showTextUI("[E] Drop Off Truck", {
+ lib.showTextUI(Lang:t("draw_text_fuel_dropoff"), {
position = 'left-center'
})
else
- exports[Config.Core]:DrawText("[E] Drop Off Truck", 'left')
+ exports[Config.Core]:DrawText(Lang:t("draw_text_fuel_dropoff"), 'left')
end
-- Add Listner for Keypress
AwaitInput()
diff --git a/locales/de.lua b/locales/de.lua
index a748a7b..988e43d 100644
--- a/locales/de.lua
+++ b/locales/de.lua
@@ -19,6 +19,13 @@ local Translations = {
cannot_refuel_inside = "Sie können nicht aus dem Fahrzeuginneren tanken!",
vehicle_is_damaged = "Das Fahrzeug ist zu beschädigt zum Tanken!",
+ -- 2.1.2 -- Reservenabholung ---
+ fuel_order_ready = "Ihre Kraftstoffbestellung ist abholbereit! Schauen Sie auf Ihrem GPS nach, um die Abholstelle zu finden!",
+ draw_text_fuel_dropoff = "[E] LKW abstellen",
+ fuel_pickup_success = "Ihre Reserven wurden aufgefüllt: %sL",
+ fuel_pickup_failed = "Ron Oil hat gerade den Kraftstoff an Ihre Tankstelle geliefert!",
+ trailer_too_far = "Der Anhänger ist nicht mit dem LKW verbunden oder zu weit entfernt!",
+
-- 2.1.0
no_nozzle = "Sie haben keine Zapfpistole!",
vehicle_too_far = "Sie sind zu weit entfernt, um dieses Fahrzeug zu betanken!",
diff --git a/locales/ee.lua b/locales/ee.lua
index 42bb506..ea16d70 100644
--- a/locales/ee.lua
+++ b/locales/ee.lua
@@ -16,6 +16,13 @@ local Translations = {
need_electric_charger = "Elektri auto jaoks, peaksid sa minema laadimispunkti!",
cannot_refuel_inside = "Sa ei saa tankida sõidukit, kui ise seal sees istud!",
+ -- 2.1.2 -- Reservi kogumine ---
+ fuel_order_ready = "Teie kütuse tellimus on saadaval kogumiseks! Vaadake oma GPS-i, et leida kogumiskoht!",
+ draw_text_fuel_dropoff = "[E] Jäta veok maha",
+ fuel_pickup_success = "Teie reservuaarid on täidetud: %sL",
+ fuel_pickup_failed = "Ron Oil on just teie jaama kütust maha toimetanud!",
+ trailer_too_far = "Haagis pole veokiga ühendatud või on liiga kaugel!",
+
-- 2.1.0
no_nozzle = "Sul ei ole kütuse otsikut!",
vehicle_is_damaged = "Sõiduk on liiga katki, et seda tankida!",
diff --git a/locales/en.lua b/locales/en.lua
index bea5527..f9464ec 100644
--- a/locales/en.lua
+++ b/locales/en.lua
@@ -16,6 +16,13 @@ local Translations = {
need_electric_charger = "I need to go to an electric charger!",
cannot_refuel_inside = "You cannot refuel from inside of the vehicle!",
+ -- 2.1.2 -- Reserves Pickup ---
+ fuel_order_ready = "Your fuel order is available for pickup! Take a look at your GPS to find the pickup!",
+ draw_text_fuel_dropoff = "[E] Drop Off Truck",
+ fuel_pickup_success = "Your reserves have been filled to: %sL",
+ fuel_pickup_failed = "Ron Oil has just dropped off the fuel to your station!",
+ trailer_too_far = "The trailer is not attached to the truck or is too far!",
+
-- 2.1.0
no_nozzle = "You do not have the nozzle!",
vehicle_is_damaged = "Vehicle is too damaged to refuel!",
diff --git a/locales/es.lua b/locales/es.lua
index 5f70c02..1d52192 100644
--- a/locales/es.lua
+++ b/locales/es.lua
@@ -16,13 +16,20 @@ local Translations = {
cannot_refuel_inside = "No puedes repostar desde el interior del Vehiculo!",
vehicle_is_damaged = "El vehiculo está demasiado dañado para repostarlo!",
+ -- 2.1.2 -- Recogida de reservas ---
+ fuel_order_ready = "¡Tu pedido de combustible está disponible para recoger! ¡Consulta tu GPS para encontrar el lugar de recogida!",
+ draw_text_fuel_dropoff = "[E] Dejar camión",
+ fuel_pickup_success = "Tus reservas se han llenado con: %sL",
+ fuel_pickup_failed = "¡Ron Oil acaba de entregar el combustible a tu estación!",
+ trailer_too_far = "¡El remolque no está enganchado al camión o está demasiado lejos!",
+
-- 2.1.0
no_nozzle = "¡No tienes la boquilla!",
vehicle_too_far = "¡Estás demasiado lejos para repostar este vehículo!",
inside_vehicle = "¡No puedes repostar desde el interior del vehículo!",
you_are_discount_eligible = "Si entras en servicio, podrías recibir un descuento del "..Config.EmergencyServicesDiscount['discount'].."%!",
no_fuel = "Sin combustible..",
-
+
-- Electric
electric_more_than_zero = "Debes cargar mas de 0KW!",
electric_vehicle_not_electric = "Tu vehiculo no es Eléctrico!",
diff --git a/locales/fr.lua b/locales/fr.lua
index 5c9d1c1..91cbca8 100644
--- a/locales/fr.lua
+++ b/locales/fr.lua
@@ -19,6 +19,13 @@ local Translations = {
cannot_refuel_inside = "Vous ne pouvez pas faire le plein depuis l'intérieur du véhicule!",
vehicle_is_damaged = "Le véhicule est trop endommagé pour faire le plein!",
+ -- 2.1.2 -- Récupération des réserves ---
+ fuel_order_ready = "Votre commande de carburant est disponible pour récupération ! Consultez votre GPS pour trouver l'endroit de récupération !",
+ draw_text_fuel_dropoff = "[E] Déposer le camion",
+ fuel_pickup_success = "Vos réserves ont été remplies à hauteur de : %sL",
+ fuel_pickup_failed = "Ron Oil vient de livrer le carburant à votre station !",
+ trailer_too_far = "La remorque n'est pas attachée au camion ou est trop éloignée !",
+
-- 2.1.0
no_nozzle = "Vous n'avez pas de buse !",
vehicle_too_far = "Vous êtes trop loin pour ravitailler ce véhicule !",
diff --git a/server/station_sv.lua b/server/station_sv.lua
index 17c16ec..c7955a3 100644
--- a/server/station_sv.lua
+++ b/server/station_sv.lua
@@ -202,7 +202,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if FuelPickupSent[location] then
local cid = QBCore.Functions.GetPlayer(src).PlayerData.citizenid
MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {FuelPickupSent[location]['refuelAmount'], location})
- TriggerClientEvent('QBCore:Notify', src, "Ron Oil has just dropped off the fuel to your station!", 'success')
+ TriggerClientEvent('QBCore:Notify', src, Lang:t("fuel_pickup_failed"), 'success')
-- This will print player information just in case someone figures out a way to exploit this.
print("User encountered an error with fuel pickup, so we are updating the fuel level anyways, and cancelling the pickup. SQL Execute Update: fuel_station level to: "..FuelPickupSent[location].refuelAmount.. " | Source: "..src.." | Citizen Id: "..cid..".")
FuelPickupSent[location] = nil
@@ -221,7 +221,7 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
if FuelPickupSent[location] then
local cid = QBCore.Functions.GetPlayer(src).PlayerData.citizenid
MySQL.Async.execute('UPDATE fuel_stations SET fuel = ? WHERE `location` = ?', {FuelPickupSent[location].refuelAmount, location})
- TriggerClientEvent('QBCore:Notify', src, 'Your reserves have been filled to: '..tostring(tonumber(FuelPickupSent[location].refuelAmount)).."L", 'success')
+ TriggerClientEvent('QBCore:Notify', src, string.format(Lang:t("fuel_pickup_success"), tostring(tonumber(FuelPickupSent[location].refuelAmount))), 'success')
-- This will print player information just in case someone figures out a way to exploit this.
if Config.FuelDebug then
print("User successfully dropped off fuel truck, so we are updating the fuel level and clearing the pickup table. SQL Execute Update: fuel_station level to: "..FuelPickupSent[location].refuelAmount.. " | Source: "..src.." | Citizen Id: "..cid..".")
diff --git a/shared/config.lua b/shared/config.lua
index a1bea4f..86029c1 100644
--- a/shared/config.lua
+++ b/shared/config.lua
@@ -2,7 +2,7 @@ Config = {}
Config.FuelDebug = false -- Used for debugging, although there are not many areas in yet (Default: false) + Enables Setfuel Commands (0, 50, 100).
Config.PolyDebug = false -- Enables Polyzone Debugging to see PolyZones!
Config.ShowNearestGasStationOnly = true -- When enabled, only the nearest gas stations will be shown on the map.
-Config.LeaveEngineRunning = true -- When true, the vehicle's engine will be left running upon exit if the player *HOLDS* F.
+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.CostMultiplier = 3 -- Amount to multiply 1 by. This indicates fuel price. (Default: $3.0/l or 3.0)
@@ -12,11 +12,35 @@ Config.FuelDecor = "_FUEL_LEVEL" -- Do not touch! (Default: "_FUEL_LEVEL")
Config.RefuelTime = 600 -- Highly recommended to leave at 600. This value will be multiplied times the amount the player is fueling for the progress bar and cancellation logic! DON'T GO BELOW 250, performance WILL drop!
Config.FuelTargetExport = false -- DO NOT USE WITH OX_TARGET! This is only used to fix this qb-target issue: https://github.com/CodineDev/cdn-fuel/issues/3.
If you don't have this issue and haven't installed this exports in qb-target, then this should be false. Otherwise there will be an error.
+-- 2.1.1 Update --
+Config.OwnersPickupFuel = false -- If an owner buys fuel, they will have to go pick it up at a configured location.
+Config.PossibleDeliveryTrucks = {
+ "hauler",
+ "phantom",
+ -- "phantom3", -- This is an fast version of the normal phantom.
+ "packer",
+}
+Config.DeliveryTruckSpawns = { -- https://i.imgur.com/VS22i8R.jpeg
+ ['trailer'] = vector4(1724.0, -1649.7, 112.57, 194.24),
+ ['truck'] = vector4(1727.08, -1664.01, 112.62, 189.62),
+ ['PolyZone'] = {
+ ['coords'] = {
+ vector2(1724.62, -1672.36),
+ vector2(1719.01, -1648.33),
+ vector2(1730.99, -1645.62),
+ vector2(1734.42, -1673.32),
+ },
+ ['minz'] = 110.0,
+ ['maxz'] = 115.0,
+ }
+}
+-- 2.1.1 End
+
-- 2.1.0 Update
Config.EmergencyServicesDiscount = {
['enabled'] = true, -- Enables Emergency Services Getting a discount based on the value below for Refueling & Electricity Charging Cost
['discount'] = 25, -- % Discount off of price.
- ['emergency_vehicles_only'] = false, -- Only allows discounts to be applied to Emergency Vehicles
+ ['emergency_vehicles_only'] = true, -- Only allows discounts to be applied to Emergency Vehicles
['ondutyonly'] = true, -- Discount only applies while on duty.
['job'] = {
"police",
@@ -34,7 +58,7 @@ Config.Ox = {
Progress = false -- Uses Ox ProgressBar instead of progressbar.
}
Config.TargetResource = "qb-target" -- Supported: { 'qb-target', 'ox_target'} -- Others must use the same format as QB-Target or manual configuration is required.
-Config.PumpHose = true -- If true, it creates a hose from the pump to the nozzle the client is holding, to give it a more realistic feel.
+Config.PumpHose = false -- If true, it creates a hose from the pump to the nozzle the client is holding, to give it a more realistic feel.
Config.RopeType = { -- Options: 1-2-3-4-5; 1: Khaki Color, Kind of Thick, 2: Very Thick Khaki Rope, 3: Very Thick Black Rope, 4: Very Thin Black Rope, 5: Same as 3
['fuel'] = 1,
['electric'] = 1,
@@ -686,37 +710,38 @@ Config.AirAndWaterVehicleFueling = {
}
},
-- La Mesa Landing Pad (Custom)
- [19] = {
- ['PolyZone'] = {
- ['coords'] = {
- vector2(830.66, -1378.54),
- vector2(834.87, -1382.59),
- vector2(834.81, -1388.5),
- vector2(830.75, -1392.54),
- vector2(824.96, -1392.58),
- vector2(820.8, -1388.39),
- vector2(820.84, -1382.65),
- vector2(824.97, -1378.52)
- },
- ['minmax'] = {
- ['min'] = 35.67,
- ['max'] = 38.67
- },
- },
- ['draw_text'] = "[G] Refuel Aircraft",
- ['type'] = 'air',
- ['whitelist'] = {
- ['enabled'] = false,
- ['on_duty_only'] = true,
- ['whitelisted_jobs'] = {
- 'police', 'ambulance',
- }
- },
- ['prop'] = {
- ['model'] = 'prop_gas_pump_1c',
- ['coords'] = vector4(827.55, -1378.57, 36.67, 1.11)
- }
- }
+ -- Does not work in conjunction with Gabz Trooper PD.
+ -- [19] = {
+ -- ['PolyZone'] = {
+ -- ['coords'] = {
+ -- vector2(830.66, -1378.54),
+ -- vector2(834.87, -1382.59),
+ -- vector2(834.81, -1388.5),
+ -- vector2(830.75, -1392.54),
+ -- vector2(824.96, -1392.58),
+ -- vector2(820.8, -1388.39),
+ -- vector2(820.84, -1382.65),
+ -- vector2(824.97, -1378.52)
+ -- },
+ -- ['minmax'] = {
+ -- ['min'] = 35.67,
+ -- ['max'] = 38.67
+ -- },
+ -- },
+ -- ['draw_text'] = "[G] Refuel Aircraft",
+ -- ['type'] = 'air',
+ -- ['whitelist'] = {
+ -- ['enabled'] = false,
+ -- ['on_duty_only'] = true,
+ -- ['whitelisted_jobs'] = {
+ -- 'police', 'ambulance',
+ -- }
+ -- },
+ -- ['prop'] = {
+ -- ['model'] = 'prop_gas_pump_1c',
+ -- ['coords'] = vector4(827.55, -1378.57, 36.67, 1.11)
+ -- }
+ -- }
},
['refuel_button'] = 47, -- "G" Button for Draw Text.
['nozzle_length'] = 20.0, -- The max distance you can go from the "Special Pump" before the nozzle in returned to the pump.
diff --git a/version b/version
index 7c32728..8f9174b 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-2.1.1
\ No newline at end of file
+2.1.2
\ No newline at end of file
From 2fa2c5f77687fd43de8942e70838ed08591cce1d Mon Sep 17 00:00:00 2001
From: dnelyk <95599217+dnelyk@users.noreply.github.com>
Date: Fri, 26 May 2023 18:27:33 -0700
Subject: [PATCH 5/5] Update fxmanifest.lua
---
fxmanifest.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fxmanifest.lua b/fxmanifest.lua
index 47a4048..1f6497b 100644
--- a/fxmanifest.lua
+++ b/fxmanifest.lua
@@ -2,7 +2,7 @@ fx_version 'cerulean'
game 'gta5'
author 'https://www.github.com/CodineDev' -- Base Refueling System: (https://github.com/InZidiuZ/LegacyFuel), other code by Codine (https://www.github.com/CodineDev).
description 'cdn-fuel'
-version '2.1.1'
+version '2.1.2'
client_scripts {
'@PolyZone/client.lua',