Skip to content

Commit

Permalink
fix(client/crafting): check if data.zones is defined (#1373)
Browse files Browse the repository at this point in the history
  • Loading branch information
polisek authored Jun 20, 2023
1 parent 0b7bd4a commit 0b26667
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions modules/crafting/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,33 @@ local function createCraftingBench(id, data)

if shared.target == 'ox_target' then
data.points = nil

for i = 1, #data.zones do
local zone = data.zones[i]
zone.name = ("craftingbench_%s:%s"):format(id, i)
zone.id = id
zone.index = i
zone.options = {
{
label = zone.label or locale('open_crafting_bench'),
canInteract = data.groups and function()
return client.hasGroup(data.groups)
end or nil,
onSelect = function()
client.openInventory('crafting', { id = id, index = i })
end,
distance = zone.distance or 2.0,
icon = zone.icon or 'fas fa-wrench',
}
}

exports.ox_target:addBoxZone(zone)

if blip then
createBlip(blip, zone.coords)
end
end
if data.zones then
for i = 1, #data.zones do
local zone = data.zones[i]
zone.name = ("craftingbench_%s:%s"):format(id, i)
zone.id = id
zone.index = i
zone.options = {
{
label = zone.label or locale('open_crafting_bench'),
canInteract = data.groups and function()
return client.hasGroup(data.groups)
end or nil,
onSelect = function()
client.openInventory('crafting', { id = id, index = i })
end,
distance = zone.distance or 2.0,
icon = zone.icon or 'fas fa-wrench',
}
}

exports.ox_target:addBoxZone(zone)

if blip then
createBlip(blip, zone.coords)
end
end
end
elseif data.points then
data.zones = nil

Expand Down

0 comments on commit 0b26667

Please sign in to comment.