Context Menu

showContext(menuData)
showContext(menuData)
Creates and displays a context menu with configurable options.
Parameters:
menuData
(table): Menu configuration object containing:name
(string): Title of the context menuitems
(table): Array of menu items, each containing:title
(string): Display text for the menu itemicon
(string, optional): URL or path to icon imagedescription
(string, optional): Description text for the itemaction
(function, optional): Function to execute when item is clickedevent
(string, optional): Event name to trigger when item is clickedtype
(string, optional): Event type - 'server' for server events, 'client' for client eventsargs
(table, optional): Arguments to pass to the event
Returns:
None
Exports:
exports['ps-lib']:showContext(menuData)
exports.ps_lib:HideMenu()
HideMenu()
HideMenu()
Hides the currently displayed context menu.
Usage Examples
Basic Context Menu with Actions
local function showPlayerMenu()
local menuData = {
name = 'Player Options',
items = {
{
title = 'Check ID',
icon = 'https://example.com/id-icon.png',
description = 'View player identification',
action = function()
ps.notify('Checking player ID...', 'info')
-- Your ID check logic here
end,
},
{
title = 'Give Money',
icon = ps.getImage('money'),
description = 'Transfer money to player',
action = function()
-- Open money transfer interface
TriggerEvent('banking:openTransfer')
end,
}
}
}
exports['ps-lib']:showContext(menuData)
end
Context Menu with Server Events
local function showVehicleMenu(vehicleId)
local menuData = {
name = 'Vehicle Actions',
items = {
{
title = 'Lock/Unlock',
icon = 'https://example.com/lock-icon.png',
description = 'Toggle vehicle lock',
event = 'vehicle:toggleLock',
type = 'server',
args = { vehicleId = vehicleId }
},
{
title = 'Start Engine',
icon = 'https://example.com/engine-icon.png',
description = 'Start the vehicle engine',
event = 'vehicle:startEngine',
type = 'client',
args = { vehicle = vehicleId }
},
{
title = 'Check Trunk',
description = 'Open vehicle trunk',
action = function()
TriggerServerEvent('inventory:openTrunk', vehicleId)
end,
}
}
}
exports['ps-lib']:showContext(menuData)
end
Menu Item Configuration
Item Properties
title
string
Yes
Display text for the menu item
icon
string
No
URL or path to icon image
description
string
No
Description text shown below title
action
function
No
Function to execute when clicked
event
string
No
Event name to trigger when clicked
type
string
No
'server' or 'client' for event type
args
table
No
Arguments passed to the event
Last updated