Skip to main content

GetMenuData

on top of your client scripts add this to get the menu data setters and getters
return
table
The menu data
local Menu = exports.vorp_menu:GetMenuData()

CloseAll

Close all menus
-- these params are optional
-- to not fire event close pass false if nil or true will fire the event close
MenuData.CloseAll(showRadar, soundClose, fireEventClose)

RegisterControls

Register custom keyboard, mouse, or wheel controls handled by vorp_menu’s NUI layer.This is useful when you want menu-like input handling outside of an opened menu.
controls
table
required
Array of controls to listen for.Supported values:
  • Any browser keyboard key string from KeyboardEvent.key, for example e, ArrowUp, Enter, or Backspace
  • scrollup
  • scrolldown
  • mousepress
onPress
function
required
Callback fired with the triggered control name.
Notes:
  • Keyboard keys and mousepress repeat every frame while held until release.
  • scrollup and scrolldown fire once per wheel event.
  • mousepress ignores middle click and returns mousepress_left or mousepress_right in the callback.
  • If a menu is open, these menu keys are reserved and will not trigger custom callbacks: ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Enter, Escape, Backspace.
  • Calling RegisterControls again replaces previously registered controls in the UI layer.
  • Call Menu.UnregisterControls() when you no longer need the listeners.
local Menu = exports.vorp_menu:GetMenuData()

Menu.RegisterControls({ "e", "scrollup", "scrolldown", "mousepress" }, function(control)
    if control == "e" then
        print("E is being held")
    elseif control == "scrollup" then
        print("Scrolled up once")
    elseif control == "scrolldown" then
        print("Scrolled down once")
    elseif control == "mousepress_left" then
        print("Left mouse button pressed")
    elseif control == "mousepress_right" then
        print("Right mouse button pressed")
    end
end)

UnregisterControls

Remove all controls previously registered with RegisterControls.
local Menu = exports.vorp_menu:GetMenuData()

Menu.UnregisterControls()
Menu elements are the elements that will be displayed in the menu

Functions

update elements ,add ,remove ,get elements runtime
this function will add a new element to the current menu elements by order
label
string
required
The label of the element
value
string
required
The value of the element
desc
string
required
The description of the element
menu.addNewElement({
    label = "label",
    value = "open",
    desc = "description"
})
refresh menu to show new element
menu.refresh()

Events

  • close menu event
AddEventHandler("vorp:menu:closemenu", function(data)

end)
  • open menu event
AddEventHandler("vorp:menu:openmenu", function(data)

end)