Skip to content

Commit

Permalink
2.1.5 | feat(Various Bug Fixes)
Browse files Browse the repository at this point in the history
More information is available on the release page (https://github.com/CodineDev/cdn-fuel/releases/tag/2.1.5).

Thank you.
  • Loading branch information
dnelyk committed Aug 11, 2023
1 parent 8dad29b commit b9b1a70
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 18 deletions.
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
![Codine Development Fuel Script Banner](https://i.imgur.com/qVOMMvW.png)

# _CDN-Fuel (2.1.4)_
# _CDN-Fuel (2.1.5)_

A highly in-depth fuel system for **FiveM** with support for the **QBCore Framework & QBox Remastered**.

# _Lastest Patch Information_
*Additions:*
- Various Optimizations Throughout
- Config Option for Having Owners Pickup Reserves they Purchase

*Fixes:*
- 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.
- Jerry Cans not refuelling at pump.
- Removed spamming debug print.
- Changed the way Air Fuel Zones spawn PolyZones and Props.
- Player Job Error on load.
- Syphoning Issue with QB-Inventory.


<br>
<br>
Expand Down
190 changes: 187 additions & 3 deletions client/fuel_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if Config.FuelDebug then
QBCore.Functions.Notify(Lang:t("set_fuel_debug")..' '..args[1]..'L', 'success')
end, false)

RegisterCommand('getCachedFuelPrice', function ()
RegisterCommand('getCachedFuelPrice', function()
print(CachedFuelPrice)
end, false)

Expand Down Expand Up @@ -1702,6 +1702,7 @@ RegisterNetEvent('cdn-fuel:jerrycan:refueljerrycan', function(data)
QBCore.Functions.Notify(Lang:t("jerry_can_success"), 'success')
local jerryCanData = data.itemData
local srcPlayerData = QBCore.Functions.GetPlayerData()
local refuelAmount = tonumber(refuel.amount)
if Config.Ox.Inventory then
TriggerServerEvent('cdn-fuel:info', "add", tonumber(refuelAmount), srcPlayerData, 'jerrycan')
else
Expand Down Expand Up @@ -2227,7 +2228,173 @@ end)
local AirSeaFuelZones = {}
local vehicle = nil
-- Create Polyzones with In-Out functions for handling fueling --
CreateThread(function()

AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
if LocalPlayer.state['isLoggedIn'] then
for i = 1, #Config.AirAndWaterVehicleFueling['locations'], 1 do
local currentLocation = Config.AirAndWaterVehicleFueling['locations'][i]
local k = #AirSeaFuelZones+1
local GeneratedName = "air_sea_fuel_zone_"..k

AirSeaFuelZones[k] = {} -- Make a new table inside of the Vehicle Pullout Zones representing this zone.

-- Get Coords for Zone from Config.
AirSeaFuelZones[k].zoneCoords = currentLocation['PolyZone']['coords']

-- Grab MinZ & MaxZ from Config.
local minimumZ, maximumZ = currentLocation['PolyZone']['minmax']['min'], currentLocation['PolyZone']['minmax']['max']

-- Create Zone
AirSeaFuelZones[k].PolyZone = PolyZone:Create(AirSeaFuelZones[k].zoneCoords, {
name = GeneratedName,
minZ = minimumZ,
maxZ = maximumZ,
debugPoly = Config.PolyDebug
})

AirSeaFuelZones[k].name = GeneratedName

-- Setup onPlayerInOut Events for zone that is created.
AirSeaFuelZones[k].PolyZone:onPlayerInOut(function(isPointInside)
if isPointInside then
local canUseThisStation = false
if Config.AirAndWaterVehicleFueling['locations'][i]['whitelist']['enabled'] then
local whitelisted_jobs = Config.AirAndWaterVehicleFueling['locations'][i]['whitelist']['whitelisted_jobs']
local plyJob = QBCore.Functions.GetPlayerData().job

if Config.FuelDebug then
print("Player Job: "..plyJob.name.." Is on Duty?: "..json.encode(plyJob.onduty))
end

if type(whitelisted_jobs) == "table" then
for i = 1, #whitelisted_jobs, 1 do
if plyJob.name == whitelisted_jobs[i] then
if Config.AirAndWaterVehicleFueling['locations'][i]['whitelist']['on_duty_only'] then
if plyJob.onduty == true then
canUseThisStation = true
else
canUseThisStation = false
end
else
canUseThisStation = true
end
end
end
end
else
canUseThisStation = true
end

if canUseThisStation then
-- Inside
PlayerInSpecialFuelZone = true
inGasStation = true
RefuelingType = 'special'

local DrawText = Config.AirAndWaterVehicleFueling['locations'][i]['draw_text']

if Config.Ox.DrawText then
lib.showTextUI(DrawText, {
position = 'left-center'
})
else
exports[Config.Core]:DrawText(DrawText, 'left')
end

CreateThread(function()
while PlayerInSpecialFuelZone do
Wait(3000)
vehicle = GetClosestVehicle()
end
end)

CreateThread(function()
while PlayerInSpecialFuelZone do
Wait(0)
if PlayerInSpecialFuelZone ~= true then
break
end
if IsControlJustReleased(0, Config.AirAndWaterVehicleFueling['refuel_button']) --[[ Control in Config ]] then
local vehCoords = GetEntityCoords(vehicle)
local dist = #(GetEntityCoords(PlayerPedId()) - vehCoords)

if not HoldingSpecialNozzle then
QBCore.Functions.Notify(Lang:t("no_nozzle"), 'error', 1250)
elseif dist > 4.5 then
QBCore.Functions.Notify(Lang:t("vehicle_too_far"), 'error', 1250)
elseif IsPedInAnyVehicle(PlayerPedId(), true) then
QBCore.Functions.Notify(Lang:t("inside_vehicle"), 'error', 1250)
else
if Config.FuelDebug then print("Attempting to Open Fuel menu for special vehicles.") end
TriggerEvent('cdn-fuel:client:RefuelMenu', 'special')
end
end
end
end)

if Config.FuelDebug then
print('Player has entered the Heli or Plane Refuel Zone: ('..GeneratedName..')')
end
end
else
if HoldingSpecialNozzle then
QBCore.Functions.Notify(Lang:t("nozzle_cannot_reach"), 'error')
HoldingSpecialNozzle = false
if Config.PumpHose then
if Config.FuelDebug then
print("Deleting Rope: "..Rope)
end
RopeUnloadTextures()
DeleteObject(Rope)
end
DeleteObject(SpecialFuelNozzleObj)
end
if Config.PumpHose then
if Rope ~= nil then
if Config.FuelDebug then
print("Deleting Rope: "..Rope)
end
RopeUnloadTextures()
DeleteObject(Rope)
end
end
-- Outside
if Config.Ox.DrawText then
lib.hideTextUI()
else
exports[Config.Core]:HideText()
end
PlayerInSpecialFuelZone = false
inGasStation = false
RefuelingType = nil
if Config.FuelDebug then
print('Player has exited the Heli or Plane Refuel Zone: ('..GeneratedName..')')
end
end
end)

if currentLocation['prop'] then
local model = currentLocation['prop']['model']
local modelCoords = currentLocation['prop']['coords']
local heading = modelCoords[4] - 180.0
AirSeaFuelZones[k].prop = CreateObject(model, modelCoords.x, modelCoords.y, modelCoords.z, false, true, true)
if Config.FuelDebug then print("Created Special Pump from Location #"..i) end
SetEntityHeading(AirSeaFuelZones[k].prop, heading)
FreezeEntityPosition(AirSeaFuelZones[k].prop, 1)
else
if Config.FuelDebug then print("Location #"..i.." for Special Fueling Zones (Air and Sea) doesn't have a prop set up, so players cannot fuel here.") end
end

if Config.FuelDebug then
print("Created Location: "..GeneratedName)
end
end
end
end
end)

AddEventHandler("QBCore:Client:OnPlayerLoaded", function ()
for i = 1, #Config.AirAndWaterVehicleFueling['locations'], 1 do
local currentLocation = Config.AirAndWaterVehicleFueling['locations'][i]
local k = #AirSeaFuelZones+1
Expand All @@ -2249,6 +2416,8 @@ CreateThread(function()
debugPoly = Config.PolyDebug
})

AirSeaFuelZones[k].name = GeneratedName

-- Setup onPlayerInOut Events for zone that is created.
AirSeaFuelZones[k].PolyZone:onPlayerInOut(function(isPointInside)
if isPointInside then
Expand Down Expand Up @@ -2386,11 +2555,26 @@ CreateThread(function()
end
end)

AddEventHandler("QBCore:Client:OnPlayerUnload", function()
for i = 1, #AirSeaFuelZones, 1 do
AirSeaFuelZones[i].PolyZone:destroy()
if Config.FuelDebug then
print("Destroying Air Fuel PolyZone: "..AirSeaFuelZones[i].name)
end
if AirSeaFuelZones[i].prop then
if Config.FuelDebug then
print("Destroying Air Fuel Zone Pump: "..i)
end
DeleteObject(AirSeaFuelZones[i].prop)
end
end
end)

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for i = 1, #AirSeaFuelZones, 1 do
DeleteObject(AirSeaFuelZones[i].prop)
end
end
end
end)

Expand Down
8 changes: 7 additions & 1 deletion server/fuel_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ RegisterNetEvent('cdn-fuel:info', function(type, amount, srcPlayerData, itemdata
end

if type == "add" then
srcPlayerData.items[itemdata.slot].info.gasamount = srcPlayerData.items[itemdata.slot].info.gasamount + amount
if not srcPlayerData.items[itemdata.slot].info.gasamount then
srcPlayerData.items[itemdata.slot].info = {
gasamount = amount,
}
else
srcPlayerData.items[itemdata.slot].info.gasamount = srcPlayerData.items[itemdata.slot].info.gasamount + amount
end
Player.Functions.SetInventory(srcPlayerData.items)
elseif type == "remove" then
srcPlayerData.items[itemdata.slot].info.gasamount = srcPlayerData.items[itemdata.slot].info.gasamount - amount
Expand Down
1 change: 0 additions & 1 deletion server/station_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ if Config.PlayerOwnedGasStationsEnabled then -- This is so Player Owned Gas Stat
local location = 0
for value in ipairs(Config.GasStations) do
location = location + 1

UpdateStationLabel(location)
end
end
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.4
2.1.5

0 comments on commit b9b1a70

Please sign in to comment.