overextended / ox_lib

A FiveM resource and script library for Lua and JS.
https://overextended.dev/ox_lib
GNU Lesser General Public License v3.0
306 stars 407 forks source link

[Bug] Opened menu doesn't close after re-registering parent menu #240

Closed Moozdzn closed 1 year ago

Moozdzn commented 1 year ago

Describe the bug After re-registering a radial menu, if a nested menu is open it doesn't get updated and the player can still access old options.

To Reproduce Steps to reproduce the behavior:

  1. Register the following RadialMenus/Items
    
    lib.registerRadial({
    id = 'police_frisk',
    items = {
    {
      label = 'Frisk',
      icon = 'hand'
    },
    {
      label = 'Frisk',
      icon = 'hand'
    },
    {
      label = 'Frisk',
      icon = 'hand'
    },
    }
    })

lib.registerRadial({ id = 'police_handcuff', items = { { label = 'Handcuff', icon = 'handcuffs', }, { label = 'Handcuff', icon = 'handcuffs', }, { label = 'Handcuff', icon = 'handcuffs', }, } })

lib.addRadialItem({ { id = 'police', label = 'Police', icon = 'shield-halved', menu = 'police_menu' }, { id = 'police2', label = 'Police 2', icon = 'shield-halved', menu = 'police_menu' }, { id = 'police3', label = 'Police 3', icon = 'shield-halved', menu = 'police_menu' },

{ id = 'police4', label = 'Police 4', icon = 'shield-halved', menu = 'police_menu' },

{ id = 'police5', label = 'Police5', icon = 'shield-halved', menu = 'police_menu' }, { id = 'garage_access', icon = 'warehouse', label = 'Garage', onSelect = function() print('Garage') end }, })

local coords = GetEntityCoords(cache.ped) local point = lib.points.new(coords, 5)

function point:onEnter() print('police_menu updated onEnter') lib.registerRadial({ id = 'police_menu', items = { { id = 'dandcuff', label = 'Handcuff', icon = 'handcuffs', menu = 'police_handcuff' }, { id = 'frisk', label = 'Frisk', icon = 'hand', menu = 'police_frisk' }, { label = 'Fingerprint', icon = 'fingerprint' }, { label = 'Jail', icon = 'bus', onSelect = function() print('Jail') end }, { label = 'Search', icon = 'magnifying-glass', onSelect = function() print('Search') end } } }) end

function point:onExit() print('police_menu updated onExit') lib.registerRadial({ id = 'police_menu', items = { { id = 'garage_access', icon = 'warehouse', label = 'Garage', onSelect = function() print('Garage') end } } }) end


2. Select any `Police` option
3. Select `Frisk` option
3. Walk away until the console prints `police_menu updated onExit`
4. Menu doesn't close

**Expected behavior**
Menu should close if the option to access it gets removed

**Screenshots**
[Video](https://streamable.com/6t4diz)
thelindat commented 1 year ago

how dynamic does this shit need to be

Moozdzn commented 1 year ago

Honestly, this is not very impacting assuming there are more server and/or client safety checks and not only rely in showing/hiding the option. It's just visually confusing