Skip to content

Commit

Permalink
refactor(client/radial): clear items on resource stop
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 7, 2023
1 parent a30c8c1 commit 560b19c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions resource/interface/client/radial.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ end

function lib.addRadialItem(items)
local menuSize = #menuItems
local invokingResource = GetInvokingResource()

if table.type(items) == 'array' then
for i = 1, #items do
local item = items[i]
item.resource = invokingResource
menuSize += 1
menuItems[menuSize] = item
end
else
items.resource = invokingResource
menuItems[menuSize + 1] = items
end
end
Expand Down Expand Up @@ -130,3 +133,13 @@ RegisterCommand('+ox_lib-radial', openRadial)
RegisterCommand('-ox_lib-radial', closeRadial)

RegisterKeyMapping('+ox_lib-radial', 'Open radial menu', 'keyboard', 'z')

AddEventHandler('onClientResourceStop', function(resource)
for i = #menuItems, 1, -1 do
local item = menuItems[i]

if item.resource == resource then
table.remove(menuItems, i)
end
end
end)

0 comments on commit 560b19c

Please sign in to comment.