Skip to main content
Menu Component

Usage

Define menu entries, control the component from client or server code, and connect selections to your own events.

Menu entry interface

Each entry in the menu data array follows the IMenu interface.

namestring

The label displayed for the menu entry.

icon?string

An optional Font Awesome icon class.

eventName?string

The event triggered when the entry is selected.

args?any

Optional arguments passed to the selected event.

env?"server" | "client"

The environment in which the selected event is triggered.

description?string

Optional supporting text displayed for the menu entry.

API reference

Client exports

Open, close or update the menu from client-side Lua code.

3 exports
exports["avp_click_menu"]:open(atCursor)

Opens the menu, optionally at the current cursor position.

atCursor?boolean
void
exports["avp_click_menu"]:close()

Closes the active menu.

None
void
exports["avp_click_menu"]:setData(menuHeader, menuData)

Sets the menu header and entries displayed by the component.

menuHeaderstringmenuDataIMenu[]
void
API reference

Server exports

Control a specific player's menu from server-side Lua code.

3 exports
exports["avp_click_menu"]:open(source, atCursor)

Opens the menu for the specified player.

sourcenumber | stringatCursor?boolean
void
exports["avp_click_menu"]:close(source)

Closes the menu for the specified player.

sourcenumber | string
void
exports["avp_click_menu"]:setData(source, menuHeader, menuData)

Sets the menu header and entries for the specified player.

sourcenumber | stringmenuHeaderstringmenuDataIMenu[]
void

Examples

Server-side example

Open a menu from the server

Set a player's menu data, open the component and handle the selected server event.

server.lua
RegisterNetEvent("Ping", function(response)
local source = source

print(source .. " " .. response)
end)

RegisterCommand("sv_test", function(source)
exports["avp_click_menu"]:setData(
source,
"Vehicle (Server)",
{
{
icon = "fa-solid fa-car",
name = "Open door",
eventName = "Ping",
env = "server",
args = "Pong",
description = "Description (server)"
}
}
)
exports["avp_click_menu"]:open(source)
end)
Client-side example

Open a menu from the client

Set the local menu data, open it at the cursor and handle the selected client event.

client.lua
AddEventHandler("Ping", function(response)
print(response) -- Pong
end)

RegisterCommand("cl_test", function()
exports["avp_click_menu"]:setData(
"Vehicle (Client)",
{
{
icon = "fa-solid fa-car",
name = "Open door",
eventName = "Ping",
env = "client",
args = "Pong",
description = "Description (client)"
}
}
)
exports["avp_click_menu"]:open(true)
end)