Skip to content

Commit

Permalink
fix bug where TextUI would not always show
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorn08 committed Aug 20, 2024
1 parent 4168f5f commit ea0d230
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions client/zones.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
local zoneId
local QBCore
local allowAccess = false
local zones = {}
local textUiTitle = 'Press [E] to tune your car'
---@type TextUIOptions
local textUiOptions = {
icon = 'fa-solid fa-car',
position = 'left-center',
}

if GetResourceState('qb-core') == 'started' then
QBCore = exports['qb-core']:GetCoreObject()
Expand All @@ -26,7 +33,7 @@ end

CreateThread(function()
for _, v in ipairs(Config.Zones) do
lib.zones.poly({
zones[#zones + 1] = lib.zones.poly({
points = v.points,
onEnter = function(s)
zoneId = s.id
Expand All @@ -48,10 +55,7 @@ CreateThread(function()
return
end

lib.showTextUI('Press [E] to tune your car', {
icon = 'fa-solid fa-car',
position = 'left-center',
})
lib.showTextUI(textUiTitle, textUiOptions)
end,
onExit = function()
zoneId = nil
Expand Down Expand Up @@ -97,4 +101,17 @@ RegisterNetEvent('customs:client:adminMenu', function()
type = 'error'
})
end
end)
end)

lib.onCache("vehicle", function(veh)
if not veh then
lib.hideTextUI()
return
end
for _, zone in ipairs(zones) do
if zone:contains(GetEntityCoords(veh)) then
lib.showTextUI(textUiTitle, textUiOptions)
break
end
end
end)
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ author 'Jorn#0008'
name 'popcornrp-customs'
description 'Customs script using ox_lib'
repository 'https://github.com/alberttheprince/popcornrp-customs'
version '1.4.0'
version '1.4.1'

ui_page 'web/index.html'

Expand Down

0 comments on commit ea0d230

Please sign in to comment.