mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
refactor: Add h1 headers to all pages missing it (#137)
* refactor: Add h1 headers to all pages missing it * refactor: missed example h3 * change hooks example heading to bold text --------- Co-authored-by: Luke <[email protected]>
This commit is contained in:
1 parent
74227cc262
commit
1d2c490b26
95 files changed
+2167
-2289
No files matched your search
@@ -1,126 +1,112 @@
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Server
|
||||
|
||||
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
|
||||
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
### lib.addAce
|
||||
## lib.addAce
|
||||
|
||||
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.addAce(principal, ace, allow)
|
||||
|
||||
```lua
|
||||
lib.addAce(principal, ace, allow)
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
lib.addAce(principal, ace, allow)
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.addAce(principal, ace, allow)
|
||||
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* allow: `boolean`
|
||||
- principal: `string`
|
||||
- ace: `string`
|
||||
- allow: `boolean`
|
||||
|
||||
### lib.removeAce
|
||||
## lib.removeAce
|
||||
|
||||
Removes the ace permission from a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.removeAce(principal, ace, allow)
|
||||
|
||||
```lua
|
||||
lib.removeAce(principal, ace, allow)
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
lib.removeAce(principal, ace, allow)
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.removeAce(principal, ace, allow)
|
||||
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* allow: `boolean`
|
||||
- principal: `string`
|
||||
- ace: `string`
|
||||
- allow: `boolean`
|
||||
|
||||
### lib.addPrincipal
|
||||
## lib.addPrincipal
|
||||
|
||||
Assigns a principal to a parent principal. Children inherit permissions from the parent.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.addPrincipal(child, parent)
|
||||
|
||||
```lua
|
||||
lib.addPrincipal(child, parent)
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
lib.addPrincipal(child, parent)
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.addPrincipal(child, parent)
|
||||
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* child: `string`
|
||||
* parent: `string`
|
||||
- child: `string`
|
||||
- parent: `string`
|
||||
|
||||
### lib.removePrincipal
|
||||
## lib.removePrincipal
|
||||
|
||||
Removes a principal from a parent principal.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.removePrincipal(child, parent)
|
||||
|
||||
```lua
|
||||
lib.removePrincipal(child, parent)
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
lib.removePrincipal(child, parent)
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.removePrincipal(child, parent)
|
||||
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
* child: `string`
|
||||
* parent: `string`
|
||||
- child: `string`
|
||||
- parent: `string`
|
||||
@@ -1,3 +1,5 @@
|
||||
# Server
|
||||
|
||||
Registers commands and simplifies argument validation, permissions, and chat suggestions.
|
||||
|
||||
```lua
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Client
|
||||
|
||||
Registers keybinds and simplifies interactions of the keybinds.
|
||||
|
||||
### CKeybind
|
||||
## CKeybind Class
|
||||
|
||||
A table representing a keybind with the following properties.
|
||||
|
||||
@@ -24,7 +26,7 @@ A table representing a keybind with the following properties.
|
||||
- onReleased?: `function(self: CKeybind)`
|
||||
- User-defined function triggered on keybind release
|
||||
|
||||
### lib.addKeybind
|
||||
## lib.addKeybind
|
||||
|
||||
```lua
|
||||
lib.addKeybind(data)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Client
|
||||
|
||||
Caches data related to the player.
|
||||
An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||
|
||||
## States
|
||||
## Cache States
|
||||
|
||||
- ped: `number`
|
||||
- player entity id
|
||||
@@ -31,47 +33,48 @@ An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||
Register an event handler that is triggered when the cached value is updated.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.onCache(key, function(value) end)
|
||||
```
|
||||
|
||||
```lua
|
||||
lib.onCache(key, function(value) end)
|
||||
```
|
||||
- key: `string`
|
||||
- `ped`
|
||||
- `vehicle`
|
||||
- `seat`
|
||||
- `weapon`
|
||||
- `mount` (RedM only)
|
||||
- value: `any`
|
||||
|
||||
- key: `string`
|
||||
- `ped`
|
||||
- `vehicle`
|
||||
- `seat`
|
||||
- `weapon`
|
||||
- `mount` (RedM only)
|
||||
- value: `any`
|
||||
```lua
|
||||
lib.onCache('vehicle', function(value)
|
||||
print('old vehicle:', cache.vehicle)
|
||||
print('new vehicle:', value)
|
||||
end)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import { onCache } from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.onCache('vehicle', function(value)
|
||||
print('old vehicle:', cache.vehicle)
|
||||
print('new vehicle:', value)
|
||||
end)
|
||||
```
|
||||
onCache(key, (value) => {});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
- key: `string`
|
||||
- `ped`
|
||||
- `vehicle`
|
||||
- `seat`
|
||||
- `weapon`
|
||||
- `mount` (RedM only)
|
||||
- value: `any`
|
||||
|
||||
```ts
|
||||
import { onCache } from '@overextended/ox_lib/client';
|
||||
```ts
|
||||
import { cache, onCache } from '@overextended/ox_lib/client';
|
||||
|
||||
onCache(key, (value) => {});
|
||||
```
|
||||
|
||||
- key: `string`
|
||||
- value: `any`
|
||||
|
||||
```ts
|
||||
import { cache, onCache } from '@overextended/ox_lib/client';
|
||||
|
||||
lib.onCache('vehicle', (value) => {
|
||||
console.log('old vehicle:', cache.vehicle);
|
||||
console.log('new vehicle:', value);
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.onCache('vehicle', (value) => {
|
||||
console.log('old vehicle:', cache.vehicle);
|
||||
console.log('new vehicle:', value);
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -1,3 +1,5 @@
|
||||
# Client
|
||||
|
||||
## Trigger Server Callback
|
||||
|
||||
### triggerServerCallback
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Server
|
||||
|
||||
## Trigger Client Callback
|
||||
|
||||
### triggerClientCallback
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Client
|
||||
|
||||
## Trigger Server Callback
|
||||
|
||||
### lib.callback
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Server
|
||||
|
||||
## Trigger Client Callback
|
||||
|
||||
### lib.callback
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Cron
|
||||
# Server
|
||||
|
||||
A Lua implementation of cron, allowing tasks to be scheduled to run periodically at fixed times, dates, and intervals.
|
||||
|
||||
@@ -44,4 +44,6 @@ lib.cron.new(expression, job, options)
|
||||
- options?: `table`
|
||||
- debug?: `boolean`
|
||||
|
||||
**returns**: OxTask
|
||||
Return:
|
||||
|
||||
- task: `OxTask`
|
||||
@@ -1,6 +1,8 @@
|
||||
# Client
|
||||
|
||||
A centralized way to track and disable controls.
|
||||
|
||||
### lib.disableControls
|
||||
## lib.disableControls
|
||||
|
||||
Call on frame to disable all stored controls.
|
||||
|
||||
@@ -8,7 +10,7 @@ Call on frame to disable all stored controls.
|
||||
lib.disableControls()
|
||||
```
|
||||
|
||||
### lib.disableControls:Add
|
||||
## lib.disableControls:Add
|
||||
|
||||
Adds the specified control(s) to the stored list.
|
||||
If the control is already being tracked, the stored counter will be incremented.
|
||||
@@ -20,7 +22,7 @@ lib.disableControls:Add(...)
|
||||
- vararg: `number` or `table`
|
||||
- Control(s) to add a stored count of
|
||||
|
||||
### lib.disableControls:Remove
|
||||
## lib.disableControls:Remove
|
||||
|
||||
Removes the specified control(s) from the stored list.
|
||||
If the stored counter for a given control is greater than one, the stored counter will be decremented.
|
||||
@@ -32,7 +34,7 @@ lib.disableControls:Remove(...)
|
||||
- vararg: `number` or `table`
|
||||
- Control(s) to remove a stored count of
|
||||
|
||||
### lib.disableControls:Clear
|
||||
## lib.disableControls:Clear
|
||||
|
||||
Clears the stored counter(s) for the specified control(s).
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getClosestObject
|
||||
# Client
|
||||
|
||||
## lib.getClosestObject
|
||||
|
||||
Get the object handle and coords of the closest object to a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getClosestPed
|
||||
# Client
|
||||
|
||||
## lib.getClosestPed
|
||||
|
||||
Get the ped handle and coords of the closest ped to a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getClosestPlayer
|
||||
# Client
|
||||
|
||||
## lib.getClosestPlayer
|
||||
|
||||
Get the player id, ped handle, and coords of the closest player to a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getClosestVehicle
|
||||
# Client
|
||||
|
||||
## lib.getClosestVehicle
|
||||
|
||||
Get the vehicle handle and coords of the closest vehicle to a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getNearbyObjects
|
||||
# Client
|
||||
|
||||
## lib.getNearbyObjects
|
||||
|
||||
Get the object handle and coords of all objects within range of a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getNearbyPeds
|
||||
# Client
|
||||
|
||||
## lib.getNearbyPeds
|
||||
|
||||
Get the ped handle and coords of all peds within range of a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getNearbyPlayers
|
||||
# Client
|
||||
|
||||
## lib.getNearbyPlayers
|
||||
|
||||
Get the player id, ped handle, and coords of all players within range of a set of coordinates.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.getNearbyVehicles
|
||||
# Client
|
||||
|
||||
## lib.getNearbyVehicles
|
||||
|
||||
Get the vehicle handle and coords of all vehicles within range of a set of coordinates.
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
title: Interface
|
||||
---
|
||||
|
||||
# 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.
|
||||
|
||||
@@ -5,45 +5,39 @@ title: Alert Dialog
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Alert Dialog
|
||||
|
||||
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
|
||||
## lib.alertDialog
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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>
|
||||
|
||||
<Tabs items={["Client", "Server"]}>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```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>
|
||||
lib.alertDialog(data);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- data: `table` (`object`)
|
||||
@@ -65,62 +59,54 @@ lib.alertDialog(data);
|
||||
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
|
||||
## lib.closeAlertDialog
|
||||
|
||||
Force closes the active alert dialog and sets its return data as `nil`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.closeAlertDialog();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.closeAlertDialog();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
**Example:**
|
||||
## Example
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
local alert = lib.alertDialog({
|
||||
header = 'Hello there',
|
||||
content = 'General Kenobi \n Markdown support!',
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
```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';
|
||||
|
||||
print(alert)
|
||||
```
|
||||
const alert = await lib.alertDialog({
|
||||
header: 'Hello there',
|
||||
content: 'General Kenobi \n Markdown support!',
|
||||
centered: true,
|
||||
cancel: true,
|
||||
});
|
||||
|
||||
</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>
|
||||
console.log(alert);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -5,39 +5,33 @@ title: Clipboard
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.setClipboard
|
||||
# Clipboard
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
To create a new line use `\t\n` not just `\n` in your string.
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setClipboard(value);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.setClipboard(value);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- value: `string`
|
||||
@@ -5,27 +5,25 @@ title: Context Menu
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.registerContext
|
||||
# Context Menu
|
||||
|
||||
## lib.registerContext
|
||||
|
||||
Used for registering a context menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.registerContext(context)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.registerContext(context)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerContext(context);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.registerContext(context);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
@@ -86,83 +84,71 @@ 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
|
||||
## lib.showContext
|
||||
|
||||
Opens a registered context menu by its id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.showContext(id)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showContext(id);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.showContext(id);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.hideContext
|
||||
## lib.hideContext
|
||||
|
||||
Hides any currently visible context menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.hideContext(onExit)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.hideContext(onExit)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideContext(onExit);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.hideContext(onExit);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- onExit: `boolean`
|
||||
- Defines whether the onExit function for the menu should be ran or not.
|
||||
|
||||
### lib.getOpenContextMenu
|
||||
## lib.getOpenContextMenu
|
||||
|
||||
Returns the id of the currently open context menu.
|
||||
|
||||
If no context menu is open returns `nil`.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.getOpenContextMenu();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.getOpenContextMenu();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
## Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
@@ -171,219 +157,201 @@ First we register the menu with our specified options then we call the show func
|
||||
</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>
|
||||
```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';
|
||||
|
||||
</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 },
|
||||
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,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
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>
|
||||
</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>
|
||||
<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>
|
||||
<Tab>
|
||||
```lua
|
||||
RegisterNetEvent('test_event', function(args)
|
||||
lib.registerContext({
|
||||
id = 'event_menu',
|
||||
title = 'Event menu',
|
||||
menu = 'some_menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Event value: '..args.someValue,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
```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')
|
||||
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>
|
||||
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>
|
||||
<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.
|
||||
|
||||
@@ -5,28 +5,25 @@ 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.
|
||||
# Input Dialog
|
||||
|
||||
### lib.inputDialog
|
||||
The input dialog window allows you to take data from the user by setting input fields.
|
||||
|
||||
## lib.inputDialog
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.inputDialog(heading, rows, options);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.inputDialog(heading, rows, options);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- heading: `string`
|
||||
@@ -36,7 +33,7 @@ lib.inputDialog(heading, rows, options);
|
||||
- allowCancel: `boolean`
|
||||
- If true the user will not be able to cancel and close the input dialog until submitted.
|
||||
|
||||
Available properties per field type:
|
||||
### Field Type Properties
|
||||
|
||||
- input
|
||||
|
||||
@@ -168,32 +165,26 @@ The callback data is promise based meaning that the thread will not continue exe
|
||||
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.
|
||||
|
||||
Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value.
|
||||
</Callout>
|
||||
|
||||
### lib.closeInputDialog
|
||||
## lib.closeInputDialog
|
||||
|
||||
Force closes the active input dialog and sets its return data as `nil`
|
||||
Force closes the active input dialog and sets its return data as `nil`.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.closeInputDialog();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.closeInputDialog();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Usage Example
|
||||
@@ -201,32 +192,26 @@ lib.closeInputDialog();
|
||||
### Basic
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
|
||||
if not input then return end
|
||||
print(json.encode(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>
|
||||
|
||||
if not input then return end
|
||||
print(json.encode(input), input[1], input[2])
|
||||
```
|
||||
```ts
|
||||
const input = await lib.inputDialog('Basic dialog', ['First row', 'Second row']);
|
||||
|
||||
</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>
|
||||
if (!input) return;
|
||||
console.log(input, input[0], input[1]);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -234,59 +219,53 @@ console.log(input, input[0], input[1]);
|
||||
### Advanced
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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"}
|
||||
})
|
||||
|
||||
```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))
|
||||
|
||||
print(json.encode(input))
|
||||
-- Getting rgb values from colour picker
|
||||
local rgb = lib.math.torgba(input[4])
|
||||
|
||||
-- Getting rgb values from colour picker
|
||||
local rgb = lib.math.torgba(input[4])
|
||||
-- Transforming date timestamp to a readable format with Lua's os library (server-only)
|
||||
local timestamp = math.floor(input[5] / 1000)
|
||||
local date = os.date('%Y-%m-%d %H:%M:%S', timestamp)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
<Callout>
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
</Callout>
|
||||
|
||||
-- Transforming date timestamp to a readable format with Lua's os library (server-only)
|
||||
local timestamp = math.floor(input[5] / 1000)
|
||||
local date = os.date('%Y-%m-%d %H:%M:%S', timestamp)
|
||||
```
|
||||
```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' },
|
||||
]);
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
console.log(JSON.stringify(input, null, 2));
|
||||
|
||||
<Callout>
|
||||
// Getting r, g and b values from colour picker
|
||||
const regExp = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
||||
const colourInput = input[3];
|
||||
|
||||
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||
const color = regExp.exec(colourInput);
|
||||
|
||||
</Callout>
|
||||
if (!color) return;
|
||||
|
||||
```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>
|
||||
console.log(+color[1], +color[2], +color[3]);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -5,29 +5,27 @@ title: Menu
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Menu
|
||||
|
||||
Keyboard navigation menu with specific event functions.
|
||||
|
||||
### lib.registerMenu
|
||||
## lib.registerMenu
|
||||
|
||||
Registers and caches a menu under the specified id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(data, cb);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.registerMenu(data, cb);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- data: `table` (`object`)
|
||||
@@ -74,97 +72,81 @@ lib.registerMenu(data, cb);
|
||||
- cb: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`)
|
||||
- Callback function when the menu item is pressed.
|
||||
|
||||
### lib.showMenu
|
||||
## lib.showMenu
|
||||
|
||||
Displays the menu with the provided id.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showMenu(id);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.showMenu(id);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.hideMenu
|
||||
## lib.hideMenu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideMenu(onExit);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.hideMenu(onExit);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- onExit?: `boolean`
|
||||
- If true runs the menu's `onClose` function.
|
||||
|
||||
### lib.getOpenMenu
|
||||
## lib.getOpenMenu
|
||||
|
||||
Returns the id of the currently open menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.getOpenMenu();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.getOpenMenu();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.setMenuOptions
|
||||
## lib.setMenuOptions
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.setMenuOptions(id, options, index);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.setMenuOptions(id, options, index);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
@@ -172,30 +154,26 @@ lib.setMenuOptions(id, options, index);
|
||||
- index?: `number`
|
||||
- If specified only sets the options table on the specified options index.
|
||||
|
||||
**Example:**
|
||||
### Example
|
||||
|
||||
Replaces the 3rd index option of the specified menu
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```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>
|
||||
lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
## Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
@@ -204,127 +182,123 @@ First we register the menu with our specified options then we call the show func
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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
|
||||
|
||||
```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")
|
||||
if args.isScroll then
|
||||
print("Scroll button")
|
||||
end
|
||||
end
|
||||
|
||||
if args.isScroll then
|
||||
print("Scroll button")
|
||||
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
|
||||
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');
|
||||
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)
|
||||
|
||||
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' } },
|
||||
RegisterCommand('testmenu', function()
|
||||
lib.showMenu('some_menu_id')
|
||||
end)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerMenu(
|
||||
{
|
||||
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);
|
||||
}
|
||||
);
|
||||
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');
|
||||
}
|
||||
|
||||
RegisterCommand(
|
||||
'testmenu',
|
||||
() => {
|
||||
lib.showMenu('some_menu_id');
|
||||
},
|
||||
false
|
||||
);
|
||||
```
|
||||
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);
|
||||
}
|
||||
);
|
||||
|
||||
</Tab>
|
||||
RegisterCommand(
|
||||
'testmenu',
|
||||
() => {
|
||||
lib.showMenu('some_menu_id');
|
||||
},
|
||||
false
|
||||
);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -5,40 +5,34 @@ title: Notifications
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.notify
|
||||
# Notifications
|
||||
|
||||
## lib.notify
|
||||
|
||||
Custom notifications with a lot of styling options.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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';
|
||||
|
||||
<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>
|
||||
lib.notify(data);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id?: `string`
|
||||
@@ -57,94 +51,84 @@ lib.notify(data);
|
||||
- React CSS styling format
|
||||
- icon?: `string`
|
||||
- Font Awesome 6 icon name
|
||||
- iconColor: `string`
|
||||
- iconColor?: `string`
|
||||
|
||||
<Callout>
|
||||
|
||||
Setting `iconColor` will get rid of the contrasted icon colour and it's circular background.
|
||||
|
||||
Setting `iconColor` will get rid of the contrasted icon colour and it's circular background.
|
||||
</Callout>
|
||||
|
||||
### Usage Example
|
||||
## Usage Example
|
||||
|
||||
#### Standard
|
||||
### Standard
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.notify({
|
||||
title = 'Notification title',
|
||||
description = 'Notification description',
|
||||
type = 'success'
|
||||
})
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```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>
|
||||
lib.notify({
|
||||
title: 'Notification title',
|
||||
description: 'Notification description',
|
||||
type: 'success',
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
#### Custom
|
||||
### Custom
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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';
|
||||
|
||||
```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>
|
||||
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>
|
||||
|
||||

|
||||
@@ -5,134 +5,128 @@ title: Progress
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Progress
|
||||
|
||||
## lib.progressBar
|
||||
|
||||
Displays a running progress bar.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.progressBar(data)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
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`
|
||||
- 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>
|
||||
<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>
|
||||
|
||||
```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
|
||||
```
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
</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>
|
||||
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>
|
||||
|
||||

|
||||
@@ -142,131 +136,123 @@ else console.log('Do stuff when cancelled')
|
||||
Similar to `lib.progressBar` except it displays a circle and you can define a position.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
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`
|
||||
- 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>
|
||||
<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>
|
||||
|
||||
```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
|
||||
```
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
</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>
|
||||
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>
|
||||
|
||||

|
||||
@@ -276,22 +262,18 @@ else console.log('Do stuff when cancelled')
|
||||
Returns true if a progress bar is currently active.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.progressActive()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.progressActive()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## lib.cancelProgress
|
||||
@@ -300,20 +282,16 @@ If there is a progress bar active and the
|
||||
progress bar can be cancelled then it cancels it.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.cancelProgress()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.cancelProgress()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -5,31 +5,29 @@ title: Radial Menu
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Radial Menu
|
||||
|
||||
- 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
|
||||
## lib.addRadialItem
|
||||
|
||||
Item or array of items added to the global radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.addRadialItem(items);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.addRadialItem(items);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- items: `table` (`object` or `array`)
|
||||
@@ -44,75 +42,63 @@ lib.addRadialItem(items);
|
||||
- Function that's ran when a user clicks the item.
|
||||
- keepOpen?: `boolean`
|
||||
|
||||
### lib.removeRadialItem
|
||||
## lib.removeRadialItem
|
||||
|
||||
Id of an item to be removed from the global menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.removeRadialItem(item);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.removeRadialItem(item);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- id: `string`
|
||||
|
||||
### lib.clearRadialItems
|
||||
## lib.clearRadialItems
|
||||
|
||||
Removes all items from the radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.clearRadialItems()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.clearRadialItems()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.clearRadialItems();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.clearRadialItems();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.registerRadial
|
||||
## lib.registerRadial
|
||||
|
||||
Registers a radial sub menu with predefined options.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.registerRadial(radial);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.registerRadial(radial);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- radial: `table` (`object`)
|
||||
@@ -127,236 +113,216 @@ lib.registerRadial(radial);
|
||||
- onSelect?: `function(currentMenu: string | nil, itemIndex: number)` | `string`
|
||||
- Function that's ran when a user clicks the item.
|
||||
|
||||
### lib.hideRadial
|
||||
## lib.hideRadial
|
||||
|
||||
Hides the radial menu if one is open.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.hideRadial()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.hideRadial()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideRadial();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.hideRadial();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.disableRadial
|
||||
## lib.disableRadial
|
||||
|
||||
Disallow players from opening the radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.disableRadial(state)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.disableRadial(state)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.disableRadial(state);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.disableRadial(state);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- state: `boolean`
|
||||
- Whether or not radial menu should be disabled
|
||||
|
||||
### lib.getCurrentRadialId
|
||||
## lib.getCurrentRadialId
|
||||
|
||||
Returns the id of the currently open radial menu.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
local id = lib.getCurrentRadialId()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
local id = lib.getCurrentRadialId()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
let id = lib.getCurrentRadialId();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
let id = lib.getCurrentRadialId();
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
## 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 its density.
|
||||
|
||||
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 its 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>
|
||||
<Tab>
|
||||
```lua
|
||||
exports('myMenuHandler', function(menu, item)
|
||||
print(menu, item)
|
||||
|
||||
```lua
|
||||
exports('myMenuHandler', function(menu, item)
|
||||
print(menu, item)
|
||||
if menu == 'police_menu' and item == 1 then
|
||||
print('Handcuffs')
|
||||
end
|
||||
end)
|
||||
|
||||
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.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: () => {
|
||||
console.log('Business')
|
||||
}
|
||||
}
|
||||
])
|
||||
```
|
||||
lib.addRadialItem({
|
||||
{
|
||||
id = 'police',
|
||||
label = 'Police',
|
||||
icon = 'shield-halved',
|
||||
menu = 'police_menu'
|
||||
},
|
||||
{
|
||||
id = 'business_stuff',
|
||||
label = 'Business',
|
||||
icon = 'briefcase',
|
||||
onSelect = function()
|
||||
print("Business")
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
</Tab>
|
||||
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>
|
||||
|
||||

|
||||
|
||||
@@ -4,27 +4,25 @@ title: Skill Check
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
### lib.skillCheck
|
||||
# Skill Check
|
||||
|
||||
## lib.skillCheck
|
||||
|
||||
Runs a skill check with the defined difficulty.
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.skillCheck(difficulty, inputs);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.skillCheck(difficulty, inputs);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- difficulty: `'easy'` or `'medium'` or `'hard'` or `table`
|
||||
@@ -41,28 +39,24 @@ lib.skillCheck(difficulty, inputs);
|
||||
- A random key will be picked from the inputs table for each skill check
|
||||
- If no inputs are defined the key is defaulted to `e`
|
||||
|
||||
### Usage Example
|
||||
## Usage Example
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<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';
|
||||
|
||||
```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>
|
||||
const success = await lib.skillCheck(
|
||||
['easy', 'easy', { areaSize: 60, speedMultiplier: 2 }, 'hard'],
|
||||
['w', 'a', 's', 'd']
|
||||
);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -5,33 +5,29 @@ title: TextUI
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
### lib.showTextUI
|
||||
# TextUI
|
||||
|
||||
## lib.showTextUI
|
||||
|
||||
Show the TextUI window.
|
||||
|
||||
<Callout type="warning">
|
||||
|
||||
**DO NOT** run this function every tick, it's intended to be used as a toggle.
|
||||
|
||||
**DO NOT** run this function every tick, it's intended to be used as a toggle.
|
||||
</Callout>
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.showTextUI(text, options)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.showTextUI(text, options)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.showTextUI(text, options);
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.showTextUI(text, options);
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- text: `string`
|
||||
@@ -42,113 +38,96 @@ lib.showTextUI(text, options);
|
||||
- iconColor?: `string`
|
||||
- style?: React.CSSProperties
|
||||
|
||||
### lib.hideTextUI
|
||||
## lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.hideTextUI();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
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>
|
||||
|
||||
### lib.isTextUIOpen
|
||||
## lib.isTextUIOpen
|
||||
|
||||
Returns whether Text UI is opened or not
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.isTextUIOpen()
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
```lua
|
||||
lib.isTextUIOpen()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client';
|
||||
|
||||
lib.isTextUIOpen();
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.isTextUIOpen();
|
||||
```
|
||||
</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>
|
||||
|
||||

|
||||
@@ -1,3 +1,5 @@
|
||||
# Shared
|
||||
|
||||
Allows servers to set a preferred language and attempt to load locale files in any resources using the module.
|
||||
Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json`
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Steps, Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Server
|
||||
|
||||
## lib.logger
|
||||
|
||||
```lua
|
||||
@@ -25,23 +27,22 @@ lib.logger(-1, 'CreateVehicle', json.encode(vehicle))
|
||||
## Datadog
|
||||
|
||||
<Steps>
|
||||
### Create your [Datadog](https://www.datadoghq.com/) account
|
||||
You will receive a free 14 day trial, otherwise refer to their [pricing](https://www.datadoghq.com/pricing/) guide.
|
||||
Free accounts are limited, however logs will still be retained for 14 days.
|
||||
### Create your [Datadog](https://www.datadoghq.com/) account
|
||||
You will receive a free 14 day trial, otherwise refer to their [pricing](https://www.datadoghq.com/pricing/) guide.
|
||||
Free accounts are limited, however logs will still be retained for 14 days.
|
||||
|
||||
### Create an [API key](https://app.datadoghq.com/organization-settings/api-keys)
|
||||
### Create an [API key](https://app.datadoghq.com/organization-settings/api-keys)
|
||||
|
||||
This is a UUID used to submit logs to your Datadog organisation.
|
||||
This is a UUID used to submit logs to your Datadog organisation.
|
||||
|
||||
### Config
|
||||
### Config
|
||||
|
||||
Set your API key and [Datadog site](https://docs.datadoghq.com/getting_started/site/) using the following convars.
|
||||
|
||||
```bash
|
||||
set datadog:key "yourapikey"
|
||||
set datadog:site "datadoghq.com"
|
||||
```
|
||||
Set your API key and [Datadog site](https://docs.datadoghq.com/getting_started/site/) using the following convars.
|
||||
|
||||
```bash
|
||||
set datadog:key "yourapikey"
|
||||
set datadog:site "datadoghq.com"
|
||||
```
|
||||
</Steps>
|
||||
|
||||
## Grafana Loki
|
||||
@@ -51,21 +52,18 @@ It is designed to be very cost effective and easy to operate.
|
||||
|
||||
<Tabs items={["Cloud", "Self-hosted"]}>
|
||||
<Tab>
|
||||
|
||||
- Has free tier with some restrictions
|
||||
- Easy to manage
|
||||
- Easier to setup
|
||||
- Mostly managed by Grafana
|
||||
|
||||
<Steps>
|
||||
### Create your [Grafana](https://grafana.com/) account
|
||||
### Head to [My Account](https://grafana.com/auth/sign-in/?plcmt=top-nav&cta=myaccount)
|
||||
### Setup Loki
|
||||
Find the Loki section in your account panel, and click "Details".
|
||||
Generate a password and save the API key, as well as your `user` and `url`.
|
||||
|
||||
### Create your [Grafana](https://grafana.com/) account
|
||||
### Head to [My Account](https://grafana.com/auth/sign-in/?plcmt=top-nav&cta=myaccount)
|
||||
### Setup Loki
|
||||
Find the Loki section in your account panel, and click "Details".
|
||||
Generate a password and save the API key, as well as your `user` and `url`.
|
||||
</Steps>
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
To setup a grafana instance you'll need docker, and knowledge on containers or kubernetes.
|
||||
@@ -74,19 +72,15 @@ It is designed to be very cost effective and easy to operate.
|
||||
Once done, setup authentication and use the username and password securing your endpoint.
|
||||
|
||||
- By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Steps>
|
||||
### Config
|
||||
Use the following convars to set your logging service, endpoint, and authentication details.
|
||||
### Config
|
||||
Use the following convars to set your logging service, endpoint, and authentication details.
|
||||
|
||||
```bash
|
||||
set ox:logger "loki"
|
||||
set loki:user "<insert your user>"
|
||||
set loki:password "<insert the api key or password>"
|
||||
set loki:endpoint "<insert loki url without http:// or https://>"
|
||||
```
|
||||
|
||||
</Steps>
|
||||
```bash
|
||||
set ox:logger "loki"
|
||||
set loki:user "<insert your user>"
|
||||
set loki:password "<insert the api key or password>"
|
||||
set loki:endpoint "<insert loki url without http:// or https://>"
|
||||
```
|
||||
@@ -1,3 +1,5 @@
|
||||
# Shared
|
||||
|
||||
## lib.math
|
||||
|
||||
Extends the standard Lua math table with extra functions.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# Points
|
||||
# Client
|
||||
|
||||
## Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Points
|
||||
# Client
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
### CPoint
|
||||
## CPoint Class
|
||||
|
||||
A table representing a point with the following properties.
|
||||
|
||||
@@ -22,7 +22,7 @@ A table representing a point with the following properties.
|
||||
- nearby?: `function(self: CPoint)`
|
||||
- Function triggered on frame when within `distance` of the point
|
||||
|
||||
### lib.points.new
|
||||
## lib.points.new
|
||||
|
||||
```lua
|
||||
lib.points.new(data)
|
||||
@@ -36,7 +36,7 @@ Returns:
|
||||
|
||||
- point: `CPoint`
|
||||
|
||||
#### Example
|
||||
### Example
|
||||
```lua
|
||||
local point = lib.points.new({
|
||||
coords = GetEntityCoords(cache.ped),
|
||||
@@ -61,7 +61,7 @@ function point:nearby()
|
||||
end
|
||||
```
|
||||
|
||||
### lib.points.getAllPoints
|
||||
## lib.points.getAllPoints
|
||||
|
||||
Get a table of all points created in the resource.
|
||||
|
||||
@@ -73,7 +73,7 @@ Return:
|
||||
|
||||
- points: `CPoint[]`
|
||||
|
||||
### lib.points.getNearbyPoints
|
||||
## lib.points.getNearbyPoints
|
||||
|
||||
Get an array of all points in range of the player.
|
||||
|
||||
@@ -85,7 +85,7 @@ Return:
|
||||
|
||||
- nearbyPoints: `CPoint[]`
|
||||
|
||||
### lib.points.getClosestPoint
|
||||
## lib.points.getClosestPoint
|
||||
|
||||
Get the data for the closest point to the player.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
### lib.raycast.cam
|
||||
# Client
|
||||
|
||||
## lib.raycast.cam
|
||||
|
||||
Starts a shapetest originating from the camera, extending to ~10m by default.
|
||||
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Client
|
||||
|
||||
Check if assets exist, such as models, and loads them into memory.
|
||||
Throws errors for invalid assets and returns true if the asset is loaded.
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
### lib.requestAnimDict
|
||||
## lib.requestAnimDict
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- dict: `string`
|
||||
@@ -29,25 +27,21 @@ lib.requestAnimDict(dict, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestAnimSet
|
||||
## lib.requestAnimSet
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- set: `string`
|
||||
@@ -55,25 +49,21 @@ lib.requestAnimSet(set, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestModel
|
||||
## lib.requestModel
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- model: `string`
|
||||
@@ -81,25 +71,21 @@ lib.requestModel(model, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestStreamedTextureDict
|
||||
## lib.requestStreamedTextureDict
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- dict: `string`
|
||||
@@ -107,25 +93,21 @@ lib.requestStreamedTextureDict(dict, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestNamedPtfxAsset
|
||||
## lib.requestNamedPtfxAsset
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestNamedPtfxAsset(ptFxName, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestNamedPtfxAsset(ptFxName, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestNamedPtfxAsset(ptFxName, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestNamedPtfxAsset(ptFxName, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- ptFxName: `string`
|
||||
@@ -133,25 +115,21 @@ lib.requestNamedPtfxAsset(ptFxName, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestScaleformMovie
|
||||
## lib.requestScaleformMovie
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestScaleformMovie(scaleformName, timeout)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestScaleformMovie(scaleformName, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestScaleformMovie(scaleformName, timeout)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestScaleformMovie(scaleformName, timeout)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- scaleformName: `string`
|
||||
@@ -159,25 +137,21 @@ lib.requestScaleformMovie(scaleformName, timeout)
|
||||
- Number of ticks to wait for the asset to load.
|
||||
- Default: `500`
|
||||
|
||||
### lib.requestWeaponAsset
|
||||
## lib.requestWeaponAsset
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
- weaponType: `string | number`
|
||||
@@ -189,7 +163,7 @@ lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComp
|
||||
- extraWeaponComponentFlags?: `ExtraWeaponComponentFlags`
|
||||
- Default: `0`
|
||||
|
||||
#### WeaponResourceFlags
|
||||
### WeaponResourceFlags
|
||||
|
||||
```
|
||||
1 WRF_REQUEST_BASE_ANIMS
|
||||
@@ -201,7 +175,7 @@ lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComp
|
||||
31 WRF_REQUEST_ALL_ANIMS
|
||||
```
|
||||
|
||||
#### ExtraWeaponComponentFlags
|
||||
### ExtraWeaponComponentFlags
|
||||
|
||||
```
|
||||
0 WEAPON_COMPONENT_NONE
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
Adds additional functions alongside the standard table library
|
||||
# Shared
|
||||
|
||||
Adds additional functions alongside the standard table library.
|
||||
|
||||
## lib.table.contains
|
||||
|
||||
Checks if `table` contains the given `value`. Only intended for simple values and unnested tables.
|
||||
|
||||
```lua
|
||||
lib.table.contains(tbl, value)
|
||||
```
|
||||
|
||||
Checks if `table` contains the given `value`. Only intended for simple values and unnested tables.
|
||||
|
||||
- tbl: `table`
|
||||
- value: `any`
|
||||
|
||||
@@ -16,12 +18,12 @@ Return:
|
||||
|
||||
## lib.table.matches
|
||||
|
||||
Compares if two values are equal, iterating over tables and matching both keys and values.
|
||||
|
||||
```lua
|
||||
lib.table.matches(tableOne, tableTwo)
|
||||
```
|
||||
|
||||
Compares if two values are equal, iterating over tables and matching both keys and values.
|
||||
|
||||
- tableOne: `table`
|
||||
- tableTwo: `table`
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Client
|
||||
|
||||
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
|
||||
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5
|
||||
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L3
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
### lib.getVehicleProperties
|
||||
## lib.getVehicleProperties
|
||||
|
||||
```ts
|
||||
lib.getVehicleProperties(vehicle)
|
||||
@@ -14,25 +16,21 @@ lib.getVehicleProperties(vehicle)
|
||||
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### lib.setVehicleProperties
|
||||
## lib.setVehicleProperties
|
||||
|
||||
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
||||
|
||||
@@ -44,29 +42,25 @@ lib.setVehicleProperties(vehicle, props)
|
||||
- props: `table` (`object`)
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
end)
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
end)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
onNet('ox_lib:setVehicleProperties', (netid, data) => {
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
onNet('ox_lib:setVehicleProperties', (netid, data) => {
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
})
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
#### Recommended Usage
|
||||
### Recommended Usage
|
||||
|
||||
The server should tell the owner of the entity to set properties, using the following trigger.
|
||||
|
||||
@@ -74,7 +68,7 @@ The server should tell the owner of the entity to set properties, using the foll
|
||||
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
|
||||
```
|
||||
|
||||
### Vehicle Properties
|
||||
## Vehicle Properties
|
||||
|
||||
- model?: `number`
|
||||
- plate?: `string`
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
### lib.versionCheck
|
||||
|
||||
Compares the resource version to the latest published release on GitHub.
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Server
|
||||
|
||||
## lib.versionCheck
|
||||
|
||||
Compares the resource version to the latest published release on GitHub.
|
||||
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
|
||||
|
||||
```lua
|
||||
lib.versionCheck(repository)
|
||||
```
|
||||
@@ -11,22 +14,16 @@ lib.versionCheck(repository)
|
||||
- repository: `string`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
```lua
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
|
||||
</Tab>
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
|
||||
@@ -1,9 +1,11 @@
|
||||
### lib.checkDependency
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
# Shared
|
||||
|
||||
## lib.checkDependency
|
||||
|
||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
|
||||
```lua
|
||||
lib.checkDependency(resource, version)
|
||||
```
|
||||
@@ -12,21 +14,17 @@ lib.checkDependency(resource, version)
|
||||
- version: `string`
|
||||
|
||||
<Tabs items={["Lua", "JS"]}>
|
||||
<Tab>
|
||||
<Tab>
|
||||
```lua
|
||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/shared'
|
||||
// import { checkDependency } from '@overextended/ox_lib/shared'
|
||||
|
||||
```lua
|
||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/shared'
|
||||
// import { checkDependency } from '@overextended/ox_lib/shared'
|
||||
|
||||
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
||||
```
|
||||
|
||||
</Tab>
|
||||
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Tabs, Tab } from 'nextra-theme-docs';
|
||||
import { Callout } from 'nextra/components';
|
||||
|
||||
# Shared
|
||||
|
||||
Faster alternative to PolyZone utilising [glm.polygon](https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/EXTENDED.md).
|
||||
|
||||
<Callout>
|
||||
|
||||
Currently zones only have basic support on the server side. Some features will not work such as `onEnter`, `onExit`, and `inside`.
|
||||
|
||||
Currently zones only have basic support on the server side. Some features will not work such as `onEnter`, `onExit`, and `inside`.
|
||||
</Callout>
|
||||
|
||||
## lib.zones.poly
|
||||
@@ -147,7 +147,6 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
|
||||
|
||||
<Tabs items={["function", "array", "ox_target"]}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local poly = lib.zones.poly({
|
||||
name = poly,
|
||||
@@ -161,10 +160,8 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
|
||||
thickness = 2,
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
{
|
||||
name = poly,
|
||||
@@ -180,7 +177,6 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
|
||||
```
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
exports.ox_target:addPolyZone({
|
||||
name = poly,
|
||||
@@ -194,6 +190,5 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
|
||||
thickness = 2,
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
Reference in new issue
Block a user