mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 07:26:02 +01:00
feat(client/radial): add lib.disableRadial to prevent radial access
This commit is contained in:
@@ -149,7 +149,7 @@ function lib.addRadialItem(items)
|
|||||||
menuItems[j] = item
|
menuItems[j] = item
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
if j == menuSize then
|
if j == menuSize then
|
||||||
menuSize += 1
|
menuSize += 1
|
||||||
menuItems[menuSize] = item
|
menuItems[menuSize] = item
|
||||||
@@ -222,7 +222,7 @@ RegisterNUICallback('radialBack', function(_, cb)
|
|||||||
local lastMenu = numHistory > 0 and menuHistory[numHistory]
|
local lastMenu = numHistory > 0 and menuHistory[numHistory]
|
||||||
|
|
||||||
if not lastMenu then return end
|
if not lastMenu then return end
|
||||||
|
|
||||||
menuHistory[numHistory] = nil
|
menuHistory[numHistory] = nil
|
||||||
|
|
||||||
if lastMenu.id then
|
if lastMenu.id then
|
||||||
@@ -271,11 +271,25 @@ RegisterNUICallback('radialTransition', function(_, cb)
|
|||||||
cb(true)
|
cb(true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local isDisabled = false
|
||||||
|
|
||||||
|
---Disallow players from opening the radial menu.
|
||||||
|
---@param state boolean
|
||||||
|
function lib.disableRadial(state)
|
||||||
|
isDisabled = state
|
||||||
|
|
||||||
|
if isOpen and state then
|
||||||
|
return lib.hideRadial()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
lib.addKeybind({
|
lib.addKeybind({
|
||||||
name = 'ox_lib-radial',
|
name = 'ox_lib-radial',
|
||||||
description = 'Open radial menu',
|
description = 'Open radial menu',
|
||||||
defaultKey = 'z',
|
defaultKey = 'z',
|
||||||
onPressed = function()
|
onPressed = function()
|
||||||
|
if isDisabled then return end
|
||||||
|
|
||||||
if isOpen then
|
if isOpen then
|
||||||
return lib.hideRadial()
|
return lib.hideRadial()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user