Options Properties
This page documents all properties available when creating options for lyre_context. Options are used in all add*Option exports and in menu items.
Basic Properties
name
A unique identifier for the option. Used to remove the option later.
name
string or number
No
Auto-generated
{
name = "my_unique_option",
label = "My Option",
onSelect = function(ctx) end
}Note: If not provided, an ID is automatically generated and returned by the add*Option export.
label
The text displayed in the menu for this option.
label
string
Yes
"Option"
{
label = "Open Door",
onSelect = function(ctx) end
}icon
A FontAwesome icon class to display next to the label.
icon
string
No
nil
{
label = "Repair Vehicle",
icon = "fa-solid fa-wrench",
onSelect = function(ctx) end
}Note: Use FontAwesome 6 class names. The icon is automatically converted to lowercase.
iconColor
Custom color for the icon.
iconColor
string
No
nil
{
label = "Emergency",
icon = "fa-solid fa-exclamation-triangle",
iconColor = "#ff0000",
onSelect = function(ctx) end
}Action Properties
You must define at least one action property. Options are mutually exclusive - only one will be executed.
onSelect
A callback function executed when the option is selected.
onSelect
function
No*
For entity options:
{
label = "Lock Vehicle",
onSelect = function(ctx)
-- ctx contains entity data (see Context Object section)
SetVehicleDoorsLocked(ctx.id, 2)
end
}For menu items:
exports.lyre_context:addMenuItem(menuId, {
label = "Repair",
onSelect = function(menuCtx, entityCtx)
-- menuCtx = { id, title, data }
-- entityCtx = arguments passed to openMenu()
SetVehicleFixed(entityCtx.id)
end
})event
Triggers a client event when the option is selected.
event
string
No*
{
label = "Open Shop",
event = "myshop:openMenu"
}Note: The context object is passed as the first argument to the event.
serverEvent
Triggers a server event when the option is selected.
serverEvent
string
No*
{
label = "Call Police",
serverEvent = "police:alertDispatch"
}Note: The context object is passed as the first argument to the event.
export
Calls an export function when the option is selected.
export
string
No*
resource
string
No
{
label = "Open Inventory",
export = "openInventory",
resource = "ox_inventory" -- optional, defaults to invoking resource
}Note: The export is called as exports[resource][export](nil, ctx, ...).
command
Executes a command when the option is selected.
command
string
No*
{
label = "Toggle Engine",
command = "engine"
}Condition Properties
These properties control when an option is visible/available.
canInteract
A function that determines if the option should be shown.
canInteract
function
No
nil (always visible)
For entity options:
{
label = "Enter Vehicle",
canInteract = function(ctx)
-- Return true to show the option, false to hide it
local vehicle = ctx.id
return GetVehicleDoorLockStatus(vehicle) ~= 2
end,
onSelect = function(ctx)
TaskEnterVehicle(PlayerPedId(), ctx.id, -1, -1, 1.0, 1, 0)
end
}For menu items:
exports.lyre_context:addMenuItem(menuId, {
label = "Driver Seat",
canInteract = function(menuCtx, entityCtx)
-- Check if driver seat is empty
return GetPedInVehicleSeat(entityCtx.id, -1) == 0
end,
onSelect = function(menuCtx, entityCtx)
SetPedIntoVehicle(PlayerPedId(), entityCtx.id, -1)
end
})Note: The canInteract function is re-evaluated in real-time while the menu is open. If conditions change (e.g., player moves out of range), the option will disappear.
distance
Maximum distance from the player to the target for the option to be available.
distance
number
No
nil (no limit)
{
label = "Pick Lock",
distance = 2.0, -- Must be within 2 meters
onSelect = function(ctx) end
}groups
Restricts the option to players in specific jobs/gangs.
groups
string or table
No
nil (all players)
Single group:
{
label = "Arrest",
groups = "police",
onSelect = function(ctx) end
}Multiple groups (player needs ANY):
{
label = "Staff Action",
groups = { "admin", "mod", "helper" },
onSelect = function(ctx) end
}Groups with minimum grade:
{
label = "Chief Only",
groups = { police = 4, sheriff = 4 }, -- Minimum grade 4
onSelect = function(ctx) end
}items
Restricts the option to players with specific items in their inventory.
items
string or table
No
nil (no item requirement)
anyItem
boolean
No
false
Single item:
{
label = "Pick Lock",
items = "lockpick",
onSelect = function(ctx) end
}Multiple items (player needs ALL by default):
{
label = "Repair Vehicle",
items = { "repairkit", "advancedrepairkit" },
onSelect = function(ctx) end
}Multiple items (player needs ANY):
{
label = "Break In",
items = { "lockpick", "crowbar" },
anyItem = true, -- Only need one of these
onSelect = function(ctx) end
}Items with specific amounts:
{
label = "Craft Item",
items = { wood = 5, metal = 3 }, -- Need 5 wood AND 3 metal
onSelect = function(ctx) end
}Items with specific amounts (any):
{
label = "Use Healing Item",
items = { bandage = 1, medkit = 1 },
anyItem = true, -- Need 1 bandage OR 1 medkit
onSelect = function(ctx) end
}bones
Restricts the option to specific entity bones (only for entity options).
bones
string or table
No
nil (any part of entity)
Single bone:
{
label = "Open Hood",
bones = "bonnet", -- GTA bone name
onSelect = function(ctx)
SetVehicleDoorOpen(ctx.id, 4, false, false)
end
}Multiple bones:
{
label = "Open Driver Door",
bones = { "door_dside_f", "seat_dside_f" },
onSelect = function(ctx)
SetVehicleDoorOpen(ctx.id, 0, false, false)
end
}Note: The option only appears if the player clicks within ~1 meter of the specified bone(s).
Common vehicle bones:
Doors:
door_dside_f,door_pside_f,door_dside_r,door_pside_rSeats:
seat_dside_f,seat_pside_f,seat_dside_r,seat_pside_rOther:
bonnet,boot,exhaust,wheel_lf,wheel_rf,wheel_lr,wheel_rr
Common ped bones:
SKEL_Head,SKEL_Neck_1,SKEL_Spine3,SKEL_L_Hand,SKEL_R_Hand
offset
Restricts the option to a specific position relative to the entity (only for entity options).
offset
vector3
No
nil
offsetAbsolute
boolean
No
false
offsetSize
number
No
1.0
Relative offset (based on model dimensions):
{
label = "Open Trunk",
offset = vec3(0.5, 0.0, 0.5), -- Relative to model: (x=right, y=back, z=up)
offsetSize = 1.5, -- Detection radius around the offset point
onSelect = function(ctx)
SetVehicleDoorOpen(ctx.id, 5, false, false)
end
}Note: Relative offset uses the model's bounding box:
x: 0.0 = left, 0.5 = center, 1.0 = righty: 0.0 = front, 0.5 = center, 1.0 = backz: 0.0 = bottom, 0.5 = center, 1.0 = top
Absolute offset (world coordinates relative to entity):
{
label = "Check Roof",
offset = vec3(0.0, 0.0, 2.0), -- 2 meters above entity center
offsetAbsolute = true,
onSelect = function(ctx) end
}Behavior Properties
closeOnClick
Controls whether the context menu closes after selecting this option.
closeOnClick
boolean
No
false
{
label = "Delete Vehicle",
closeOnClick = true, -- Menu closes after selection
onSelect = function(ctx)
DeleteEntity(ctx.id)
end
}Note: By default, the menu stays open. Set to true for one-time actions like deletion.
Context Object
The context object (ctx) passed to callbacks contains information about the targeted entity or environment.
Entity Context (Vehicles, Peds, Objects, Players)
id
number
Entity handle
type
number
Entity type: 1 = Ped, 2 = Vehicle, 3 = Object, 10 = Player
model
number
Entity model hash
coords
vector3
Entity coordinates
endCoords
vector3
Raycast impact point (where player clicked)
normal
vector3
Surface normal at impact point
netId
number or nil
Network ID (if entity is networked)
serverId
number or nil
Player server ID (only for type 10 - players)
Example:
{
label = "Entity Info",
onSelect = function(ctx)
print("Entity ID: " .. ctx.id)
print("Entity Type: " .. ctx.type)
print("Model Hash: " .. ctx.model)
print("Position: " .. tostring(ctx.coords))
print("Click Position: " .. tostring(ctx.endCoords))
if ctx.netId then
print("Network ID: " .. ctx.netId)
end
if ctx.serverId then
print("Player Server ID: " .. ctx.serverId)
end
end
}Environment Context
type
number
Always 100 for environment
coords
vector3
Position where player clicked
normal
vector3
Surface normal at click position
Example:
exports.lyre_context:addEnvironmentOption({
label = "Teleport Here",
onSelect = function(ctx)
print("Environment click at: " .. tostring(ctx.coords))
print("Surface normal: " .. tostring(ctx.normal))
SetEntityCoords(PlayerPedId(), ctx.coords.x, ctx.coords.y, ctx.coords.z)
end
})Menu Context
For menu items, the first argument is a menu context, and additional arguments are those passed to openMenu().
id
string
Menu ID
title
string
Menu title
data
table
Custom data set in createMenu or updateMenuData
Example:
local myMenu = exports.lyre_context:createMenu("test_menu", "Test", {
data = { counter = 0 }
})
exports.lyre_context:addMenuItem(myMenu, {
label = "Increment Counter",
onSelect = function(menuCtx, entityCtx)
-- menuCtx.data contains { counter = 0 }
menuCtx.data.counter = menuCtx.data.counter + 1
print("Counter: " .. menuCtx.data.counter)
-- entityCtx is what was passed to openMenu()
if entityCtx then
print("Entity ID: " .. entityCtx.id)
end
end
})
-- Open menu from a vehicle option
exports.lyre_context:addVehicleOption({
label = "Open Test Menu",
onSelect = function(ctx)
-- ctx (entity context) becomes entityCtx in menu items
exports.lyre_context:openMenu(myMenu, ctx)
end
})Complete Example
Here's a complete example showcasing multiple properties:
-- Create a submenu for vehicle staff actions
local staffVehicleMenu = exports.lyre_context:createMenu(nil, "Staff Vehicle Actions", {
data = { uses = 0 },
onOpen = function(data, entityCtx)
data.uses = data.uses + 1
print("Menu opened " .. data.uses .. " times")
end
})
-- Add menu items
exports.lyre_context:addMenuItem(staffVehicleMenu, {
name = "repair_vehicle",
label = "Repair Vehicle",
icon = "fa-solid fa-wrench",
groups = { "admin", "mechanic" },
onSelect = function(menuCtx, entityCtx)
SetVehicleFixed(entityCtx.id)
SetVehicleEngineHealth(entityCtx.id, 1000.0)
end
})
exports.lyre_context:addMenuItem(staffVehicleMenu, {
name = "delete_vehicle",
label = "Delete Vehicle",
icon = "fa-solid fa-trash",
iconColor = "#ff4444",
groups = { admin = 3 }, -- Admin grade 3+
closeOnClick = true,
onSelect = function(menuCtx, entityCtx)
DeleteEntity(entityCtx.id)
end
})
exports.lyre_context:addMenuItem(staffVehicleMenu, {
name = "go_back",
label = "Go Back",
icon = "fa-solid fa-chevron-left",
onSelect = function()
exports.lyre_context:backToMainMenu()
end
})
-- Add vehicle option that opens the menu
exports.lyre_context:addVehicleOption({
name = "staff_menu",
label = "Staff Options",
icon = "fa-solid fa-shield-halved",
groups = { "admin", "mod", "mechanic" },
distance = 5.0,
canInteract = function(ctx)
-- Only show for damaged vehicles
return GetVehicleEngineHealth(ctx.id) < 900
end,
onSelect = function(ctx)
exports.lyre_context:openMenu(staffVehicleMenu, ctx)
end
})
-- Add a door option with bone detection
exports.lyre_context:addVehicleOption({
name = "open_trunk",
label = "Open/Close Trunk",
icon = "fa-solid fa-box-open",
bones = { "boot", "trunk" },
distance = 3.0,
canInteract = function(ctx)
-- Only show if vehicle is unlocked and trunk exists
return GetVehicleDoorLockStatus(ctx.id) ~= 2 and GetIsDoorValid(ctx.id, 5)
end,
onSelect = function(ctx)
if GetVehicleDoorAngleRatio(ctx.id, 5) > 0 then
SetVehicleDoorShut(ctx.id, 5, false)
else
SetVehicleDoorOpen(ctx.id, 5, false, false)
end
end
})Last updated