vorp menu is a library that allows you to create menus in game with a rdr2 style.
GetMenuData
local Menu = exports.vorp_menu:GetMenuData()
CloseAll
MenuData.CloseAll()
Menu Elements
local menuElements = {
{
label = "name",
value = "value",
desc = "description",
itemHeight = "4vh", -- optional
labelPos = "left", -- optional
footerText = "any text here" -- optional
isNotSelectable = true -- optional
image = "image" -- optional
}
}
addNewElement
menu.addNewElement({
label = "label",
value = "open",
desc = "description"
})
menu.refresh()
Menu Example
function OpenMenu()
-- close any menu before opening
Menu.CloseAll()
local menuElements = {
{
label = "name",
value = "value",
desc = "description"
}
{
label = "name",
value = 0,
desc = "description",
type = "slider",
min = 0,
max = 10,
hop = 1
}
{
label = "name",
value = "value",
desc = "description",
itemHeight = "4vh"
}
}
Menu.Open("default", GetCurrentResourceName() , "OpenMenu", -- unique namespace will allow the menu to open where you left off
{
title = "title",
subtext = "subtext",
align = "top-left", -- top-right , top-center , top-left
elements = menuElements, -- elements needed
lastmenu = "functionName", -- if you wish to go back to the previous menu , or remove (optional)
maxVisibleItems = 6, -- max visible items in the menu
hideRadar = true, -- hides the radar
soundOpen = true, -- plays the open sound of the menu
},
function(data, menu) -- submit callback
-- triggers when pressing/clicking enter
print("current key of MenuElements is " .. data.current.index)
print("current value of MenuElements is " .. data.current.value)
-- to go back to lastmenu if any
if (data.current == "backup") then --(optional) if lastmenu is defined
return _G[data.trigger](any,any) -- or the function of the last menu
end
end,
function(data,menu) -- cancel callback THIS IS OPTIONAL
-- when menu closes if lastmenu isn't defined
menu.close(true, true)
end,
function(data, menu) -- change callback THIS IS OPTIONAL
-- if theres no previous menu close menu on backspace press
-- is called when scrolling through the elements, also when the type = "slider" is changed i dont know why.
end,
function(data,menu) -- close callback THIS IS OPTIONAL
-- when menu closes if lastmenu isnt defined
-- menu.close(showRadar, soundClose)
end,
)
end