From f57519a7f82e406db4795a4eb5a9c21ef6543075 Mon Sep 17 00:00:00 2001 From: dnelyk <95599217+dnelyk@users.noreply.github.com> Date: Fri, 18 Aug 2023 22:41:02 -0700 Subject: [PATCH] feat(2.1.9 | Fix OX_Target AddTargetModel Error) --- README.md | 2 +- client/electric_cl.lua | 56 +++++++++++++---- client/fuel_cl.lua | 134 +++++++++++++++++++++-------------------- fxmanifest.lua | 2 +- version | 2 +- 5 files changed, 115 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 2f882d8..d244042 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Codine Development Fuel Script Banner](https://i.imgur.com/qVOMMvW.png) -# _CDN-Fuel (2.1.8)_ +# _CDN-Fuel (2.1.9)_ A highly in-depth fuel system for **FiveM** with support for the **QBCore Framework & QBox Remastered**. diff --git a/client/electric_cl.lua b/client/electric_cl.lua index abed2d2..830d513 100644 --- a/client/electric_cl.lua +++ b/client/electric_cl.lua @@ -726,15 +726,43 @@ if Config.ElectricVehicleCharging then end end) - -- Target - local TargetResource = Config.TargetResource - if Config.TargetResource == 'ox_target' then - TargetResource = 'qb-target' - end - - exports[TargetResource]:AddTargetModel('electric_charger', { - options = { - { + -- Target -- + if Config.TargetResource ~= "ox_target" then + -- This assumes your target resource uses the same format as qb-target or has an auto converter. + exports[Config.TargetResource]:AddTargetModel('electric_charger', { + options = { + { + num = 1, + type = "client", + event = "cdn-fuel:client:grabelectricnozzle", + icon = "fas fa-bolt", + label = Lang:t("grab_electric_nozzle"), + canInteract = function() + if not IsHoldingElectricNozzle() and not IsPedInAnyVehicle(PlayerPedId()) then + return true + end + end + }, + { + num = 2, + type = "client", + event = "cdn-fuel:client:returnnozzle", + icon = "fas fa-hand", + label = Lang:t("return_nozzle"), + canInteract = function() + if IsHoldingElectricNozzle() and not refueling then + return true + end + end + }, + }, + distance = 2.0 + }) + else + -- Using OX_Target: + local modelOptions = { + [1] = { + name = "cdn-fuel:modelOptions:electric:option_1", num = 1, type = "client", event = "cdn-fuel:client:grabelectricnozzle", @@ -746,7 +774,8 @@ if Config.ElectricVehicleCharging then end end }, - { + [2] = { + name = "cdn-fuel:modelOptions:electric:option_2", num = 2, type = "client", event = "cdn-fuel:client:returnnozzle", @@ -758,7 +787,8 @@ if Config.ElectricVehicleCharging then end end }, - }, - distance = 2.0 - }) + } + + exports.ox_target:addModel(props, modelOptions) + end end \ No newline at end of file diff --git a/client/fuel_cl.lua b/client/fuel_cl.lua index 0c877e6..aba327b 100644 --- a/client/fuel_cl.lua +++ b/client/fuel_cl.lua @@ -2622,73 +2622,77 @@ CreateThread(function() exports.ox_target:addGlobalVehicle(options) - exports['qb-target']:AddTargetModel(props, { - options = { - { - num = 1, - type = "client", - event = "cdn-fuel:client:grabnozzle", - icon = "fas fa-gas-pump", - label = Lang:t("grab_nozzle"), - canInteract = function() - if PlayerInSpecialFuelZone then return false end - if not IsPedInAnyVehicle(PlayerPedId()) and not holdingnozzle and not HoldingSpecialNozzle and inGasStation == true and not PlayerInSpecialFuelZone then - return true - end - end, - }, - { - num = 2, - type = "client", - event = "cdn-fuel:client:purchasejerrycan", - icon = "fas fa-fire-flame-simple", - label = Lang:t("buy_jerrycan"), - canInteract = function() - if not IsPedInAnyVehicle(PlayerPedId()) and not holdingnozzle and not HoldingSpecialNozzle and inGasStation == true then - return true - end - end, - }, - { - num = 3, - type = "client", - event = "cdn-fuel:client:returnnozzle", - icon = "fas fa-hand", - label = Lang:t("return_nozzle"), - canInteract = function() - if holdingnozzle and not refueling then - return true - end - end, - }, - { - num = 4, - type = "client", - event = "cdn-fuel:client:grabnozzle:special", - icon = "fas fa-gas-pump", - label = Lang:t("grab_special_nozzle"), - canInteract = function() - if Config.FuelDebug then print("Is Player In Special Fuel Zone?: "..tostring(PlayerInSpecialFuelZone)) end - if not HoldingSpecialNozzle and not IsPedInAnyVehicle(PlayerPedId()) and PlayerInSpecialFuelZone then - return true - end - end, - }, - { - num = 5, - type = "client", - event = "cdn-fuel:client:returnnozzle:special", - icon = "fas fa-hand", - label = Lang:t("return_special_nozzle"), - canInteract = function() - if HoldingSpecialNozzle and not IsPedInAnyVehicle(PlayerPedId()) then - return true - end + local modelOptions = { + [1] = { + name = "cdn-fuel:modelOptions:option_1", + num = 1, + type = "client", + event = "cdn-fuel:client:grabnozzle", + icon = "fas fa-gas-pump", + label = Lang:t("grab_nozzle"), + canInteract = function() + if PlayerInSpecialFuelZone then return false end + if not IsPedInAnyVehicle(PlayerPedId()) and not holdingnozzle and not HoldingSpecialNozzle and inGasStation == true and not PlayerInSpecialFuelZone then + return true end - }, + end, }, - distance = 2.0 - }) + [2] = { + name = "cdn-fuel:modelOptions:option_2", + num = 2, + type = "client", + event = "cdn-fuel:client:purchasejerrycan", + icon = "fas fa-fire-flame-simple", + label = Lang:t("buy_jerrycan"), + canInteract = function() + if not IsPedInAnyVehicle(PlayerPedId()) and not holdingnozzle and not HoldingSpecialNozzle and inGasStation == true then + return true + end + end, + }, + [3] = { + name = "cdn-fuel:modelOptions:option_3", + num = 3, + type = "client", + event = "cdn-fuel:client:returnnozzle", + icon = "fas fa-hand", + label = Lang:t("return_nozzle"), + canInteract = function() + if holdingnozzle and not refueling then + return true + end + end, + }, + [4] = { + name = "cdn-fuel:modelOptions:option_4", + num = 4, + type = "client", + event = "cdn-fuel:client:grabnozzle:special", + icon = "fas fa-gas-pump", + label = Lang:t("grab_special_nozzle"), + canInteract = function() + if Config.FuelDebug then print("Is Player In Special Fuel Zone?: "..tostring(PlayerInSpecialFuelZone)) end + if not HoldingSpecialNozzle and not IsPedInAnyVehicle(PlayerPedId()) and PlayerInSpecialFuelZone then + return true + end + end, + }, + [5] = { + name = "cdn-fuel:modelOptions:option_5", + num = 5, + type = "client", + event = "cdn-fuel:client:returnnozzle:special", + icon = "fas fa-hand", + label = Lang:t("return_special_nozzle"), + canInteract = function() + if HoldingSpecialNozzle and not IsPedInAnyVehicle(PlayerPedId()) then + return true + end + end + }, + } + + exports.ox_target:addModel(props, modelOptions) else exports[Config.TargetResource]:AddTargetBone(bones, { options = { diff --git a/fxmanifest.lua b/fxmanifest.lua index 63a916e..e07b61d 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.8' +version '2.1.9' client_scripts { '@PolyZone/client.lua', diff --git a/version b/version index b370e25..b88e500 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.1.8 \ No newline at end of file +2.1.9 \ No newline at end of file