esx_menu_default

MLO-uri, interioare, hărți optimizate și asset-uri pentru stream.
Post Reply
User avatar
greenie
Full Member
Full Member
Posts: 4444
Joined: Sun Nov 21, 2021 4:55 pm
Jucator SA:MP ?: Nu
Nick:: greenie
Jucator CS ?: Da

esx_menu_default

Post by greenie »

ESX.UI.Menu.Open
Open a menu that can be used with arrow keys
ESX.UI.Menu.Open(type, namespace, name, data, onSelect, cancel )
Arguments

type: string
the menu to open default in this case
namespace: string
The namespace of the menu, usually GetResourceName()is used
name: string
The name of the menu
data: table
The table with the elements to show in the menu
onSelect: function
Function that gets ran when an element is selected.
cancel: function
Function that gets ran when the menu gets closed
Data table

title: title of the menu
align: position (top-left | top-right | bottom-left | bottom-right | center)
elements: selectable elements table
locales?: locales table
Elements

label: string
label name to show, supports HTML
name: string
name of the element
value: number | string
value of the element/slider
type: slider | button - default is button
Type of the element
min: number
minimum slider value
max: number
Maximum slider value
disableRightArrow?: boolean
Disables right arrow icon for buttons
unselectable?: boolean
Makes the menu element not selectable
usable?: boolean
Makes the menu element not usable
options?: string[]
Allows to use options instead of numbers in slider
icon?: string
Icon next to the text
onSelect
Function triggered when an element is selected, returns data and menu, data.current is used to get the current selected element

Example
function(data, menu)
--- for a simple element
if data.current.name == "element1" then
print("Element 1 Selected")
menu.close()
end

-- for slider elements

if data.current.name == "bread" then
print(data.current.value)
end
end
cancel
This function is triggered when the menu gets closed, returns data and menu
function(data, menu)
print("Closing Menu - " .. menu.title)
menu.close() -- close menu
end
Menu Example
local Elements = {
{label = "I`m An Element", name = "element1"},
{label = "Bread - £200", name = "bread", value = 1, type = 'slider', min = 1,max = 100},
{label = '<span style="color:green;">HEY! IM GREEN!/span>', name = "geen_element"}
}

ESX.UI.Menu.Open("default", GetCurrentResourceName(), "Example_Menu", {
title = "Example Menu", -- The Name of Menu to show to users,
align = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center" | "left-center" | "right-center"
elements = Elements, -- define elements as the pre-created table
}, function(data,menu) -- OnSelect Function
--- for a simple element
if data.current.name == "element1" then
print("Element 1 Selected")
menu.close()
end

-- for slider elements

if data.current.name == "bread" then
print(data.current.value)

if data.current.value == 69 then
print("Nice!")
menu.close()
end
end
end, function(data, menu) -- Cancel Function
print("Closing Menu")
menu.close() -- close menu
end)
𝑴𝒂𝒚𝒃𝒆 𝒕𝒉𝒆 𝑬𝒂𝒓𝒕𝒉 𝒊𝒔 𝒕𝒉𝒆 𝑯𝒆𝒍𝒍 𝒐𝒇 𝑨𝒏𝒐𝒕𝒉𝒆𝒓 𝑷𝒍𝒂𝒏𝒆𝒕... ☢️

✅ GAZDUIRE JOCURI / VPS / GAZDUIRE WEB / SERVERE DEDICATE - Stock NELIMITAT / Valabil comandati pe https://www.zonek.ro/
Post Reply

Return to “Server Resources”