mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
14 files changed
+769
-330
No files matched your search
@@ -1,18 +1,50 @@
|
||||
Registers commands and simplifies argument validation, permissions, and chat suggestions.
|
||||
|
||||
```lua
|
||||
lib.addCommand(principal, command, callback, parameters, help)
|
||||
lib.addCommand(commandName, properties, cb)
|
||||
```
|
||||
|
||||
* principal: `string` or `string[]` or `false`
|
||||
* command: `string`
|
||||
* callback: `function`
|
||||
* parameters?: `table` (`array`)
|
||||
* help?: `string`
|
||||
- commandName: `string` or `string[]`
|
||||
- properties: `table` or `false`
|
||||
- help?: `string`
|
||||
- restricted?: `boolean` or `string` or `string[]`
|
||||
- params?: `table[]`
|
||||
- name: `string`
|
||||
- help?: `string`
|
||||
- type?: `'number'` or `'playerId'` or `'string'`
|
||||
- optional?: `boolean`
|
||||
|
||||
```lua
|
||||
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
|
||||
args.item = Items(args.item)
|
||||
if args.item and args.count > 0 then
|
||||
Inventory.AddItem(args.target, args.item.name, args.count, args.metatype)
|
||||
lib.addCommand('giveitem', {
|
||||
help = 'Gives an item to a player',
|
||||
params = {
|
||||
{
|
||||
name = 'target',
|
||||
type = 'playerId',
|
||||
help = 'Target player\'s server id', },
|
||||
{
|
||||
name = 'item',
|
||||
type = 'string',
|
||||
help = 'Name of the item to give',
|
||||
},
|
||||
{
|
||||
name = 'count',
|
||||
type = 'number',
|
||||
help = 'Amount of the item to give, or blank to give 1',
|
||||
optional = true,
|
||||
},
|
||||
{
|
||||
name = 'metatype',
|
||||
help = 'Sets the item\'s "metadata.type"',
|
||||
optional = true,
|
||||
},
|
||||
},
|
||||
restricted = 'group.admin'
|
||||
}, function(source, args, raw)
|
||||
local item = Items(args.item)
|
||||
|
||||
if item then
|
||||
Inventory.AddItem(args.target, item.name, args.count or 1, args.metatype)
|
||||
end
|
||||
end, {'target:number', 'item:string', 'count:number', 'metatype:?string'})
|
||||
end)
|
||||
```
|
||||
@@ -42,6 +42,8 @@ lib.alertDialog(data)
|
||||
* Centers the dialog vertically and horizontally.
|
||||
* cancel?: `boolean`
|
||||
* Displays a cancel button (ESC is still available if this is not defined).
|
||||
* size?: `'xs'` or `'sm'` or `'md'` or `'lg'` or `'xl'`
|
||||
* overflow?: `boolean`
|
||||
* labels?: `table`
|
||||
* Allows you to define the displayed labels for cancel and/or confirm buttons.
|
||||
* cancel?: `string`
|
||||
@@ -108,4 +110,4 @@ console.log(alert)
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -5,10 +5,17 @@ title: Clipboard
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
|
||||
|
||||
### lib.setClipboard
|
||||
|
||||
Sets the player's clipboard to the specified string value.
|
||||
|
||||
:::caution
|
||||
|
||||
Will not work if focus is already taken by some NUI component.
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
|
||||
@@ -52,13 +52,15 @@ lib.registerContext(context)
|
||||
* Function that's ran when the button is clicked.
|
||||
* icon?: `string`
|
||||
* FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons.
|
||||
* Also supports image urls, png and webp files but are not recommend to use over font awesome icons.
|
||||
* iconColor?: `string`
|
||||
* Colour of the displayed icon.
|
||||
* progress?: `number`
|
||||
* Adds a progress bar filled to this percentage
|
||||
* colorScheme?: `string`
|
||||
* Sets the color scheme of the progress bar. Current options available are:
|
||||
* `whiteAlpha`, `blackAlpha`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `cyan`, `purple`, `pink`
|
||||
* Sets the color scheme of the progress bar. Current options can be found here:
|
||||
* https://mantine.dev/theming/colors/#default-colors
|
||||
* For example: `blue` or `teal`
|
||||
* arrow?: `boolean`
|
||||
* Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it.
|
||||
* description?: `string`
|
||||
@@ -67,6 +69,10 @@ lib.registerContext(context)
|
||||
* Url to an image that will be displayed in the button's metadata.
|
||||
* metadata?: `string[]` or `object` or `array`
|
||||
* Information that will display on the side upon hovering a button.
|
||||
* label: `string`
|
||||
* value: `any`
|
||||
* progress?: `number`
|
||||
* Display a progress bar in the metadata.
|
||||
* event?: `string`
|
||||
* Event that the button is going to trigger.
|
||||
* serverEvent?: `string`
|
||||
@@ -169,182 +175,217 @@ Avoid constantly re-registering a menu that does not depend on any outside value
|
||||
|
||||
```lua
|
||||
lib.registerContext({
|
||||
id = 'example_menu',
|
||||
title = 'Example Context',
|
||||
onExit = function()
|
||||
print('Hello there')
|
||||
end,
|
||||
options = {
|
||||
{title = 'Empty button'},
|
||||
{
|
||||
title = 'Example button',
|
||||
description = 'Example button description',
|
||||
onSelect = function(args)
|
||||
print('Pressed the button!')
|
||||
end,
|
||||
metadata = {
|
||||
{label = 'Value 1', value = 'Some value'},
|
||||
{label = 'Value 2', value = 300},
|
||||
}
|
||||
},
|
||||
{
|
||||
title = 'Menu button',
|
||||
menu = 'other_example_menu',
|
||||
description = 'Takes you to another menu!',
|
||||
metadata = {'It also has metadata support'}
|
||||
},
|
||||
{
|
||||
title = 'Event button',
|
||||
description = 'Open a menu and send event data',
|
||||
arrow = true,
|
||||
event = 'some_event',
|
||||
args = {value1 = 300, value2 = 'Other value'}
|
||||
}
|
||||
id = 'some_menu',
|
||||
title = 'Some context menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Empty button',
|
||||
},
|
||||
{
|
||||
id = 'other_example_menu',
|
||||
title = 'Other Context Menu',
|
||||
menu = 'example_menu',
|
||||
options = {
|
||||
['Nothing here'] = {}
|
||||
}
|
||||
title = 'Disabled button',
|
||||
description = 'This button is disabled',
|
||||
icon = 'hand',
|
||||
disabled = true
|
||||
},
|
||||
{
|
||||
title = 'Example button',
|
||||
description = 'Example button description',
|
||||
icon = 'circle',
|
||||
onSelect = function()
|
||||
print("Pressed the button!")
|
||||
end,
|
||||
metadata = {
|
||||
{label = 'Value 1', value = 'Some value'},
|
||||
{label = 'Value 2', value = 300}
|
||||
},
|
||||
},
|
||||
{
|
||||
title = 'Menu button',
|
||||
description = 'Takes you to another menu!',
|
||||
menu = 'other_menu',
|
||||
icon = 'bars'
|
||||
},
|
||||
{
|
||||
title = 'Event button',
|
||||
description = 'Open a menu from the event and send event data',
|
||||
icon = 'check',
|
||||
event = 'test_event',
|
||||
arrow = true,
|
||||
args = {
|
||||
someValue = 500
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
```lua
|
||||
RegisterCommand('testcontext', function()
|
||||
lib.showContext('example_menu')
|
||||
end)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
```
|
||||
|
||||
```ts
|
||||
lib.registerContext([
|
||||
{
|
||||
id: 'example_menu',
|
||||
title: 'Example Context',
|
||||
onExit: () => {
|
||||
console.log('Hello there');
|
||||
lib.registerContext({
|
||||
id: 'some_menu',
|
||||
title: 'Some context menu',
|
||||
options: [
|
||||
{
|
||||
title: 'Empty button',
|
||||
},
|
||||
options: [
|
||||
{ title: 'Empty button' },
|
||||
{
|
||||
title: 'Example button',
|
||||
description: 'Example button description',
|
||||
onSelect: (args) => {
|
||||
console.log('Pressed the button!');
|
||||
},
|
||||
metadata: [
|
||||
{ label: 'Value 1', value: 'Some value' },
|
||||
{ label: 'Value 2', value: 300 },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Menu button',
|
||||
menu: 'other_example_menu',
|
||||
description: 'Takes you to another menu!',
|
||||
metadata: ['It also has metadata support'],
|
||||
},
|
||||
{
|
||||
title: 'Event button',
|
||||
description: 'Open a menu and send event data',
|
||||
arrow: true,
|
||||
event: 'some_event',
|
||||
args: { value1: 300, value2: 'Other value' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'other_example_menu',
|
||||
title: 'Other Context Menu',
|
||||
menu: 'example_menu',
|
||||
options: {
|
||||
['Nothing here']: {},
|
||||
{
|
||||
title: 'Disabled button',
|
||||
description: 'This button is disabled',
|
||||
icon: 'hand',
|
||||
disabled: true
|
||||
},
|
||||
},
|
||||
]);
|
||||
{
|
||||
title: 'Example button',
|
||||
description: 'Example button description',
|
||||
icon: 'circle',
|
||||
onSelect: () => {
|
||||
console.log("Pressed the button!")
|
||||
},
|
||||
metadata: [
|
||||
{label: 'Value 1', value: 'Some value'},
|
||||
{label: 'Value 2', value: 300}
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Menu button',
|
||||
description: 'Takes you to another menu!',
|
||||
menu: 'other_menu',
|
||||
icon: 'bars'
|
||||
},
|
||||
{
|
||||
title: 'Event button',
|
||||
description: 'Open a menu from the event and send event data',
|
||||
icon: 'check',
|
||||
event: 'test_event',
|
||||
arrow: true,
|
||||
args: {
|
||||
someValue: 500
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
```ts
|
||||
RegisterCommand('testcontext', () => {
|
||||
lib.showContext('example_menu')
|
||||
}, false)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
To trigger the event from the `Event button` and get it's data we first need to register the event properly:
|
||||
Then we can also register our second menu called `other_menu`
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('some_event', function(data)
|
||||
print(json.encode(data, {indent=true}))
|
||||
lib.registerContext({
|
||||
id = 'another_context_menu',
|
||||
title = 'Event Menu',
|
||||
menu = 'example_menu',
|
||||
options = {
|
||||
['Menu data'] = {
|
||||
description = 'Data from the previous menu',
|
||||
metadata = {
|
||||
['Value1'] = data.value1,
|
||||
['Value2'] = data.value2
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
lib.showContext('another_context_menu')
|
||||
end)
|
||||
lib.registerContext({
|
||||
id = 'other_menu',
|
||||
title = 'Other context menu',
|
||||
menu = 'some_menu',
|
||||
onBack = function()
|
||||
print('Went back!')
|
||||
end,
|
||||
options = {
|
||||
{
|
||||
title = 'Nothing here'
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
onNet('some_event', () => {
|
||||
console.log(JSON.stringify(data, null, 2))
|
||||
lib.registerContext({
|
||||
id: 'another_context_menu',
|
||||
title: 'Event Menu',
|
||||
menu: 'example_menu',
|
||||
options: {
|
||||
['Menu data']: {
|
||||
description: 'Data from the previous menu',
|
||||
metadata: {
|
||||
['Value1']: data.value1,
|
||||
['Value2']: data.value2,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
lib.showContext('another_context_menu');
|
||||
});
|
||||
lib.registerContext({
|
||||
id: 'other_menu',
|
||||
title: 'Other context menu',
|
||||
menu: 'some_menu',
|
||||
onBack: () => {
|
||||
console.log('Went back!')
|
||||
},
|
||||
options: [
|
||||
{
|
||||
title: 'Nothing here'
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The data from the `args` table in the menu is passed as a first argument to the event you register, in this case that argument is called `data`.
|
||||
And the event that we are going to run from the `some_menu` menu, which is going to open another menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('test_event', function(args)
|
||||
lib.registerContext({
|
||||
id = 'event_menu',
|
||||
title = 'Event menu',
|
||||
menu = 'some_menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Event value: '..args.someValue,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lib.showContext('event_menu')
|
||||
end)
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
onNet('test_event', (args: {someValue: number}) => {
|
||||
lib.registerContext({
|
||||
id:'event_menu',
|
||||
title:'Event menu',
|
||||
menu:'some_menu',
|
||||
options: [
|
||||
{
|
||||
title: `Event value: ${args.someValue}`,
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
lib.showContext('event_menu')
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
Lastly we register a test command to show the `some_menu` menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
RegisterCommand('testcontext', function()
|
||||
lib.showContext('some_menu')
|
||||
end)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
RegisterCommand('testcontext', () => {
|
||||
lib.showContext('some_menu')
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The data from the `args` table in the menu is passed as a first argument to the event you register.
|
||||
|
||||
Using this event we also register a new context menu with it's own options.
|
||||
|
||||
By defining a `menu` param to be the id of the first menu we can get the neat back arrow button next to the menu title that will take us back.
|
||||
By defining a `menu` param to be the id of the first menu we can get the back arrow button next to the menu title that will take us back.
|
||||
|
||||
If we have a button that does not define either event, serverEvent or menu the button will do nothing upon being clicked.
|
||||
|
||||
Of course just registering the event won't do much so we need to display it with the `lib.showContext` function, passing in the menu's id.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
@@ -23,7 +23,7 @@ lib.inputDialog(heading, rows)
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.inputDialog(heading, rows)
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -31,50 +31,130 @@ lib.inputDialog(heading, rows)
|
||||
|
||||
* heading: `string`
|
||||
* rows: `string[]` or `table` (`array`)
|
||||
* type: `'input'` or `'number'` or `'checkbox'` or `'select'` or `'slider'`
|
||||
* type: `'input'` or `'number'` or `'checkbox'` or `'select'` or `'slider'` or `'color'` or `'multi-select'` or `'date'` or `'date-range'` or `'time'` or `'textarea'`
|
||||
* options?: `table`(`object`)
|
||||
* allowCancel: `boolean`
|
||||
* If true the user will not be able to cancel and close the input dialog until submitted.
|
||||
|
||||
Available properties per field type:
|
||||
|
||||
* input
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* If set will show a ? near the label a user can hover over and the description.
|
||||
* options?: `table` (`array`)
|
||||
* [ Only used with `'select'` type ]
|
||||
* value: `string`
|
||||
* label: `string`
|
||||
* password?: `boolean`
|
||||
* Hides input characters with ability to toggle them on. Used only with `'input'` type.
|
||||
* icon?: `string`
|
||||
* Used only with `'input'` and `'number'` types.
|
||||
* placeholder?: `string`
|
||||
* Used only with `'input'` and `'number'` types.
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* Should the field be disabled from input.
|
||||
* default?: `string` or `number`
|
||||
* Default value for the field.
|
||||
* default?: `string`
|
||||
* password?: `boolean`
|
||||
|
||||
* number
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* max?: `number`
|
||||
|
||||
* checkbox
|
||||
* label: `string`
|
||||
* checked?: `boolean`
|
||||
* Whether the checkbox should be checked by default. Used only with `'checkbox'` type.
|
||||
* disabled?: `boolean`
|
||||
* required?: `boolean`
|
||||
|
||||
* select and multi-select
|
||||
* label: `string`
|
||||
* options: `table`(`array`)
|
||||
* value: `string`
|
||||
* label?: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* value of the default option.
|
||||
* clearable?: `boolean`
|
||||
|
||||
* slider
|
||||
* label: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* Used only with `'slider'` and `'number'` types.
|
||||
* max?: `number`
|
||||
* Used only with `'slider'` and `'number'` types.
|
||||
* step?: `number`
|
||||
* Amount of change per slider step. Used only with `'slider'` type.
|
||||
|
||||
* color
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* format?: `'hex'` | `'hexa'` | `'rgb'` | `'rgba'` | `'hsl'` | `'hsla'`;
|
||||
|
||||
* date
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string` or `true`
|
||||
* True defaults to current date
|
||||
* format?: `string`
|
||||
* Date format to display in the field
|
||||
* clearable?: `boolean`
|
||||
|
||||
* date-range
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `[string, string]`
|
||||
* format?: `string`
|
||||
* Date format to display in the field
|
||||
* clearable?: `boolean`
|
||||
|
||||
* time
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* format?: `'12'` or `'24'`
|
||||
* clearable?: `boolean`
|
||||
|
||||
* textarea
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* Minimum amount of rows the text area will take.
|
||||
* max?: `number`
|
||||
* Maxmimum amount of rows the text area will take, when exceeded goes into overflow.
|
||||
* autosize?: `boolean`
|
||||
* If true text area will grow with content until max rows are reached.
|
||||
|
||||
The callback data is promise based meaning that the thread will not continue executing until the user either sends the data or exits the popup.
|
||||
|
||||
The data returned will be a table (array), indexes represent the rows sent to the dialog, so if we want data from the first field that would be index `1` (`0`), if we want data from the third field, that would be index `3` (`2`), etc...
|
||||
|
||||
The standard input rows will always return a string, if you want a row to be of number data type, you can use set the `type` to `number`.
|
||||
|
||||
If a user left an input field empty it will return `nil`.
|
||||
|
||||
You can also add checkboxes that will return `true` if checked and `nil` if unchecked.
|
||||
Look at the *Advanced* example for it's usage.
|
||||
|
||||
:::caution
|
||||
|
||||
When using the advanced method you can define `icon` and `password` **ONLY** with type `'input'` and `'number'` and
|
||||
you can define `options` **ONLY** with type `'select'`.
|
||||
|
||||
Doing so otherwise ***will*** result in errors.
|
||||
Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value.
|
||||
:::
|
||||
|
||||
### lib.closeInputDialog
|
||||
@@ -108,13 +188,10 @@ lib.closeInputDialog()
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'})
|
||||
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
|
||||
|
||||
if not input then return end
|
||||
local lockerNumber = tonumber(input[1])
|
||||
local lockerPasscode = input[2]
|
||||
|
||||
print(lockerNumber, lockerPasscode)
|
||||
print(input, input[1], input[2])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -126,19 +203,16 @@ This function is **asynchronous** requiring you to do a `.then` callback on the
|
||||
:::
|
||||
|
||||
```ts
|
||||
const input = await lib.inputDialog('Police locker', ['Locker number', 'Locker passcode'])
|
||||
const input = await lib.inputDialog('Basic dialog', ['First row', 'Second row'])
|
||||
|
||||
if (!input) return
|
||||
const lockerNumber = input[0] as number
|
||||
const lockerPasscode = input[1] as number
|
||||
|
||||
console.log(lockerNumber, lockerPasscode)
|
||||
console.log(input, input[0], input[1])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
|
||||
### Advanced
|
||||
|
||||
@@ -146,20 +220,15 @@ console.log(lockerNumber, lockerPasscode)
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Police locker', {
|
||||
{ type = "input", label = "Locker number", placeholder = "123" },
|
||||
{ type = "checkbox", label = "Some checkbox" },
|
||||
{ type = "input", label = "Locker PIN", password = true, icon = 'lock' },
|
||||
{ type = "checkbox", label = "Some other checkbox", checked = true },
|
||||
{ type = 'select', label = 'Value select', options = {
|
||||
{ value = 'option1', label = 'Option 1' },
|
||||
{ value = 'option2', label = 'Option 2' },
|
||||
{ value = 'option3', label = 'Option 3'},
|
||||
}},
|
||||
{ type = "number", label = "Number counter", default = 12 }
|
||||
local input = lib.inputDialog('Dialog title', {
|
||||
{type = 'input', label = 'Text input', description = 'Some input description'},
|
||||
{type = 'number', label = 'Number input', description = 'Some number desrciption', icon = 'hashtag'},
|
||||
{type = 'checkbox', label = 'Simple checkbox'},
|
||||
{type = 'color', label = 'Colour input', default = '#eb4034'},
|
||||
{type = 'date', label = 'Date input', icon = {'far', 'calendar'}, default = true, format = "DD/MM/YYYY"}
|
||||
})
|
||||
|
||||
print(json.encode(input, {indent=true}))
|
||||
print(json.encode(input))
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -172,16 +241,11 @@ This function is **asynchronous** requiring you to do a `.then` callback on the
|
||||
|
||||
```ts
|
||||
const input = await lib.inputDialog('Police locker', [
|
||||
{ type: 'input', label: 'Locker number', placeholder: '123' },
|
||||
{ type: 'checkbox', label: 'Some checkbox' },
|
||||
{ type: 'input', label: 'Locker PIN', password: true, icon: 'lock' },
|
||||
{ type: 'checkbox', label: 'Some other checkbox', checked: true },
|
||||
{ type: 'select', label: 'Value select', options: [
|
||||
{ value: 'option1', label: 'Option 1' },
|
||||
{ value: 'option2', label: 'Option 2' },
|
||||
{ value: 'option3', label: 'Option 3' },
|
||||
]},
|
||||
{ type: 'number', label: 'Number counter', default: 12 },
|
||||
{type: 'input', label: 'Text input', description: 'Some input description'},
|
||||
{type: 'number', label: 'Number input', description: 'Some number desrciption', icon: 'hashtag'},
|
||||
{type: 'checkbox', label: 'Simple checkbox'},
|
||||
{type: 'color', label: 'Colour input', default: '#eb4034'},
|
||||
{type: 'date', label: 'Date input', icon: ['far', 'calendar'], default: true, format: "DD/MM/YYYY"}
|
||||
]);
|
||||
|
||||
console.log(JSON.stringify(input, null, 2));
|
||||
@@ -190,4 +254,4 @@ console.log(JSON.stringify(input, null, 2));
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
 
|
||||

|
||||
@@ -38,6 +38,8 @@ lib.registerMenu(data, cb)
|
||||
* progress?: `number`
|
||||
* colorScheme?: `string`
|
||||
* icon?: `string`
|
||||
* FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons.
|
||||
* Also supports image urls, png and webp files but are not recommend to use over font awesome icons.
|
||||
* iconColor?: `string`
|
||||
* values?: `table` (`Array<string | {label: string; description: string}>`)
|
||||
* If provided creates a side scrollable list.
|
||||
@@ -309,5 +311,4 @@ RegisterCommand('testmenu', () => {
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||

|
||||
@@ -5,7 +5,7 @@ title: Notifications
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## lib.notify
|
||||
### lib.notify
|
||||
|
||||
Custom notifications with a lot of styling options.
|
||||
|
||||
@@ -33,9 +33,10 @@ lib.notify(data)
|
||||
* title?: `string`
|
||||
* Must provide if there is no description
|
||||
* description?: `string`
|
||||
* Must provide if there is no title; has markdown support.
|
||||
* Must provide if there is no title
|
||||
* Markdown support
|
||||
* duration?: `number`
|
||||
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
|
||||
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'` or `'center-right'` or `'center-left'`
|
||||
* Default: `'top-right'`
|
||||
* type?: `'inform'` or `'error'` or `'success'`
|
||||
* Default: `'inform'`
|
||||
@@ -45,6 +46,11 @@ lib.notify(data)
|
||||
* Font Awesome 6 icon name
|
||||
* iconColor: `string`
|
||||
|
||||
:::caution
|
||||
|
||||
Setting `iconColor` will get rid of the contrasted icon colour and it's circular background.
|
||||
:::
|
||||
|
||||
### Usage Example
|
||||
|
||||
#### Standard
|
||||
@@ -76,7 +82,7 @@ lib.notify({
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
|
||||
#### Custom
|
||||
|
||||
@@ -121,68 +127,4 @@ lib.notify({
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
## lib.defaultNotify
|
||||
|
||||
Default notifications provided by Chakra UI.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.defaultNotify(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.defaultNotify(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id?: `number`
|
||||
* Same as id in `lib.notify`
|
||||
* title?: `string`
|
||||
* description?: `string`
|
||||
* duration?: `number`
|
||||
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
|
||||
* variant?: `'solid'` or `'subtle'` or `'left-accent'` or `'top-accent'`
|
||||
* status?: `'info'` or `'warning'` or `'success'` or `'error'`
|
||||
|
||||
### Usage Example
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.defaultNotify({
|
||||
title = 'Notification title',
|
||||
description = 'Notification description',
|
||||
variant = 'left-accent',
|
||||
status = 'success'
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.defaultNotify({
|
||||
title: 'Notification title',
|
||||
description: 'Notification description',
|
||||
status: 'success'
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -135,7 +135,7 @@ else console.log('Do stuff when cancelled')
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
|
||||
## lib.progressCircle
|
||||
|
||||
@@ -269,7 +269,7 @@ else console.log('Do stuff when cancelled')
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
|
||||
## lib.progressActive
|
||||
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
---
|
||||
title: Radial Menu
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
* Radial menu has a global menu that's by default accessed with `z` and only displays when there is at least one item.
|
||||
* You can add and remove items from the global menu using `lib.addRadialItem` and `lib.removeRadialItem`.
|
||||
* Use `lib.registerRadial` for creating sub menus and use the `menu` property on the items to open those sub menus.
|
||||
|
||||
### lib.addRadialItem
|
||||
|
||||
Item or array of items added to the global radial menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
* Id that is used for removing options.
|
||||
* icon: `string`
|
||||
* label: `string`
|
||||
* menu?: `string`
|
||||
* Id of a menu to open.
|
||||
* onSelect: `function(currentMenu: string | nil, itemIndex: number)` | `string`
|
||||
* Function that's ran when a user clicks the item.
|
||||
|
||||
### lib.removeRadialItem
|
||||
|
||||
Id of an item to be removed from the global menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
|
||||
### lib.registerRadial
|
||||
|
||||
Registers a radial sub menu with predefined options.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
* Unique menu id used to open with `menu` prop on an item.
|
||||
* items: `array`
|
||||
* icon: `string`
|
||||
* label: `string`
|
||||
* menu?: `string`
|
||||
* Id of a menu to open.
|
||||
* onSelect?: `function(currentMenu: string | nil, itemIndex: number)` | `string`
|
||||
* Function that's ran when a user clicks the item.
|
||||
|
||||
### lib.hideRadial
|
||||
|
||||
Hides the radial menu if one is open.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.hideRadial()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideRadial()
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 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.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
exports('myMenuHandler', function(menu, item)
|
||||
print(menu, item)
|
||||
|
||||
if menu == 'police_menu' and item == 1 then
|
||||
print('Handcuffs')
|
||||
end
|
||||
end)
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'police_menu',
|
||||
items = {
|
||||
{
|
||||
label = 'Handcuff',
|
||||
icon = 'handcuffs',
|
||||
onSelect = 'myMenuHandler'
|
||||
},
|
||||
{
|
||||
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
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
:::caution
|
||||
|
||||
Points system in the lib isn't available for the npm package.
|
||||
:::
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
exports('myMenuHandler', (menu, item) => {
|
||||
console.log(menu, item)
|
||||
|
||||
if (menu === 'police_menu' and item === 1) {
|
||||
console.log('Handcuffs')
|
||||
}
|
||||
})
|
||||
|
||||
lib.registerRadial({
|
||||
id: 'police_menu',
|
||||
items: [
|
||||
{
|
||||
label: 'Handcuff',
|
||||
icon: 'handcuffs',
|
||||
onSelect: 'myMenuHandler'
|
||||
},
|
||||
{
|
||||
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')
|
||||
}
|
||||
}
|
||||
])
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -13,7 +13,7 @@ Runs a skill check with the defined difficulty.
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.skillCheck(difficulty)
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -22,7 +22,7 @@ lib.skillCheck(difficulty)
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.skillCheck(difficulty)
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -36,6 +36,8 @@ lib.skillCheck(difficulty)
|
||||
* hard: { areaSize: 25, speedMultiplier: 1.75 }
|
||||
* `areaSize` size of the area in degrees.
|
||||
* Sending an array will chain the checks together and return false if one fails and true if all succeed
|
||||
* inputs: `string[]`
|
||||
* Picks a random key from the inputs table to use on each skill check pass.
|
||||
|
||||
### Usage Example
|
||||
|
||||
@@ -43,7 +45,7 @@ lib.skillCheck(difficulty)
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'})
|
||||
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -52,10 +54,10 @@ local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard'])
|
||||
const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard'], ['w', 'a', 's', 'd'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -5,11 +5,14 @@ title: TextUI
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## lib.showTextUI
|
||||
### lib.showTextUI
|
||||
|
||||
Show the TextUI window.
|
||||
|
||||
**DO NOT** run this every tick, it's intended to be used as a toggle.
|
||||
:::danger
|
||||
|
||||
**DO NOT** run this function every tick, it's intented to be used as a toggle.
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
@@ -38,9 +41,32 @@ lib.showTextUI(text, options)
|
||||
* iconColor?: `string`
|
||||
* style?: React.CSSProperties
|
||||
|
||||
### lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
### Basic
|
||||
#### Basic
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
@@ -61,9 +87,9 @@ lib.showTextUI('[E] - Fuel vehicle')
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
|
||||
### Custom styling
|
||||
#### Custom styling
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
@@ -100,27 +126,4 @@ lib.showTextUI('[E] - Pick apple', {
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
### lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||

|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Interface
|
||||
---
|
||||
|
||||
If you wish to change the primary colour for the UI to better match your server's theme you can do so easily through the available convars.
|
||||
|
||||
They don't require you to build the UI, just restart the resource.
|
||||
|
||||
Convars:
|
||||
|
||||
```yaml
|
||||
set ox:primaryColor blue
|
||||
set ox:primaryShade 8
|
||||
```
|
||||
|
||||
Changing the primary colour will change the colour in elements such as the progress bar/circle, skill check, radial menu center button and hover,
|
||||
dialog confirm buttons, input field focus, and more.
|
||||
|
||||
You can find the full list of preset colours and shades here:
|
||||
|
||||
https://mantine.dev/theming/colors/#default-colors
|
||||
|
||||
If you wish to create your own pallete I suggest following the guide on that page.
|
||||
Keep in mind doing so *will* require you to download the source code and build the UI.
|
||||
@@ -0,0 +1,46 @@
|
||||
# Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
```ts
|
||||
Point<T>({coords, distance, onEnter, onExit, nearby, args})
|
||||
```
|
||||
|
||||
* coords: `number[]`
|
||||
* distance: `number`
|
||||
* onEnter?: `function`
|
||||
* onExit?: `function`
|
||||
* nearby?: `function`
|
||||
* args?: `T`
|
||||
|
||||
```ts
|
||||
import { Point, cache } from '@overextended/ox_lib/client'
|
||||
|
||||
function nearby(this: Point<{dunak: string}>) {
|
||||
// @ts-ignore
|
||||
DrawMarker(2, this.coords.x, this.coords.y, this.coords.z, 0, 0, 0, 0, 180, 0, 1, 1, 1, 200, 20, 20, 50, false, true, 2, null, null, false, false)
|
||||
|
||||
if (this.currentDistance && this.currentDistance < 1 && IsControlJustReleased(0, 38)) {
|
||||
console.log('Inside marker', this.id)
|
||||
console.log(this.args?.dunak)
|
||||
}
|
||||
}
|
||||
|
||||
const point = new Point({
|
||||
coords: GetEntityCoords(cache.ped, false),
|
||||
distance: 5,
|
||||
nearby: nearby,
|
||||
args: {
|
||||
dunak: 'nerd'
|
||||
}
|
||||
})
|
||||
|
||||
point.onEnter = () => {
|
||||
console.log('Entered range of point', point.id)
|
||||
}
|
||||
|
||||
point.onExit = () => {
|
||||
console.log('Left range of point', point.id)
|
||||
}
|
||||
```
|
||||
|
||||
File renamed without changes.
Reference in new issue
Block a user