Context Menu
A right-click style menu with multiple options and optional nested submenus.

-- Context menu with submenu
RegisterCommand('vehiclemenu', function()
exports['moon-ui']:CreateMenu({
{
id = "vehicle_menu",
header = "Vehicle Controls",
text = "Basic vehicle controls",
icon = "fas fa-car",
subMenu = {
{
id = "engine_toggle",
header = "Toggle Engine",
icon = "fas fa-engine-warning",
action = function()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local isOn = GetIsVehicleEngineRunning(vehicle)
SetVehicleEngineOn(vehicle, not isOn, false, true)
end
},
{
id = "vehicle_doors",
header = "Open Hood",
icon = "fas fa-car-burst",
action = function()
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
SetVehicleDoorOpen(vehicle, 4, false, false)
end
}
}
},
{
id = "vehicle_extras",
header = "Print Something",
text = "Just for testing",
icon = "fas fa-terminal",
color = "green",
action = function()
print("This is a custom Lua action!")
end
},
{
id = "vehicle_extras2",
header = "Vehicle Extras",
text = "Additional vehicle options",
icon = "fas fa-plus",
color = "green",
event = "moon-ui:vehicleExtras",
args = {"args1", "args2", "args3"} -- RegisterNetEvent("moon-ui:vehicleExtras", function(args1, args2, args3)
}
}, "Vehicle Management", "Control and customize your vehicle")
end)
Last updated