2023-01-31 14:07:52 +01:00
|
|
|
local isOpen = false
|
|
|
|
|
local menuItems = {}
|
|
|
|
|
|
|
|
|
|
function lib.addRadialItem(items)
|
|
|
|
|
if table.type(items) == 'array' then
|
|
|
|
|
for i = 1, #items do
|
2023-02-02 11:28:59 +01:00
|
|
|
local item = items[i]
|
|
|
|
|
menuItems[#menuItems+1] = item
|
2023-01-31 14:07:52 +01:00
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
menuItems[#menuItems+1] = items
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-02-02 11:28:59 +01:00
|
|
|
function lib.removeRadialItem(key)
|
2023-01-31 14:07:52 +01:00
|
|
|
for i = 1, #menuItems do
|
2023-02-02 11:28:59 +01:00
|
|
|
local item = menuItems[i]
|
|
|
|
|
if item.key == key then
|
|
|
|
|
table.remove(menuItems, i)
|
2023-02-03 13:24:55 +01:00
|
|
|
break
|
2023-01-31 14:07:52 +01:00
|
|
|
end
|
|
|
|
|
end
|
2023-02-02 11:28:59 +01:00
|
|
|
if isOpen then
|
2023-02-03 13:24:55 +01:00
|
|
|
SendNUIMessage({
|
|
|
|
|
action = 'refreshItems',
|
|
|
|
|
data = menuItems
|
|
|
|
|
})
|
2023-02-02 11:28:59 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function openRadial()
|
|
|
|
|
isOpen = true
|
2023-01-31 14:07:52 +01:00
|
|
|
SendNUIMessage({
|
|
|
|
|
action = 'openRadialMenu',
|
|
|
|
|
data = {
|
2023-02-03 13:24:55 +01:00
|
|
|
items = menuItems
|
2023-01-31 14:07:52 +01:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
SetNuiFocus(true, true)
|
|
|
|
|
SetNuiFocusKeepInput(true)
|
|
|
|
|
CreateThread(function()
|
|
|
|
|
while isOpen do
|
|
|
|
|
DisablePlayerFiring(cache.playerId, true)
|
|
|
|
|
DisableControlAction(0, 1, true)
|
|
|
|
|
DisableControlAction(0, 2, true)
|
|
|
|
|
Wait(0)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function closeRadial()
|
|
|
|
|
SendNUIMessage({
|
|
|
|
|
action = 'openRadialMenu',
|
|
|
|
|
data = false
|
|
|
|
|
})
|
|
|
|
|
SetNuiFocus(false, false)
|
|
|
|
|
isOpen = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
RegisterCommand('+ox_lib-radial', openRadial)
|
|
|
|
|
|
|
|
|
|
RegisterCommand('-ox_lib-radial', closeRadial)
|
|
|
|
|
|
|
|
|
|
RegisterKeyMapping('+ox_lib-radial', 'Open radial menu', 'keyboard', 'z')
|