Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit fc2863e

Browse files
committed
fix(client): qtarget support
1 parent 44771e6 commit fc2863e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

client.lua

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ lib.locale()
33
local fuelingCan = nil
44

55
AddEventHandler('ox_inventory:currentWeapon', function(currentWeapon)
6-
if currentWeapon and currentWeapon.name == 'WEAPON_PETROLCAN' then
7-
fuelingCan = currentWeapon
8-
else
9-
fuelingCan = nil
10-
end
6+
fuelingCan = currentWeapon and currentWeapon.name == 'WEAPON_PETROLCAN'
117
end)
128

139
local function raycast(flag)
@@ -138,7 +134,7 @@ CreateThread(function()
138134
elseif not isFueling then
139135
local vehicle = GetPlayersLastVehicle()
140136

141-
if vehicle then
137+
if vehicle ~= 0 then
142138
if fuelingCan and Config.petrolCan.enabled then
143139
DisplayHelpTextThisFrame('petrolcanHelpText', false)
144140
else
@@ -298,14 +294,15 @@ if not Config.qtarget then
298294
local playerCoords = GetEntityCoords(cache.ped)
299295

300296
if nearestPump then
301-
if petrolCan then
297+
local moneyAmount = ox_inventory:Search(2, 'money')
298+
299+
if petrolCan and moneyAmount >= Config.petrolCan.price then
302300
return getPetrolCan(nearestPump, true)
303301
end
304302

305303
local vehicle = GetPlayersLastVehicle()
306304

307305
local vehicleInRange = vehicle and #(GetEntityCoords(vehicle) - playerCoords) <= 3
308-
local moneyAmount = ox_inventory:Search(2, 'money')
309306

310307
if not vehicleInRange then
311308
if not Config.petrolCan.enabled then return end
@@ -361,16 +358,21 @@ if Config.qtarget then
361358
if isFueling or cache.vehicle then
362359
return false
363360
end
364-
return #(GetEntityCoords(GetPlayersLastVehicle()) - playerCoords) <= 3
361+
362+
local vehicle = GetPlayersLastVehicle()
363+
return vehicle ~= 0 and #(GetEntityCoords(vehicle) - playerCoords) <= 3
365364
end
366365
},
367366
{
368367
action = function (entity)
369-
if ox_inventory:Search(2, 'money') >= Config.petrolCan.price then
370-
getPetrolCan(GetEntityCoords(entity))
371-
else
372-
lib.notify({type = 'error', description = locale('petrolcan_cannot_afford')})
368+
local petrolCan = Config.petrolCan.enabled and GetSelectedPedWeapon(cache.ped) == `WEAPON_PETROLCAN`
369+
local moneyAmount = ox_inventory:Search(2, 'money')
370+
371+
if moneyAmount < Config.petrolCan.price then
372+
return lib.notify({type = 'error', description = locale('petrolcan_cannot_afford')})
373373
end
374+
375+
return getPetrolCan(GetEntityCoords(entity), petrolCan)
374376
end,
375377
icon = "fas fa-faucet",
376378
label = locale('petrolcan_buy_or_refill'),

fxmanifest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--[[ FX Information ]]--
22
fx_version 'cerulean'
3-
use_fxv2_oal 'yes'
3+
use_experimental_fxv2_oal 'yes'
44
lua54 'yes'
55
game 'gta5'
66

0 commit comments

Comments
 (0)