mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
4.0 KiB
4.0 KiB
title
| title |
|---|
| Radial Menu |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
lib.addRadialItem
Item or array of items added to the global radial menu.
lib.addRadialItem(items)
import lib from '@overextended/ox_lib/client'
lib.addRadialItem(items)
- id:
string- Id that is used for removing options.
- icon:
string - label:
string - menu?:
string- Id of a menu to open.
- onSelect:
function
lib.removeRadialItem
Id of an item to be removed from the global menu.
lib.removeRadialItem(item)
import lib from '@overextended/ox_lib/client'
lib.removeRadialItem(item)
- id:
string
lib.registerRadial
Registers a radial sub menu with predefined options.
lib.registerRadial(radial)
import lib from '@overextended/ox_lib/client'
lib.registerRadial(radial)
- id:
string- Unique menu id used to open with
menuprop on an item.
- Unique menu id used to open with
- items:
array- icon:
string - label:
string - menu?:
string- Id of a menu to open.
- onSelect?:
function
- icon:
lib.hideRadial
Hides the radial menu if one is open.
lib.hideRadial()
import lib from '@overextended/ox_lib/client'
lib.hideRadial()
Usage Example
:::tip
When adding radial menu items whether they are global or for a sub menu, make sure to stick to short as possible labels as long labels will look out of place and should not be used with the radial menu because of it's density. :::
Here's a use case example with some global options and an option utilising the lib's points system.
lib.registerRadial({
id = 'police_menu',
items = {
{
label = 'Handcuff',
icon = 'handcuffs',
onSelect = function()
print('Handcuffs')
end
},
{
label = 'Frisk',
icon = 'hand'
},
{
label = 'Fingerprint',
icon = 'fingerprint'
},
{
label = 'Jail',
icon = 'bus'
},
{
label = 'Search',
icon = 'magnifying-glass',
onSelect = function()
print('Search')
end
}
}
})
lib.addRadialItem({
{
id = 'police',
label = 'Police',
icon = 'shield-halved',
menu = 'police_menu'
},
{
id = 'business_stuff',
label = 'Business',
icon = 'briefcase',
onSelect = function()
print("Business")
end
}
})
local coords = GetEntityCoords(cache.ped)
local point = lib.points.new(coords, 5)
function point:onEnter()
lib.addRadialItem({
id = 'garage_access',
icon = 'warehouse',
label = 'Garage',
onSelect = function()
print('Garage')
end
})
end
function point:onExit()
lib.removeRadialItem('garage_access')
end
:::caution
Points system in the lib isn't available for the npm package. :::
import lib from '@overextended/ox_lib/client'
lib.registerRadial({
id: 'police_menu',
items: [
{
label: 'Handcuff',
icon: 'handcuffs',
onSelect: () => {
console.log('Handcuffs')
}
},
{
label: 'Frisk',
icon: 'hand'
},
{
label: 'Fingerprint',
icon: 'fingerprint'
},
{
label: 'Jail',
icon: 'bus'
},
{
label: 'Search',
icon: 'magnifying-glass',
onSelect: () => {
console.log('Search')
}
}
]
})
lib.addRadialItem([
{
id: 'police',
label: 'Police',
icon: 'shield-halved',
menu: 'police_menu'
},
{
id: 'business_stuff',
label: 'Business',
icon: 'briefcase',
onSelect: () => {
console.log('Business')
}
}
])

