Skip to content

Commit

Permalink
fix(client): qtarget support
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Jul 26, 2022
1 parent 44771e6 commit fc2863e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ lib.locale()
local fuelingCan = nil

AddEventHandler('ox_inventory:currentWeapon', function(currentWeapon)
if currentWeapon and currentWeapon.name == 'WEAPON_PETROLCAN' then
fuelingCan = currentWeapon
else
fuelingCan = nil
end
fuelingCan = currentWeapon and currentWeapon.name == 'WEAPON_PETROLCAN'
end)

local function raycast(flag)
Expand Down Expand Up @@ -138,7 +134,7 @@ CreateThread(function()
elseif not isFueling then
local vehicle = GetPlayersLastVehicle()

if vehicle then
if vehicle ~= 0 then
if fuelingCan and Config.petrolCan.enabled then
DisplayHelpTextThisFrame('petrolcanHelpText', false)
else
Expand Down Expand Up @@ -298,14 +294,15 @@ if not Config.qtarget then
local playerCoords = GetEntityCoords(cache.ped)

if nearestPump then
if petrolCan then
local moneyAmount = ox_inventory:Search(2, 'money')

if petrolCan and moneyAmount >= Config.petrolCan.price then
return getPetrolCan(nearestPump, true)
end

local vehicle = GetPlayersLastVehicle()

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

if not vehicleInRange then
if not Config.petrolCan.enabled then return end
Expand Down Expand Up @@ -361,16 +358,21 @@ if Config.qtarget then
if isFueling or cache.vehicle then
return false
end
return #(GetEntityCoords(GetPlayersLastVehicle()) - playerCoords) <= 3

local vehicle = GetPlayersLastVehicle()
return vehicle ~= 0 and #(GetEntityCoords(vehicle) - playerCoords) <= 3
end
},
{
action = function (entity)
if ox_inventory:Search(2, 'money') >= Config.petrolCan.price then
getPetrolCan(GetEntityCoords(entity))
else
lib.notify({type = 'error', description = locale('petrolcan_cannot_afford')})
local petrolCan = Config.petrolCan.enabled and GetSelectedPedWeapon(cache.ped) == `WEAPON_PETROLCAN`
local moneyAmount = ox_inventory:Search(2, 'money')

if moneyAmount < Config.petrolCan.price then
return lib.notify({type = 'error', description = locale('petrolcan_cannot_afford')})
end

return getPetrolCan(GetEntityCoords(entity), petrolCan)
end,
icon = "fas fa-faucet",
label = locale('petrolcan_buy_or_refill'),
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--[[ FX Information ]]--
fx_version 'cerulean'
use_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'
lua54 'yes'
game 'gta5'

Expand Down

0 comments on commit fc2863e

Please sign in to comment.