Context Menu
Last updated
Last updated
showContext(menuData)
Creates and displays a context menu with configurable options.
Parameters:
menuData
(table): Menu configuration object containing:
name
(string): Title of the context menu
items
(table): Array of menu items, each containing:
title
(string): Display text for the menu item
icon
(string, optional): URL or path to icon image
description
(string, optional): Description text for the item
action
(function, optional): Function to execute when item is clicked
event
(string, optional): Event name to trigger when item is clicked
type
(string, optional): Event type - 'server' for server events, 'client' for client events
args
(table, optional): Arguments to pass to the event
Returns:
None
Exports:
exports['ps-lib']:showContext(menuData)
exports.ps_lib:HideMenu()
HideMenu()
Hides the currently displayed context menu.
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
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
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