@@ -3,11 +3,7 @@ lib.locale()
33local fuelingCan = nil
44
55AddEventHandler (' 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'
117end )
128
139local 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' ),
0 commit comments