Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text ui, locale to the blips #4

Merged
merged 7 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Config = {
locale = 'en',
openControl = 'E',
previousClothing = 'qb', -- 'illenium' | 'qb' | 'esx' | 'fivem-appearance'

textUi = true -- if true, uses textUI | if false, uses sprite
outfitItem = 'clothes', -- Item given to the player when they want to make outfit an item to use
}

Expand Down
75 changes: 54 additions & 21 deletions data/zones.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,60 @@ local stores = {
}
}

local currentZone = nil
local key = Config.openControl
local textUi = Config.textUi
local control = Config.openControl
local textui = exports.bl_bridge:textui()
local currentZone = nil
local sprites = {}

local function setupZones()
if GetResourceState('bl_sprites') == 'missing' then return end
for _, v in pairs(stores) do
sprites[#sprites+1] = exports.bl_sprites:sprite({
coords = v.coords,
shape = 'hex',
key = key,
distance = 3.0,
onEnter = function()

if textUi then
local point = lib.points.new({
coords = v.coords,
distance = 3.0,
})

function point:onEnter()
currentZone = v
end,
onExit = function()
local prefix = "[" .. control .. "] - "
if currentZone.type == 'barber' then
textui.showTextUI(prefix .. "Barber Shop", 'left')
elseif currentZone.type == 'tattoos' then
textui.showTextUI(prefix .. "Tattoo Parlor", 'left')
elseif currentZone.type == 'clothing' then
textui.showTextUI(prefix .. "Clothing Store", 'left')
elseif currentZone.type == 'surgeon' then
textui.showTextUI(prefix .. "Surgeon", 'left')
end
end

function point:onExit()
currentZone = nil
textui.hideTextUI()
end
else
if GetResourceState('bl_sprites') == 'missing' then return end
for _, v in pairs(stores) do
sprites[#sprites+1] = exports.bl_sprites:sprite({
coords = v.coords,
shape = 'hex',
key = key,
distance = 3.0,
onEnter = function()
currentZone = v
end,
onExit = function()
currentZone = nil
end
})
end
})
end
end
end


setupZones()

local blips = {}
Expand All @@ -160,7 +191,7 @@ local function createBlips()
if v.type == 'barber' then
spriteId = 71
blipColor = 0
blipname = 'Barber'
blipname = 'Barber Shop'
elseif v.type == 'clothing' then
spriteId = 73
blipColor = 0
Expand Down Expand Up @@ -190,20 +221,22 @@ createBlips()

AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
for _, blip in pairs(blips) do
RemoveBlip(blip)
end
for _, blip in pairs(blips) do
RemoveBlip(blip)
end

for _, sprite in pairs(sprites) do
sprite:removeSprite()
end
if not textUi then
for _, sprite in pairs(sprites) do
sprite:removeSprite()
end
end
end
end)
end)


RegisterCommand('+openAppearance', function()
if not currentZone then return end
TriggerEvent('bl_appearance:client:useZone', currentZone.type)
end, false)

RegisterKeyMapping('+openAppearance', 'Open Appearance', 'keyboard', key)
RegisterKeyMapping('+openAppearance', 'Open Appearance', 'keyboard', key)
Loading