GetMenuData
GetMenuData
GetMenuData
on top of your client scripts add this to get the menu data setters and getters
The menu data
Copy
local Menu = exports.vorp_menu:GetMenuData()
CloseAll
CloseAll
CloseAll
Close all menus
Copy
MenuData.CloseAll()
Menu Elements
Menu elements are the elements that will be displayed in the menuMenu Elements
Menu Elements
for each element you can use the following params
The value of the tab element
The label of the tab element
The description of the tab element
The height of the tab element example 4vh
The position of the label left , center only
The text of the footer
If true the element will not be selectable, meaning the red square will not be shown
If true the element will not be clickable
The image name from vorp_inventory items folder, useful to create the grid menu
Copy
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
}
}
Functions
update elements ,add ,remove ,get elements runtimeaddNewElement
addNewElement
this function will add a new element to the current menu elements by orderrefresh menu to show new element
The label of the element
The value of the element
The description of the element
Copy
menu.addNewElement({
label = "label",
value = "open",
desc = "description"
})
Copy
menu.refresh()
Events
- close menu event
Copy
AddEventHandler("vorp:menu:closemenu", function(data)
end)
- open menu event
Copy
AddEventHandler("vorp:menu:openmenu", function(data)
end)
Menu Example
Menu Example
Menu Example
Copy
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