mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
new docs
This commit is contained in:
1 parent
3cebaf7fa5
commit
b5eba8423f
229 files changed
+6238
-10690
No files matched your search
@@ -0,0 +1,126 @@
|
||||
---
|
||||
title: Alert Dialog
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
Simple alert dialog that can display a message to the player.
|
||||
Returns whether the player pressed the confirm button or canceled the dialog.
|
||||
|
||||
### lib.alertDialog
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
<Tabs items={["Client", "Server"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.alertDialog(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
TriggerClientEvent('ox_lib:alertDialog', source, data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
</Callout>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.alertDialog(data);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- data: `table` (`object`)
|
||||
- header: `string`
|
||||
- Dialog title.
|
||||
- content: `string`
|
||||
- Dialog body content, supports markdown.
|
||||
- centered?: `boolean`
|
||||
- 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`
|
||||
- confirm?: `string`
|
||||
|
||||
Returns `confirm` if the player pressed the confirm button, otherwise if the player pressed the cancel button
|
||||
or has exited the dialog with ESC the return will be `cancel`.
|
||||
|
||||
### lib.closeAlertDialog
|
||||
|
||||
Force closes the active alert dialog and sets its return data as `nil`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.closeAlertDialog();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
**Example:**
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local alert = lib.alertDialog({
|
||||
header = 'Hello there',
|
||||
content = 'General Kenobi \n Markdown support!',
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
print(alert)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
const alert = await lib.alertDialog({
|
||||
header: 'Hello there',
|
||||
content: 'General Kenobi \n Markdown support!',
|
||||
centered: true,
|
||||
cancel: true,
|
||||
});
|
||||
|
||||
console.log(alert);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Clipboard
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.setClipboard
|
||||
|
||||
Sets the player's clipboard to the specified string value.
|
||||
|
||||
<Callout>
|
||||
|
||||
Will not work if focus is already taken by some NUI component.
|
||||
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
|
||||
To create a new line use `\t\n` not just `\n` in your string.
|
||||
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setClipboard(value);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- value: `string`
|
||||
@@ -0,0 +1,398 @@
|
||||
---
|
||||
title: Context Menu
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.registerContext
|
||||
|
||||
Used for registering a context menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerContext(context)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerContext(context);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
- Unique menu identifier, will be used to open the menu.
|
||||
- title: `string`
|
||||
- Title display in the menu; has markdown support.
|
||||
- menu?: `string`
|
||||
- Menu identifier - if defined there will be a back arrow next to the menu title that will take you to the menu you defined.
|
||||
- canClose: `boolean`
|
||||
- If set to false the user won't be able to exit the menu without pressing one of the buttons.
|
||||
- onExit?: `function`
|
||||
- Function that will be ran when the user closes their context menu with ESC.
|
||||
- onBack?: `function`
|
||||
- Function that will be ran when the user presses the back button to return to a previous menu.
|
||||
- options: `table` (`object` or `array`)
|
||||
- item: `key` (`string`) or `table` (`object`)
|
||||
- title?: `string`
|
||||
- If not using keys then sets the title for the button; has markdown support.
|
||||
- disabled?: `boolean`
|
||||
- Grays out the button and makes it unclickable.
|
||||
- menu?: `string`
|
||||
- Menu identifier that the button will take you to, when defined an arrow.
|
||||
- onSelect: `function`
|
||||
- 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 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`
|
||||
- Description that will appear under the button title that is defined as a key; has markdown support.
|
||||
- image?: `string`
|
||||
- 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`
|
||||
- Server event that the button is going to trigger.
|
||||
- args?: `any`
|
||||
- Arguments that will be sent to the events or onSelect function.
|
||||
|
||||
You can register as many context menus in one `lib.registerContext` function
|
||||
as you'd like.
|
||||
|
||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
||||
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys, otherwise not using keys and instead using tables will make the menu be in the order you define it as.
|
||||
|
||||
### lib.showContext
|
||||
|
||||
Opens a registered context menu by its id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showContext(id);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.hideContext
|
||||
|
||||
Hides any currently visible context menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.hideContext(onExit)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideContext(onExit);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- onExit: `boolean`
|
||||
- Defines whether the onExit function for the menu should be ran or not.
|
||||
|
||||
### lib.getOpenContextMenu
|
||||
|
||||
Returns the id of the currently open context menu.
|
||||
|
||||
If no context menu is open returns `nil`.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.getOpenContextMenu();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
<Callout>
|
||||
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerContext({
|
||||
id = 'some_menu',
|
||||
title = 'Some context menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Empty button',
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerContext({
|
||||
id: 'some_menu',
|
||||
title: 'Some context menu',
|
||||
options: [
|
||||
{
|
||||
title: 'Empty button',
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Then we can also register our second menu called `other_menu`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerContext({
|
||||
id = 'other_menu',
|
||||
title = 'Other context menu',
|
||||
menu = 'some_menu',
|
||||
onBack = function()
|
||||
print('Went back!')
|
||||
end,
|
||||
options = {
|
||||
{
|
||||
title = 'Nothing here'
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
lib.registerContext({
|
||||
id: 'other_menu',
|
||||
title: 'Other context menu',
|
||||
menu: 'some_menu',
|
||||
onBack: () => {
|
||||
console.log('Went back!');
|
||||
},
|
||||
options: [
|
||||
{
|
||||
title: 'Nothing here',
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
And the event that we are going to run from the `some_menu` menu, which is going to open another menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab>
|
||||
|
||||
```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');
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Lastly we register a test command to show the `some_menu` menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
RegisterCommand('testcontext', function()
|
||||
lib.showContext('some_menu')
|
||||
end)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
RegisterCommand('testcontext', () => {
|
||||
lib.showContext('some_menu');
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</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 back arrow button next to the menu title that will take us back.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
@@ -0,0 +1,291 @@
|
||||
---
|
||||
title: Input Dialog
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
The input dialog window allows you to take data from the user
|
||||
by setting input fields.
|
||||
|
||||
### lib.inputDialog
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.inputDialog(heading, rows, options);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- heading: `string`
|
||||
- rows: `string[]` or `table` (`array`)
|
||||
- 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`
|
||||
- placeholder?: `string`
|
||||
- icon?: `string`
|
||||
- required? `boolean`
|
||||
- disabled?: `boolean`
|
||||
- default?: `string`
|
||||
- password?: `boolean`
|
||||
- min?: `number`
|
||||
- max?: `number`
|
||||
|
||||
- number
|
||||
|
||||
- label: `string`
|
||||
- description?: `string`
|
||||
- placeholder?: `string`
|
||||
- icon?: `string`
|
||||
- required? `boolean`
|
||||
- disabled?: `boolean`
|
||||
- default?: `number`
|
||||
- min?: `number`
|
||||
- max?: `number`
|
||||
|
||||
- checkbox
|
||||
|
||||
- label: `string`
|
||||
- checked?: `boolean`
|
||||
- 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`
|
||||
- max?: `number`
|
||||
- step?: `number`
|
||||
|
||||
- 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`
|
||||
- min?: `string`
|
||||
- "01/01/2000"
|
||||
- max?: `string`
|
||||
- "12/12/2023"
|
||||
|
||||
- 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...
|
||||
|
||||
<Callout>
|
||||
|
||||
Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value.
|
||||
|
||||
</Callout>
|
||||
|
||||
### lib.closeInputDialog
|
||||
|
||||
Force closes the active input dialog and sets its return data as `nil`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.closeInputDialog();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Usage Example
|
||||
|
||||
### Basic
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
|
||||
|
||||
if not input then return end
|
||||
print(input, input[1], input[2])
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
|
||||
</Callout>
|
||||
|
||||
```ts
|
||||
const input = await lib.inputDialog('Basic dialog', ['First row', 'Second row']);
|
||||
|
||||
if (!input) return;
|
||||
console.log(input, input[0], input[1]);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
### Advanced
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Dialog title', {
|
||||
{type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16},
|
||||
{type = 'number', label = 'Number input', description = 'Some number description', 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))
|
||||
|
||||
-- Getting r, g and b values from colour picker
|
||||
local r, g, b = string.match(input[4], "rgb%((%d+), (%d+), (%d+)%)")
|
||||
|
||||
-- Transforming unit date return to be used with Lua's os library
|
||||
local date = input[5] / 1000
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
|
||||
</Callout>
|
||||
|
||||
```ts
|
||||
const input = await lib.inputDialog('Police locker', [
|
||||
{ type: 'input', label: 'Text input', description: 'Some input description', required: true, min: 3, max: 16 },
|
||||
{ type: 'number', label: 'Number input', description: 'Some number description', 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));
|
||||
|
||||
// Getting r, g and b values from colour picker
|
||||
const regExp = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
||||
const colourInput = input[3];
|
||||
|
||||
const color = regExp.exec(colourInput);
|
||||
|
||||
if (!color) return;
|
||||
|
||||
console.log(+color[1], +color[2], +color[3]);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,329 @@
|
||||
---
|
||||
title: Menu
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
Keyboard navigation menu with specific event functions.
|
||||
|
||||
### lib.registerMenu
|
||||
|
||||
Registers and caches a menu under the specified id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(data, cb);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- data: `table` (`object`)
|
||||
- id: `string`
|
||||
- title: `string`
|
||||
- options: `table` (`array`)
|
||||
- label: `string`
|
||||
- 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?: `string[]` or `{ label: string, description: string }[]`
|
||||
- If provided creates a side scrollable list.
|
||||
- When using object and setting description, the set description will be displayed in the menu tooltip.
|
||||
- checked?: `boolean`
|
||||
- Setting either true or false will make the button a checkbox, if `values` is also provided the button will be a
|
||||
scrollable list.
|
||||
- description?: `string`
|
||||
- Displays tooltip below menu on hovered item with provided description.
|
||||
- defaultIndex?: `number`
|
||||
- Sets the current index for the list to specified number.
|
||||
- args?: `{[string]: any}`
|
||||
- Allows you to pass any arguments through the button.
|
||||
- If the button has `values` then `isScroll` is automatically passed.
|
||||
- If the button has `checked` to either true or false then `isCheck` is automatically passed.
|
||||
- close?: `boolean`
|
||||
- If set to false, it won't close the menu upon interacting with this option.
|
||||
- position?: `'top-left'` or `'top-right'` or `'bottom-left'` or `'bottom-right'`
|
||||
- Default: `'top-left'`
|
||||
- disableInput?: `boolean`
|
||||
- Default: `false`
|
||||
- canClose: `boolean`
|
||||
- If set to false the user won't be able to exit the menu without pressing one of the buttons.
|
||||
- onClose: `function`(keyPressed?: `'Escape' | 'Backspace'`)
|
||||
- Function that runs when the menu is exited via ESC/Backspace.
|
||||
- onSelected: `function`(selected: `number`, secondary: `number` | `boolean`, args: `{[string]: any}`)
|
||||
- Function being ran when the selected button in the menu changes.
|
||||
- onSideScroll: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`)
|
||||
- Function ran whenever a scroll list item is changed.
|
||||
- onCheck: `function`(selected: `number`, checked: `boolean`, args: `{[string]: any}`)
|
||||
- cb: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`)
|
||||
- Callback function when the menu item is pressed.
|
||||
|
||||
### lib.showMenu
|
||||
|
||||
Displays the menu with the provided id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showMenu(id);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.hideMenu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideMenu(onExit);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- onExit?: `boolean`
|
||||
- If true runs the menu's `onClose` function.
|
||||
|
||||
### lib.getOpenMenu
|
||||
|
||||
Returns the id of the currently open menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.getOpenMenu();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.setMenuOptions
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setMenuOptions(id, options, index);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
- options: `table` (`object` or `array`)
|
||||
- index?: `number`
|
||||
- If specified only sets the options table on the specified options index.
|
||||
|
||||
**Example:**
|
||||
|
||||
Replaces the 3rd index option of the specified menu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
<Callout>
|
||||
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerMenu({
|
||||
id = 'some_menu_id',
|
||||
title = 'Menu title',
|
||||
position = 'top-right',
|
||||
onSideScroll = function(selected, scrollIndex, args)
|
||||
print("Scroll: ", selected, scrollIndex, args)
|
||||
end,
|
||||
onSelected = function(selected, secondary, args)
|
||||
if not secondary then
|
||||
print("Normal button")
|
||||
else
|
||||
if args.isCheck then
|
||||
print("Check button")
|
||||
end
|
||||
|
||||
if args.isScroll then
|
||||
print("Scroll button")
|
||||
end
|
||||
end
|
||||
print(selected, secondary, json.encode(args, {indent=true}))
|
||||
end,
|
||||
onCheck = function(selected, checked, args)
|
||||
print("Check: ", selected, checked, args)
|
||||
end,
|
||||
onClose = function(keyPressed)
|
||||
print('Menu closed')
|
||||
if keyPressed then
|
||||
print(('Pressed %s to close the menu'):format(keyPressed))
|
||||
end
|
||||
end,
|
||||
options = {
|
||||
{label = 'Simple button', description = 'It has a description!'},
|
||||
{label = 'Checkbox button', checked = true},
|
||||
{label = 'Scroll button with icon', icon = 'arrows-up-down-left-right', values={'hello', 'there'}},
|
||||
{label = 'Button with args', args = {someArg = 'nice_button'}},
|
||||
{label = 'List button', values = {'You', 'can', 'side', 'scroll', 'this'}, description = 'It also has a description!'},
|
||||
{label = 'List button with default index', values = {'You', 'can', 'side', 'scroll', 'this'}, defaultIndex = 5},
|
||||
{label = 'List button with args', values = {'You', 'can', 'side', 'scroll', 'this'}, args = {someValue = 3, otherValue = 'value'}},
|
||||
}
|
||||
}, function(selected, scrollIndex, args)
|
||||
print(selected, scrollIndex, args)
|
||||
end)
|
||||
|
||||
RegisterCommand('testmenu', function()
|
||||
lib.showMenu('some_menu_id')
|
||||
end)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(
|
||||
{
|
||||
id: 'some_menu_id',
|
||||
title: 'Menu title',
|
||||
position: 'top-right',
|
||||
onSideScroll: (selected, scrollIndex, args) => {
|
||||
console.log('Scroll: ', selected, scrollIndex, args);
|
||||
},
|
||||
onSelected: (selected, secondary, args) => {
|
||||
if (!secondary) {
|
||||
console.log('Normal button');
|
||||
} else {
|
||||
if (args.isCheck) {
|
||||
console.log('Check button');
|
||||
}
|
||||
|
||||
if (args.isScroll) {
|
||||
console.log('Scroll button');
|
||||
}
|
||||
}
|
||||
console.log(selected, secondary, JSON.stringify(args, null, 2));
|
||||
},
|
||||
onCheck: (selected, checked, args) => {
|
||||
console.log('Check: ', selected, checked, args);
|
||||
},
|
||||
onClose: (keyPressed) => {
|
||||
console.log('Menu closed');
|
||||
if (keyPressed) {
|
||||
console.log(`Pressed ${keyPressed} to close the menu`);
|
||||
}
|
||||
},
|
||||
options: [
|
||||
{ label: 'Simple button', description: 'It has a description!' },
|
||||
{ label: 'Checkbox button', checked: true },
|
||||
{ label: 'Scroll button with icon', icon: 'arrows-up-down-left-right', values: ['hello', 'there'] },
|
||||
{ label: 'Button with args', args: { someArg: 'nice_button' } },
|
||||
{
|
||||
label: 'List button',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
description: 'It also has a description!',
|
||||
},
|
||||
{ label: 'List button with default index', values: ['You', 'can', 'side', 'scroll', 'this'], defaultIndex: 5 },
|
||||
{
|
||||
label: 'List button with args',
|
||||
values: ['You', 'can', 'side', 'scroll', 'this'],
|
||||
args: { someValue: 3, otherValue: 'value' },
|
||||
},
|
||||
],
|
||||
},
|
||||
(selected, scrollIndex, args) => {
|
||||
console.log(selected, scrollIndex, args);
|
||||
}
|
||||
);
|
||||
|
||||
RegisterCommand(
|
||||
'testmenu',
|
||||
() => {
|
||||
lib.showMenu('some_menu_id');
|
||||
},
|
||||
false
|
||||
);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,150 @@
|
||||
---
|
||||
title: Notifications
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.notify
|
||||
|
||||
Custom notifications with a lot of styling options.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
<Tabs items={["Client", "Server"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.notify(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
TriggerClientEvent('ox_lib:notify', source, data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.notify(data);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id?: `string`
|
||||
- When set the current notification will be unique and only shown once on screen when spammed.
|
||||
- title?: `string`
|
||||
- Must provide if there is no description
|
||||
- description?: `string`
|
||||
- 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'` or `'center-right'` or `'center-left'`
|
||||
- Default: `'top-right'`
|
||||
- type?: `'inform'` or `'error'` or `'success'`or `'warning'`
|
||||
- Default: `'inform'`
|
||||
- style?: `table` (`object`)
|
||||
- React CSS styling format
|
||||
- icon?: `string`
|
||||
- Font Awesome 6 icon name
|
||||
- iconColor: `string`
|
||||
|
||||
<Callout>
|
||||
|
||||
Setting `iconColor` will get rid of the contrasted icon colour and it's circular background.
|
||||
|
||||
</Callout>
|
||||
|
||||
### Usage Example
|
||||
|
||||
#### Standard
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.notify({
|
||||
title = 'Notification title',
|
||||
description = 'Notification description',
|
||||
type = 'success'
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.notify({
|
||||
title: 'Notification title',
|
||||
description: 'Notification description',
|
||||
type: 'success',
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
#### Custom
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.notify({
|
||||
id = 'some_identifier',
|
||||
title = 'Notification title',
|
||||
description = 'Notification description',
|
||||
position = 'top',
|
||||
style = {
|
||||
backgroundColor = '#141517',
|
||||
color = '#C1C2C5',
|
||||
['.description'] = {
|
||||
color = '#909296'
|
||||
}
|
||||
},
|
||||
icon = 'ban',
|
||||
iconColor = '#C53030'
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.notify({
|
||||
id: 'some_identifier',
|
||||
title: 'Notification title',
|
||||
description: 'Notification description',
|
||||
position: 'top',
|
||||
style: {
|
||||
backgroundColor: '#141517',
|
||||
color: '#C1C2C5',
|
||||
'.decription': {
|
||||
color: '#909296',
|
||||
},
|
||||
},
|
||||
icon: 'ban',
|
||||
iconColor: '#C53030',
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,319 @@
|
||||
---
|
||||
title: Progress
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
## lib.progressBar
|
||||
|
||||
Displays a running progress bar.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* duration: `number`
|
||||
* label: `string`
|
||||
* useWhileDead?: `boolean`
|
||||
* allowRagdoll?: `boolean`
|
||||
* allowCuffed?: `boolean`
|
||||
* allowFalling?: `boolean`
|
||||
* canCancel?: `boolean`
|
||||
* anim?: `table` (`object`)
|
||||
* dict?: `string`
|
||||
* Must specify either scenario or dict
|
||||
* clip: `string`
|
||||
* flag?: `number`
|
||||
* Default: `49`
|
||||
* blendIn?: `float`
|
||||
* Default: `3.0`
|
||||
* blendOut?: `float`
|
||||
* Default: `1.0`
|
||||
* duration?: `number`
|
||||
Default: `-1`
|
||||
* playbackRate?: `number`
|
||||
Default: `0`
|
||||
* lockX?: `boolean`
|
||||
* lockY?: `boolean`
|
||||
* lockZ?: `boolean`
|
||||
* scenario?: `string`
|
||||
* Must specify either scenario or dict
|
||||
* playEnter?: `boolean`
|
||||
* Default: `true`
|
||||
* prop?: `table` (`object` or `array`)
|
||||
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
|
||||
* model: `hash`
|
||||
* bone?: `number`
|
||||
* Default: `60309`
|
||||
* pos: `table`
|
||||
* x: `number`
|
||||
* y: `number`
|
||||
* z: `number`
|
||||
* rot: `table` (`object`)
|
||||
* x: `number`
|
||||
* y: `number`
|
||||
* z: `number`
|
||||
* disable?: `table` (`object`)
|
||||
* move?: `boolean`
|
||||
* car?: `boolean`
|
||||
* combat?: `boolean`
|
||||
* mouse?: `boolean`
|
||||
|
||||
### Usage Example
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
if lib.progressBar({
|
||||
duration = 2000,
|
||||
label = 'Drinking water',
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = {
|
||||
car = true,
|
||||
},
|
||||
anim = {
|
||||
dict = 'mp_player_intdrink',
|
||||
clip = 'loop_bottle'
|
||||
},
|
||||
prop = {
|
||||
model = `prop_ld_flow_bottle`,
|
||||
pos = vec3(0.03, 0.03, 0.02),
|
||||
rot = vec3(0.0, 0.0, -1.5)
|
||||
},
|
||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
</Callout>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
if (await lib.progressBar({
|
||||
duration: 2000,
|
||||
label: 'Drinking water',
|
||||
useWhileDead: false,
|
||||
canCancel: true,
|
||||
disable: {
|
||||
car: true,
|
||||
},
|
||||
anim: {
|
||||
dict: 'mp_player_intdrink',
|
||||
clip: 'loop_bottle'
|
||||
},
|
||||
prop: {
|
||||
model: `prop_ld_flow_bottle`,
|
||||
pos: {x: 0.03, y: 0.03, z: 0.02},
|
||||
rot: {x: 0.0, y: 0.0, z: -1.5}
|
||||
},
|
||||
})) console.log('Do stuff when complete');
|
||||
else console.log('Do stuff when cancelled')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
## lib.progressCircle
|
||||
|
||||
Similar to `lib.progressBar` except it displays a circle and you can define a position.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* duration: `number`
|
||||
* label?: `string`
|
||||
* position?: `'middle'` or `'bottom'`
|
||||
* Default: `'middle'`
|
||||
* useWhileDead?: `boolean`
|
||||
* allowRagdoll?: `boolean`
|
||||
* allowCuffed?: `boolean`
|
||||
* allowFalling?: `boolean`
|
||||
* canCancel?: `boolean`
|
||||
* anim?: `table` (`object`)
|
||||
* dict?: `string`
|
||||
* Must specify either scenario or dict
|
||||
* clip: `string`
|
||||
* flag?: `number`
|
||||
* Default: `49`
|
||||
* blendIn?: `float`
|
||||
* Default: `3.0`
|
||||
* blendOut?: `float`
|
||||
* Default: `1.0`
|
||||
* duration?: `number`
|
||||
Default: `-1`
|
||||
* playbackRate?: `number`
|
||||
Default: `0`
|
||||
* lockX?: `boolean`
|
||||
* lockY?: `boolean`
|
||||
* lockZ?: `boolean`
|
||||
* scenario?: `string`
|
||||
* Must specify either scenario or dict
|
||||
* playEnter?: `boolean`
|
||||
* Default: `true`
|
||||
* prop?: `table` (`object` or `array`)
|
||||
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
|
||||
* model: `hash`
|
||||
* bone?: `number`
|
||||
* Default: `60309`
|
||||
* pos: `table`
|
||||
* x: `number`
|
||||
* y: `number`
|
||||
* z: `number`
|
||||
* rot: `table` (`object`)
|
||||
* x: `number`
|
||||
* y: `number`
|
||||
* z: `number`
|
||||
* disable?: `table` (`object`)
|
||||
* move?: `boolean`
|
||||
* car?: `boolean`
|
||||
* combat?: `boolean`
|
||||
* mouse?: `boolean`
|
||||
|
||||
### Usage Example
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
if lib.progressCircle({
|
||||
duration = 2000,
|
||||
position = 'bottom',
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = {
|
||||
car = true,
|
||||
},
|
||||
anim = {
|
||||
dict = 'mp_player_intdrink',
|
||||
clip = 'loop_bottle'
|
||||
},
|
||||
prop = {
|
||||
model = `prop_ld_flow_bottle`,
|
||||
pos = vec3(0.03, 0.03, 0.02),
|
||||
rot = vec3(0.0, 0.0, -1.5)
|
||||
},
|
||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
</Callout>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
if (await lib.progressCircle({
|
||||
duration: 2000,
|
||||
position: 'bottom',
|
||||
useWhileDead: false,
|
||||
canCancel: true,
|
||||
disable: {
|
||||
car: true,
|
||||
},
|
||||
anim: {
|
||||
dict: 'mp_player_intdrink',
|
||||
clip: 'loop_bottle'
|
||||
},
|
||||
prop: {
|
||||
model: `prop_ld_flow_bottle`,
|
||||
pos: {x: 0.03, y: 0.03, z: 0.02},
|
||||
rot: {x: 0.0, y: 0.0, z: -1.5}
|
||||
},
|
||||
})) console.log('Do stuff when complete')
|
||||
else console.log('Do stuff when cancelled')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
## lib.progressActive
|
||||
|
||||
Returns true if a progress bar is currently active.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## lib.cancelProgress
|
||||
|
||||
If there is a progress bar active and the
|
||||
progress bar can be cancelled then it cancels it.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -0,0 +1,338 @@
|
||||
---
|
||||
title: Radial Menu
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
- 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 items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.addRadialItem(items);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
- Id that is used for removing options.
|
||||
- icon: `string`
|
||||
- label: `string`
|
||||
- Label uses ` \n` to insert a newline
|
||||
- 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.
|
||||
- keepOpen?: `boolean`
|
||||
|
||||
### lib.removeRadialItem
|
||||
|
||||
Id of an item to be removed from the global menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.removeRadialItem(item);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.clearRadialItems
|
||||
|
||||
Removes all items from the radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.clearRadialItems()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.clearRadialItems();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.registerRadial
|
||||
|
||||
Registers a radial sub menu with predefined options.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerRadial(radial);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
- Unique menu id used to open with `menu` prop on an item.
|
||||
- items: `array`
|
||||
- icon: `string`
|
||||
- label: `string`
|
||||
- Label uses ` \n` to insert a newline
|
||||
- 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 items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.hideRadial()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideRadial();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.disableRadial
|
||||
|
||||
Disallow players from opening the radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.disableRadial(state)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.disableRadial(state);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- state: `boolean`
|
||||
- Whether or not radial menu should be disabled
|
||||
|
||||
### Usage Example
|
||||
|
||||
<Callout>
|
||||
|
||||
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.
|
||||
|
||||
</Callout>
|
||||
|
||||
Here's a use case example with some global options and an option utilising the lib's points system.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
<Callout>
|
||||
|
||||
Points system in the lib isn't available for the npm package.
|
||||
|
||||
</Callout>
|
||||
|
||||
```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')
|
||||
}
|
||||
}
|
||||
])
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: Skill Check
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
### lib.skillCheck
|
||||
|
||||
Runs a skill check with the defined difficulty.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.skillCheck(difficulty, inputs);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- difficulty: `easy` or `medium` or `hard` or `object`
|
||||
- Can set custom difficulty by sending a object instead of string
|
||||
- `{ areaSize: number, speedMultiplier: number }`
|
||||
- easy: `{ areaSize: 50, speedMultiplier: 1 }`
|
||||
- medium: `{ areaSize: 40, speedMultiplier: 1.5 }`
|
||||
- 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
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
const success = await lib.skillCheck(
|
||||
['easy', 'easy', { areaSize: 60, speedMultiplier: 2 }, 'hard'],
|
||||
['w', 'a', 's', 'd']
|
||||
);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,130 @@
|
||||
---
|
||||
title: TextUI
|
||||
---
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.showTextUI
|
||||
|
||||
Show the TextUI window.
|
||||
|
||||
<Callout type="warning">
|
||||
|
||||
**DO NOT** run this function every tick, it's intented to be used as a toggle.
|
||||
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.showTextUI(text, options)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showTextUI(text, options);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- text: `string`
|
||||
- options?: `table`
|
||||
- position?: `'right-center'` or `'left-center'` or `'top-center'`
|
||||
- Default: `'right-center'`
|
||||
- icon?: `string` or `table` (`array`)
|
||||
- iconColor?: `string`
|
||||
- style?: React.CSSProperties
|
||||
|
||||
### lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideTextUI();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
#### Basic
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.showTextUI('[E] - Fuel vehicle')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showTextUI('[E] - Fuel vehicle');
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
#### Custom styling
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
lib.showTextUI('[E] - Pick apple', {
|
||||
position = "top-center",
|
||||
icon = 'hand',
|
||||
style = {
|
||||
borderRadius = 0,
|
||||
backgroundColor = '#48BB78',
|
||||
color = 'white'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showTextUI('[E] - Pick apple', {
|
||||
position: 'top-center',
|
||||
icon: 'hand',
|
||||
style: {
|
||||
borderRadius: 0,
|
||||
backgroundColor: '#48BB78',
|
||||
color: 'white',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
Reference in new issue
Block a user