šINTEGRATION
Once everything is up and running, it's time to link our radial menu script with other scripts on your server to maximize its functionality and improve player interactions!
Adding Menu Items Dynamically
onexRadialItemAdd
exports['onex-radialmenu']:onexRadialItemAdd(items, id, parent_id)
Parameters
items (table
): Contains the menu item configuration
-
Required fields:
title
(string
): Display textcloseRadialMenu
(boolean
): Whether to close menu after selectionicon
(table
): Icon configurationicon = { address = "fas fa-car", -- FontAwesome icon or image URL width = "24px", -- Icon width height = "24px" -- Icon height }
-
Optional fields:
trigger
(table
): Event trigger configurationtrigger = { event = { -- (optional) name = "my:event", -- Event name type = "client", -- "client" or "server" args = "arg1" -- String or table of arguments }, onSelect = function() -- (optional) Function to execute on selection print("Function triggered!") end, command = 'myCommand' -- (optional) Command to execute on selection }
type
(string
): Set to "nested" nested menu , otherwise leave empty or any other valuesubMenu
(table
): Submenu items using same structure as parent
id (string|number
): Menu item identifier
parent_id (string|number
): Optional parent menu item ID
ā ļø
When using numeric IDs, maintain sequential order (1, 2, 3, etc). Using an existing ID will overwrite that menu item.
Example Usage
exports['onex-radialmenu']:onexRadialItemAdd({
title = "Vehicle Options",
closeRadialMenu = false,
icon = {
address = "fas fa-car",
width = "24px",
height = "24px"
},
type = "nested",
subMenu = {
{
id = "engine_toggle",
title = "Toggle Engine",
closeRadialMenu = true,
icon = {
address = "fas fa-power-off",
width = "20px",
height = "20px"
},
trigger = {
event = {
name = "vehicle:toggleEngine",
type = "client"
},
onSelect = function()
print("Engine toggled!")
end,
command = 'engine'
}
}
}
}, 'vehicle_menu', 'main_menu')
Removing Menu Items
exports['onex-radialmenu']:onexRemoveRadialItem(parent_id, child_id)
Parameters
- parent_id (
string|number
): ID of the parent menu item - child_id (
string|number
, optional): ID of the child menu item to remove
If only parent_id
is provided, the entire menu item and its children will be removed.
If both IDs are provided, only the specified child item will be removed from the parent menu.
Example
-- Remove a specific submenu item
exports['onex-radialmenu']:onexRemoveRadialItem('vehicle_menu', 'engine_toggle')
-- Remove an entire menu section
exports['onex-radialmenu']:onexRemoveRadialItem('vehicle_menu')
Clearing All Items
exports['onex-radialmenu']:clearRadialItems()
ā ļø
This function removes all items from the radial menu.
Toggling Menu Access
exports['onex-radialmenu']:disableRadial(toggle)
Parameters
- toggle (
boolean
):true
: Disables the radial menufalse
: Enables the radial menu
Example
-- Disable the radial menu
exports['onex-radialmenu']:disableRadial(true)
-- Re-enable the radial menu
exports['onex-radialmenu']:disableRadial(false)
Use this function to temporarily restrict access to the radial menu during specific game states or animations.