Onex ScriptsDocumentation
Documentation
Loading...
💢 INTEGRATION#
Use these exports to connect onex-radialmenu with your scripts: add items, nest menus, remove items, clear everything, or temporarily disable the menu.
QUICK START#
Add a simple item and test it quickly:
exports['onex-radialmenu']:onexRadialItemAdd({ title = 'Hello World', closeRadialMenu = true, icon = { address = 'fas fa-hand', width = '20px', height = '20px' }, trigger = { onSelect = function() print('Hello from radial!') end } }, 'hello_world')
Open the radial (e.g., F1) and select the item. Remove it with:
exports['onex-radialmenu']:onexRemoveRadialItem('hello_world')
EXPORT REFERENCE#
Add Items: onexRadialItemAdd#
exports['onex-radialmenu']:onexRadialItemAdd(items, id, parent_id)
Parameters:
- items (table): Menu item configuration
- Required:
- title (string): Label shown in the menu
- closeRadialMenu (boolean): Close menu after selection
- icon (table):
icon = { address = 'fas fa-car', -- FontAwesome class or image URL width = '24px', height = '24px' }
- Optional:
- id (string|number): For submenu children only — unique ID per child
- trigger (table): Choose how the item acts
trigger = { event = { -- optional event to emit name = 'my:event', -- event name type = 'client', -- 'client' | 'server' args = 'arg1' -- string or table }, onSelect = function() -- optional function print('Function triggered!') end, command = 'myCommand' -- optional command }
- type (string): Use 'nested' to create a submenu container; otherwise omit
- subMenu (table): Array of submenu items (same structure as parent)
- Required:
- id (string|number): Identifier for this top-level item
- parent_id (string|number): If set, attach this item under an existing parent
When using numeric IDs, keep them sequential (1, 2, 3, ...). Reusing an existing ID overwrites that item.
Examples:
- Basic single item:
exports['onex-radialmenu']:onexRadialItemAdd({ title = 'Toggle Engine', closeRadialMenu = true, icon = { address = 'fas fa-power-off', width = '20px', height = '20px' }, trigger = { command = 'engine' } }, 'engine_toggle')
- Nested menu with a submenu:
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 } } } }, 'vehicle_menu')
Remove Items: onexRemoveRadialItem#
exports['onex-radialmenu']:onexRemoveRadialItem(parent_id, child_id)
Parameters:
- parent_id (string|number): The ID of the parent or the item to remove
- child_id (string|number, optional): If set, removes just this child from the parent
If only parent_id
is provided, the entire parent item (and its children) will be removed. If child_id
is provided, only that child item is removed.
Examples:
-- Remove a specific submenu item exports['onex-radialmenu']:onexRemoveRadialItem('vehicle_menu', 'engine_toggle') -- Remove an entire menu section exports['onex-radialmenu']:onexRemoveRadialItem('vehicle_menu')
Clear All Items: clearRadialItems#
exports['onex-radialmenu']:clearRadialItems()
This removes all items from the radial menu.
Toggle Access: disableRadial#
exports['onex-radialmenu']:disableRadial(toggle)
Parameters:
- toggle (boolean):
true
to disable,false
to enable
Example:
-- Disable the radial menu exports['onex-radialmenu']:disableRadial(true) -- Re-enable the radial menu exports['onex-radialmenu']:disableRadial(false)
Use this to temporarily restrict access during specific game states or animations.
Troubleshooting#
- Nothing shows up: confirm your ids are unique and your item has title, closeRadialMenu, and icon.
- Events don’t fire: check event.name and type ('client' or 'server'), and verify the handler exists.
- Icons don’t render: ensure FontAwesome is available or use an image URL in icon.address.
- Menu won’t open: verify your keybind and that disableRadial(false) is set.