mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-03 14:38:49 +00:00
30 files changed
+3914
-2133
No files matched your search
+85
-10
@@ -1,44 +1,119 @@
|
|||||||
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
|
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.
|
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
|
||||||
### lib.addAce
|
### lib.addAce
|
||||||
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- principal: string
|
|
||||||
-- ace: string
|
|
||||||
-- allow: boolean
|
|
||||||
lib.addAce(principal, ace, allow)
|
lib.addAce(principal, ace, allow)
|
||||||
|
|
||||||
lib.addAce('group.admin', 'command.say')
|
lib.addAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
|
||||||
|
lib.addAce(principal, ace, allow)
|
||||||
|
|
||||||
|
lib.addAce('group.admin', 'command.say')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* principal: `string`
|
||||||
|
* ace: `string`
|
||||||
|
* allow: `boolean`
|
||||||
|
|
||||||
### lib.removeAce
|
### lib.removeAce
|
||||||
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- principal: string
|
|
||||||
-- ace: string
|
|
||||||
-- allow: boolean
|
|
||||||
lib.removeAce(principal, ace, allow)
|
lib.removeAce(principal, ace, allow)
|
||||||
|
|
||||||
lib.removeAce('group.admin', 'command.say')
|
lib.removeAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
|
||||||
|
lib.removeAce(principal, ace, allow)
|
||||||
|
|
||||||
|
lib.removeAce('group.admin', 'command.say')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* principal: `string`
|
||||||
|
* ace: `string`
|
||||||
|
* allow: `boolean`
|
||||||
|
|
||||||
### lib.addPrincipal
|
### lib.addPrincipal
|
||||||
Assigns a principal to a parent principal. Children inherit permissions from the parent.
|
Assigns a principal to a parent principal. Children inherit permissions from the parent.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- child: string
|
|
||||||
-- parent: string
|
|
||||||
lib.addPrincipal(child, parent)
|
lib.addPrincipal(child, parent)
|
||||||
|
|
||||||
lib.addPrincipal('player.1', 'group.moderator')
|
lib.addPrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
|
||||||
|
lib.addPrincipal(child, parent)
|
||||||
|
|
||||||
|
lib.addPrincipal('player.1', 'group.moderator')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* child: `string`
|
||||||
|
* parent: `string`
|
||||||
|
|
||||||
|
|
||||||
### lib.removePrincipal
|
### lib.removePrincipal
|
||||||
Removes a principal from a parent principal.
|
Removes a principal from a parent principal.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- child: string
|
|
||||||
-- parent: string
|
|
||||||
lib.removePrincipal(child, parent)
|
lib.removePrincipal(child, parent)
|
||||||
|
|
||||||
lib.removePrincipal('player.1', 'group.moderator')
|
lib.removePrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
|
||||||
|
lib.removePrincipal(child, parent)
|
||||||
|
|
||||||
|
lib.removePrincipal('player.1', 'group.moderator')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* child: `string`
|
||||||
|
* parent: `string`
|
||||||
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
```lua
|
```lua
|
||||||
-- principal: string or string[] or false
|
|
||||||
-- command: string
|
|
||||||
-- callback: function
|
|
||||||
-- parameters: table (optional)
|
|
||||||
-- help: string (optional)
|
|
||||||
lib.addCommand(principal, command, callback, parameters, help)
|
lib.addCommand(principal, command, callback, parameters, help)
|
||||||
|
```
|
||||||
|
* principal: `string` or `string[]` or `false`
|
||||||
|
* command: `string`
|
||||||
|
* callback: `function`
|
||||||
|
* parameters?: `table` (`array`)
|
||||||
|
* help?: `string`
|
||||||
|
|
||||||
|
```lua
|
||||||
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
|
lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
|
||||||
args.item = Items(args.item)
|
args.item = Items(args.item)
|
||||||
if args.item and args.count > 0 then
|
if args.item and args.count > 0 then
|
||||||
|
|||||||
+55
-16
@@ -1,26 +1,65 @@
|
|||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Caches data related to the player and handling some events or statebags.
|
Caches data related to the player and handling some events or statebags.
|
||||||
An interval runs every 100ms to update data that cannot be checked via handlers.
|
An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||||
|
|
||||||
https://github.com/overextended/ox_lib/blob/master/resource/cache/client.lua
|
|
||||||
|
|
||||||
## States
|
## States
|
||||||
```lua
|
|
||||||
cache.ped -- player entity id
|
- ped: `number`
|
||||||
cache.playerId -- player id
|
- player entity id
|
||||||
cache.serverId -- player server id
|
- playerId: `number`
|
||||||
cache.vehicle -- vehicle entity id
|
- player id
|
||||||
cache.seat -- vehicle seat index
|
- serverId: `number`
|
||||||
cache.resource -- invoking resource name
|
- player server id
|
||||||
```
|
- vehicle: `number` or `false`
|
||||||
|
- vehicle entity id
|
||||||
|
- seat: `number` or `false`
|
||||||
|
- vehicle seat index
|
||||||
|
- resource: `string`
|
||||||
|
- invoking resource name
|
||||||
|
|
||||||
## lib.onCache
|
## lib.onCache
|
||||||
Register a callback function when the value is changed.
|
|
||||||
|
Register an event handler that is triggered when the cached value is updated.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.onCache(key, function(value) end)
|
||||||
|
```
|
||||||
|
|
||||||
|
- key: `string`
|
||||||
|
- value: `any`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.onCache('vehicle', function(value)
|
lib.onCache('vehicle', function(value)
|
||||||
print('vehicle', value)
|
print('old vehicle:', cache.vehicle)
|
||||||
end)
|
print('new vehicle:', value)
|
||||||
|
|
||||||
lib.onCache('seat', function(value)
|
|
||||||
print('seat', value)
|
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { 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);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
@@ -1,25 +1,55 @@
|
|||||||
Triggers a registered server callback and registers an event handler for the response.
|
## Client -> Server callback
|
||||||
|
|
||||||
### lib.callback
|
### lib.callback
|
||||||
The response is handled in a separate coroutine.
|
|
||||||
```lua
|
|
||||||
-- name: string
|
|
||||||
-- delay: number or false
|
|
||||||
-- cb: function
|
|
||||||
lib.callback(name, delay, cb, ...)
|
|
||||||
|
|
||||||
|
The response is handled in a separate coroutine.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback(name, delay, cb, ...)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- delay: `number` or `false`
|
||||||
|
- cb: `function`
|
||||||
|
- ...: `any`
|
||||||
|
|
||||||
|
```lua
|
||||||
lib.callback('ox_inventory:getItemCount', false, function(count)
|
lib.callback('ox_inventory:getItemCount', false, function(count)
|
||||||
print(count)
|
print(count)
|
||||||
end, 'water', {type = 'fresh'})
|
end, 'water', {type = 'fresh'})
|
||||||
```
|
```
|
||||||
|
|
||||||
### lib.callback.await
|
### lib.callback.await
|
||||||
The current coroutine is yielded until a response is received.
|
|
||||||
```lua
|
|
||||||
-- name: string
|
|
||||||
-- delay: number or false
|
|
||||||
lib.callback.await(name, delay, ...)
|
|
||||||
|
|
||||||
|
The current coroutine is yielded until a response is received.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.await(name, delay, ...)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- delay: `number` or `false`
|
||||||
|
- ...: `any`
|
||||||
|
|
||||||
|
```lua
|
||||||
local count = lib.callback.await('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
|
local count = lib.callback.await('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
|
||||||
print(count)
|
print(count)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Server -> Client callback
|
||||||
|
|
||||||
|
### lib.callback.register
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.register(name, cb)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- cb: `function`
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
||||||
|
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
||||||
|
return nearbyVehicles
|
||||||
|
end
|
||||||
|
```
|
||||||
@@ -1,9 +1,58 @@
|
|||||||
### lib.callback.register
|
## Server -> Client callback
|
||||||
```lua
|
|
||||||
-- name: string
|
|
||||||
-- cb: function
|
|
||||||
lib.callback.register(name, cb)
|
|
||||||
|
|
||||||
|
### lib.callback
|
||||||
|
|
||||||
|
The response is handled in a separate coroutine.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback(name, source, cb, ...)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- source: `number`
|
||||||
|
- cb: `function`
|
||||||
|
- ...: `any`
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback('ox:getNearbyVehicles', source, function(vehicles)
|
||||||
|
for i = 1, #vehicles do
|
||||||
|
DeleteEntity(entity)
|
||||||
|
end
|
||||||
|
end, args.radius)
|
||||||
|
```
|
||||||
|
|
||||||
|
### lib.callback.await
|
||||||
|
|
||||||
|
The current coroutine is yielded until a response is received.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.await(name, source, ...)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- source: `number`
|
||||||
|
- ...: `any`
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local vehicles = lib.callback.await('ox:getNearbyVehicles', source, args.radius)
|
||||||
|
|
||||||
|
for i = 1, #vehicles do
|
||||||
|
DeleteEntity(entity)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Client -> Server callback
|
||||||
|
|
||||||
|
### lib.callback.register
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.callback.register(name, cb)
|
||||||
|
```
|
||||||
|
|
||||||
|
- name: `string`
|
||||||
|
- cb: `function`
|
||||||
|
|
||||||
|
```lua
|
||||||
lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
|
lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
|
||||||
local inventory = target and Inventory(target) or Inventory(source)
|
local inventory = target and Inventory(target) or Inventory(source)
|
||||||
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
|
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
### lib.disableControls
|
### lib.disableControls
|
||||||
|
Call on frame to disable all stored keys.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Call on frame to disable all stored keys.
|
|
||||||
lib.disableControls()
|
lib.disableControls()
|
||||||
```
|
```
|
||||||
|
|
||||||
### lib.disableControls:Add
|
### lib.disableControls:Add
|
||||||
```lua
|
```lua
|
||||||
-- vararg: number
|
|
||||||
lib.disableControls:Add(...)
|
lib.disableControls:Add(...)
|
||||||
```
|
```
|
||||||
|
* vararg: `number`
|
||||||
|
|
||||||
### lib.disableControls:Remove
|
### lib.disableControls:Remove
|
||||||
```lua
|
```lua
|
||||||
-- vararg: number
|
|
||||||
lib.disableControls:Remove(...)
|
lib.disableControls:Remove(...)
|
||||||
```
|
```
|
||||||
|
* vararg: `number`
|
||||||
|
|
||||||
### lib.disableControls:Clear
|
### lib.disableControls:Clear
|
||||||
```lua
|
```lua
|
||||||
-- vararg: number
|
|
||||||
lib.disableControls:Clear(...)
|
lib.disableControls:Clear(...)
|
||||||
```
|
```
|
||||||
|
* vararg: `number`
|
||||||
@@ -3,11 +3,16 @@
|
|||||||
Get the id, ped, and coords of the closest player to a set of coordinates.
|
Get the id, ped, and coords of the closest player to a set of coordinates.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param coords vector3 The coords to check from.
|
|
||||||
---@param maxDistance number The max distance to check.
|
|
||||||
---@param includePlayer boolean Whether or not to include the current player.
|
|
||||||
---@return number? playerId
|
|
||||||
---@return number? playerPed
|
|
||||||
---@return vector3? playerCoords
|
|
||||||
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
||||||
```
|
```
|
||||||
|
* coords: `vector3`
|
||||||
|
* The coords to check from.
|
||||||
|
* maxDistance: `number`
|
||||||
|
* The max distance to check.
|
||||||
|
* includePlayer: `boolean`
|
||||||
|
* Whether or not to include the current player.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
* playerId?: `number`
|
||||||
|
* playerPed?: `nubmer`
|
||||||
|
* playerCoords?: `vector3`
|
||||||
@@ -3,10 +3,16 @@
|
|||||||
Get the id and coords of the closest vehicle to a set of coordinates.
|
Get the id and coords of the closest vehicle to a set of coordinates.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param coords vector3 The coords to check from.
|
|
||||||
---@param maxDistance number The max distance to check.
|
|
||||||
---@param includePlayerVehicle boolean Whether or not to include the player's current vehicle.
|
|
||||||
---@return number? vehicle
|
|
||||||
---@return vector3? vehicleCoords
|
|
||||||
function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end
|
function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* coords: `vector3`
|
||||||
|
* The coords to check from.
|
||||||
|
* maxDistance: `number`
|
||||||
|
* The max distance to check.
|
||||||
|
* includePlayerVehicle: `boolean`
|
||||||
|
* Whether or not to include the player's current vehicle.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
* vehicle?: `number`
|
||||||
|
* vehicleCoords?: `vector3`
|
||||||
@@ -3,9 +3,14 @@
|
|||||||
Get the id, ped, and coords of all players within range of a set of coordinates.
|
Get the id, ped, and coords of all players within range of a set of coordinates.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param coords vector3 The coords to check from.
|
|
||||||
---@param maxDistance number The max distance to check.
|
|
||||||
---@param includePlayer boolean Whether or not to include the current player.
|
|
||||||
---@return number[]
|
|
||||||
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
||||||
```
|
```
|
||||||
|
* coords: `vector3`
|
||||||
|
* The coords to check from.
|
||||||
|
* maxDistance: `number`
|
||||||
|
* The max distance to check.
|
||||||
|
* includePlayer: `boolean`
|
||||||
|
* Whether or not to include the current player.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
* `number[]`
|
||||||
@@ -3,9 +3,14 @@
|
|||||||
Get the id and coords of all vehicles within range of a set of coordinates.
|
Get the id and coords of all vehicles within range of a set of coordinates.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param coords vector3 The coords to check from.
|
|
||||||
---@param maxDistance number The max distance to check.
|
|
||||||
---@param includePlayerVehicle boolean Whether or not to include the player's current vehicle.
|
|
||||||
---@return number[]
|
|
||||||
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
||||||
```
|
```
|
||||||
|
* coords: `vector3`
|
||||||
|
* The coords to check from.
|
||||||
|
* maxDistance: `number`
|
||||||
|
* The max distance to check.
|
||||||
|
* includePlayerVehicle: `boolean`
|
||||||
|
* Whether or not to include the player's current vehicle.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
* `number[]`
|
||||||
@@ -2,29 +2,51 @@
|
|||||||
title: Alert Dialog
|
title: Alert Dialog
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Simple alert dialog that can display a message to the player.
|
Simple alert dialog that can display a message to the player.
|
||||||
Returns whether the player pressed the confirm button or canceled the dialog.
|
Returns whether the player pressed the confirm button or canceled the dialog.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- data: table
|
lib.alertDialog(data)
|
||||||
-- header: string
|
```
|
||||||
-- content: string
|
</TabItem>
|
||||||
-- centered: boolean (optional)
|
<TabItem value='JS/TS'>
|
||||||
-- cancel: boolean (optional)
|
|
||||||
|
:::caution
|
||||||
|
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||||
|
:::
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.alertDialog(data)
|
lib.alertDialog(data)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
`header` - Dialog title.
|
* data: `table` (`object`)
|
||||||
`content` - Dialog body content, supports markdown.
|
* header: `string`
|
||||||
`centered` - Centers the dialog vertically and horizontally.
|
* Dialog title.
|
||||||
`cancel` - Displays a cancel button (ESC is still available if this is not defined).
|
* content: `string`
|
||||||
|
* Dialog body content, supports markdown.
|
||||||
|
* centered?: `boolean`
|
||||||
|
* Centers the dialog vertically and horizontally.
|
||||||
|
* cancel?: `boolean`
|
||||||
|
* Displays a cancel button (ESC is still available if this is not defined).
|
||||||
|
|
||||||
Returns `confirm` if the player pressed the confirm button, otherwise if the player pressed the cancel button
|
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`.
|
or has exited the dialog with ESC the return will be `cancel`.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local alert = lib.alertDialog({
|
local alert = lib.alertDialog({
|
||||||
header = 'Hello there',
|
header = 'Hello there',
|
||||||
@@ -35,5 +57,24 @@ local alert = lib.alertDialog({
|
|||||||
|
|
||||||
print(alert)
|
print(alert)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```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)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
@@ -2,12 +2,28 @@
|
|||||||
title: Clipboard
|
title: Clipboard
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.setClipboard
|
### lib.setClipboard
|
||||||
|
|
||||||
Sets the player's clipboard to the specified string value.
|
Sets the player's clipboard to the specified string value.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- value: string
|
lib.setClipboard(value)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.setClipboard(value)
|
lib.setClipboard(value)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* value: `string`
|
||||||
@@ -8,52 +8,59 @@ import TabItem from '@theme/TabItem';
|
|||||||
### lib.registerContext
|
### lib.registerContext
|
||||||
Used for registering a context menu.
|
Used for registering a context menu.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string
|
|
||||||
-- title: string
|
|
||||||
-- menu: string (optional)
|
|
||||||
-- onExit: function (optional)
|
|
||||||
-- options: table
|
|
||||||
-- item: key as string or table
|
|
||||||
-- title: string (optional - if item isn't key)
|
|
||||||
-- menu: string (optional)
|
|
||||||
-- icon: string (optional)
|
|
||||||
-- iconColor: string (optional)
|
|
||||||
-- arrow: boolean (optional)
|
|
||||||
-- description: string (optional)
|
|
||||||
-- metadata: string table or key, value table or table (optional)
|
|
||||||
-- event: string (optional)
|
|
||||||
-- serverEvent: string (optional)
|
|
||||||
-- args: any (optional)
|
|
||||||
lib.registerContext(context)
|
lib.registerContext(context)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.registerContext(context)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* id: `string`
|
||||||
|
* Unique menu identifier, will be used to open the menu.
|
||||||
|
* title: `string`
|
||||||
|
* Title display in the menu.
|
||||||
|
* menu?: `string`
|
||||||
|
* Menu identifier - if defined there will be a back arrow next to the menu title that will take you to the menu you defined.
|
||||||
|
* onExit?: `function`
|
||||||
|
* Function that will be ran when the user closes their context menu with ESC.
|
||||||
|
* options: `table` (`object` or `array`)
|
||||||
|
* item: `key` (`string`) or `table` (`object`)
|
||||||
|
* title?: `string`
|
||||||
|
* If not using keys then sets the title for the button.
|
||||||
|
* menu?: `string`
|
||||||
|
* Menu identifier that the button will take you to, when defined an arrow.
|
||||||
|
* onSelect: `function`
|
||||||
|
* Function that's ran when the button is clicked.
|
||||||
|
* icon?: `string`
|
||||||
|
* FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons.
|
||||||
|
* iconColor?: `string`
|
||||||
|
* Colour of the displayed icon.
|
||||||
|
* arrow?: `boolean`
|
||||||
|
* Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it.
|
||||||
|
* description?: `string`
|
||||||
|
* Description that will appear under the button title that is defined as a key.
|
||||||
|
* metadata?: `string[]` or `object` or `array`
|
||||||
|
* Information that will display on the side upon hovering a button.
|
||||||
|
* event?: `string`
|
||||||
|
* Event that the button is going to trigger.
|
||||||
|
* serverEvent?: `string`
|
||||||
|
* Server event that the button is going to trigger.
|
||||||
|
* args?: `any`
|
||||||
|
* Arguments that will be sent to the events or onSelect function.
|
||||||
|
|
||||||
You can register as many context menus in one `lib.registerContext` function
|
You can register as many context menus in one `lib.registerContext` function
|
||||||
as you'd like.
|
as you'd like.
|
||||||
|
|
||||||
`id` - Unique menu identifier, will be used to open the menu.
|
|
||||||
`title` - Every menu must have a title.
|
|
||||||
`menu` - Menu identifier - if defined there will be a back arrow next to the menu title
|
|
||||||
that will take you to the menu you defined.
|
|
||||||
`onExit` - Function that will be ran when the user closes their context menu with ESC.
|
|
||||||
`options` - Contains all the clickable menu items.
|
|
||||||
`item` - Defined as a key, can be empty if you don't want it to do anything.
|
|
||||||
`item/title` - If not using keys then sets the title for the button.
|
|
||||||
`item/onSelect` - Function that triggers when a button is pressed, returns it's args.
|
|
||||||
`item/image` - Image url, puts the image at the top of the metadata popover.
|
|
||||||
`item/icon` - FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons.
|
|
||||||
`item/iconColor` - Color of the displayed icon.
|
|
||||||
`item/menu` - Menu identifier that the button will take you to, when defined an arrow
|
|
||||||
pointing to the right to indicate a menu will be shown.
|
|
||||||
`item/arrow` - Shows an arrow on the right side like `menu` does, useful when you are
|
|
||||||
opening a menu from an event.
|
|
||||||
`item/description` - Description that will appear under the button title that is defined
|
|
||||||
as a key.
|
|
||||||
`item/metadata` - Information that will display on the side upon hovering a button.
|
|
||||||
`item/event` - Event that the button is going to trigger.
|
|
||||||
`item/serverEvent` - Server event that the button is going to trigger.
|
|
||||||
`args` - Arguments that will be sent to the events.
|
|
||||||
|
|
||||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
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,
|
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
|
otherwise not using keys and instead using tables will make the menu be in the order you
|
||||||
@@ -62,33 +69,70 @@ define it as.
|
|||||||
### lib.showContext
|
### lib.showContext
|
||||||
Opens a registered context menu by it's id.
|
Opens a registered context menu by it's id.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string
|
lib.showContext(id)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.showContext(id)
|
lib.showContext(id)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* id: `string`
|
||||||
|
|
||||||
### lib.hideContext
|
### lib.hideContext
|
||||||
Hides any currently visible context menu.
|
Hides any currently visible context menu.
|
||||||
|
|
||||||
`onExit` param defines whether the onExit function for the
|
<Tabs>
|
||||||
menu should be ran or not.
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
-- onExit: boolean
|
|
||||||
lib.hideContext(onExit)
|
lib.hideContext(onExit)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.hideContext(onExit)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</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.
|
Returns the id of the currently open context menu.
|
||||||
|
|
||||||
If not context menu is open returns `nil`.
|
If no context menu is open returns `nil`.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.getOpenContextMenu()
|
lib.getOpenContextMenu()
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.getOpenContextMenu()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
First we register the menu with our specified options then we call the show function in the command.
|
First we register the menu with our specified options then we call the show function in the command.
|
||||||
@@ -98,7 +142,7 @@ Avoid constantly re-registering a menu that does not depend on any outside value
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='custom' label='Custom order'>
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.registerContext({
|
lib.registerContext({
|
||||||
@@ -144,59 +188,81 @@ lib.registerContext({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
</TabItem>
|
|
||||||
<TabItem value='ordered' label='Alphabetically ordered'>
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.registerContext({
|
RegisterCommand('testcontext', function()
|
||||||
id = 'example_menu',
|
lib.showContext('example_menu')
|
||||||
title = 'Example Context',
|
end)
|
||||||
onExit = function()
|
```
|
||||||
print('Hello there')
|
</TabItem>
|
||||||
end,
|
<TabItem value='JS/TS'>
|
||||||
options = {
|
|
||||||
['Empty button'] = {},
|
```ts
|
||||||
['Example button'] = {
|
import lib from '@overextended/ox_lib/client'
|
||||||
description = 'Example button description',
|
```
|
||||||
metadata = {
|
|
||||||
['Value 1'] = 'Some value',
|
```ts
|
||||||
['Value 2'] = 300
|
lib.registerContext([
|
||||||
}
|
{
|
||||||
},
|
id: 'example_menu',
|
||||||
['Menu button'] = {
|
title: 'Example Context',
|
||||||
menu = 'other_example_menu',
|
onExit: () => {
|
||||||
description = 'Takes you to another menu',
|
console.log('Hello there');
|
||||||
metadata = {'It also has metadata support'}
|
|
||||||
},
|
|
||||||
['Event button'] = {
|
|
||||||
description = 'Open a menu and send event data',
|
|
||||||
arrow = true,
|
|
||||||
event = 'some_event',
|
|
||||||
args = {value1 = 300, value2 = 'Other value'}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
options: [
|
||||||
id = 'other_example_menu',
|
{ title: 'Empty button' },
|
||||||
title = 'Other Context Menu',
|
{
|
||||||
menu = 'example_menu',
|
title: 'Example button',
|
||||||
options = {
|
description: 'Example button description',
|
||||||
['Nothing here'] = {}
|
onSelect: (args) => {
|
||||||
}
|
console.log('Pressed the button!');
|
||||||
}
|
},
|
||||||
})
|
metadata: [
|
||||||
|
{ label: 'Value 1', value: 'Some value' },
|
||||||
|
{ label: 'Value 2', value: 300 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Menu button',
|
||||||
|
menu: 'other_example_menu',
|
||||||
|
description: 'Takes you to another menu!',
|
||||||
|
metadata: ['It also has metadata support'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Event button',
|
||||||
|
description: 'Open a menu and send event data',
|
||||||
|
arrow: true,
|
||||||
|
event: 'some_event',
|
||||||
|
args: { value1: 300, value2: 'Other value' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'other_example_menu',
|
||||||
|
title: 'Other Context Menu',
|
||||||
|
menu: 'example_menu',
|
||||||
|
options: {
|
||||||
|
['Nothing here']: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
RegisterCommand('testcontext', () => {
|
||||||
|
lib.showContext('example_menu')
|
||||||
|
}, false)
|
||||||
```
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
```lua
|
|
||||||
RegisterCommand('testcontext', function()
|
|
||||||
lib.showContext('example_menu')
|
|
||||||
end)
|
|
||||||
```
|
|
||||||
|
|
||||||
To trigger the event from the `Event button` and get it's data we first
|
To trigger the event from the `Event button` and get it's data we first
|
||||||
need to register the event properly:
|
need to register the event properly:
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
RegisterNetEvent('some_event', function(data)
|
RegisterNetEvent('some_event', function(data)
|
||||||
print(json.encode(data, {indent=true}))
|
print(json.encode(data, {indent=true}))
|
||||||
@@ -217,6 +283,32 @@ RegisterNetEvent('some_event', function(data)
|
|||||||
lib.showContext('another_context_menu')
|
lib.showContext('another_context_menu')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
onNet('some_event', () => {
|
||||||
|
console.log(JSON.stringify(data, null, 2))
|
||||||
|
lib.registerContext({
|
||||||
|
id: 'another_context_menu',
|
||||||
|
title: 'Event Menu',
|
||||||
|
menu: 'example_menu',
|
||||||
|
options: {
|
||||||
|
['Menu data']: {
|
||||||
|
description: 'Data from the previous menu',
|
||||||
|
metadata: {
|
||||||
|
['Value1']: data.value1,
|
||||||
|
['Value2']: data.value2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
lib.showContext('another_context_menu');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
The data from the `args` table in the menu is passed as a first argument to
|
The data from the `args` table in the menu is passed as a first argument to
|
||||||
the event you register, in this case that argument is called `data`.
|
the event you register, in this case that argument is called `data`.
|
||||||
|
|
||||||
|
|||||||
@@ -10,34 +10,57 @@ by setting input fields.
|
|||||||
|
|
||||||
### lib.inputDialog
|
### lib.inputDialog
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- heading: string
|
lib.inputDialog(heading, rows)
|
||||||
-- rows: strings array or table
|
```
|
||||||
-- type: "input" or "number" or "checkbox" or "select" or "slider"
|
</TabItem>
|
||||||
-- label: string
|
<TabItem value='JS/TS'>
|
||||||
-- options: table array (optional - used ONLY with "select" type)
|
|
||||||
-- value: string
|
```ts
|
||||||
-- label: string
|
import lib from '@overextended/ox_lib/client'
|
||||||
-- default: string (optional - any of the values)
|
|
||||||
-- password: boolean (optional - used ONLY with "input" type)
|
|
||||||
-- icon: string (optional - used ONLY with "input" type)
|
|
||||||
-- placeholder: string (optional - used ONLY with "input" or "number" type)
|
|
||||||
-- default: string or number (optional)
|
|
||||||
-- checked: boolean (optional - used ONLY with "checkbox" type)
|
|
||||||
-- min: number (optional - used ONLY with "slider" type)
|
|
||||||
-- max: number (optional - used ONLY with "slider" type)
|
|
||||||
-- step: number (optional - used ONLY with "slider" type)
|
|
||||||
|
|
||||||
lib.inputDialog(heading, rows)
|
lib.inputDialog(heading, rows)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* heading: `string`
|
||||||
|
* rows: `string[]` or `table` (`array`)
|
||||||
|
* type: `'input'` or `'number'` or `'checkbox'` or `'select'` or `'slider'`
|
||||||
|
* label: `string`
|
||||||
|
* options?: `table` (`array`)
|
||||||
|
* [ Only used with `'select'` type ]
|
||||||
|
* value: `string`
|
||||||
|
* label: `string`
|
||||||
|
* default?: `string`
|
||||||
|
* password?: `boolean`
|
||||||
|
* Hides input characters with ability to toggle them on. Used only with `'input'` type.
|
||||||
|
* icon?: `string`
|
||||||
|
* Used only with `'input'` and `'number'` types.
|
||||||
|
* placeholder?: `string`
|
||||||
|
* Used only with `'input'` and `'number'` types.
|
||||||
|
* default?: `string` or `number`
|
||||||
|
* Default value for the field.
|
||||||
|
* checked?: `boolean`
|
||||||
|
* Whether the checkbox should be checked by default. Used only with `'checkbox'` type.
|
||||||
|
* min?: `number`
|
||||||
|
* Used only with `'slider'` and `'number'` types.
|
||||||
|
* max?: `number`
|
||||||
|
* Used only with `'slider'` and `'number'` types.
|
||||||
|
* step?: `number`
|
||||||
|
* Amount of change per slider step. Used only with `'slider'` type.
|
||||||
|
|
||||||
The callback data is promise based meaning that the thread will
|
The callback data is promise based meaning that the thread will
|
||||||
not continue executing until the user either sends the data
|
not continue executing until the user either sends the data
|
||||||
or exits the popup.
|
or exits the popup.
|
||||||
|
|
||||||
The data returned will be a table, indexes represent the rows
|
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
|
sent to the dialog, so if we want data from the first field that
|
||||||
would be index `1`, if we want data from the third field, that would
|
would be index `1` (`0`), if we want data from the third field, that would
|
||||||
be index `3`, etc...
|
be index `3` (`2`), etc...
|
||||||
|
|
||||||
The standard input rows will always return a string, if you want a row to be of
|
The standard input rows will always return a string, if you want a row to be of
|
||||||
number data type, you can use set the `type` to `number`.
|
number data type, you can use set the `type` to `number`.
|
||||||
@@ -49,31 +72,56 @@ Look at the *Advanced* example for it's usage.
|
|||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
||||||
When using the advanced method you can define `icon` and `password` **ONLY** with type `"input"` and
|
When using the advanced method you can define `icon` and `password` **ONLY** with type `'input'` and `'number'` and
|
||||||
you can define `options` **ONLY** with type `"select"`.
|
you can define `options` **ONLY** with type `'select'`.
|
||||||
|
|
||||||
|
|
||||||
Doing so otherwise ***will*** result in errors.
|
Doing so otherwise ***will*** result in errors.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
**Example:**
|
## Usage Example
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value="basic" label="Basic">
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'})
|
local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'})
|
||||||
|
|
||||||
if input then
|
if not input then return end
|
||||||
local lockerNumber = tonumber(input[1])
|
local lockerNumber = tonumber(input[1])
|
||||||
local lockerPasscode = input[2]
|
local lockerPasscode = input[2]
|
||||||
|
|
||||||
print(lockerNumber, lockerPasscode)
|
print(lockerNumber, lockerPasscode)
|
||||||
end
|
|
||||||
```
|
```
|
||||||

|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='advanced' label='Advanced'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||||
|
:::
|
||||||
|
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const input = await lib.inputDialog('Police locker', ['Locker number', 'Locker passcode'])
|
||||||
|
|
||||||
|
if (!input) return
|
||||||
|
const lockerNumber = input[0] as number
|
||||||
|
const lockerPasscode = input[1] as number
|
||||||
|
|
||||||
|
console.log(lockerNumber, lockerPasscode)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Advanced
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value="Lua">
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local input = lib.inputDialog('Police locker', {
|
local input = lib.inputDialog('Police locker', {
|
||||||
@@ -90,6 +138,31 @@ local input = lib.inputDialog('Police locker', {
|
|||||||
})
|
})
|
||||||
print(json.encode(input, {indent=true}))
|
print(json.encode(input, {indent=true}))
|
||||||
```
|
```
|
||||||
 
|
</TabItem>
|
||||||
|
<TabItem value="JS/TS">
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||||
|
:::
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const input = await lib.inputDialog('Police locker', [
|
||||||
|
{ type: 'input', label: 'Locker number', placeholder: '123' },
|
||||||
|
{ type: 'checkbox', label: 'Some checkbox' },
|
||||||
|
{ type: 'input', label: 'Locker PIN', password: true, icon: 'lock' },
|
||||||
|
{ type: 'checkbox', label: 'Some other checkbox', checked: true },
|
||||||
|
{ type: 'select', label: 'Value select', options: [
|
||||||
|
{ value: 'option1', label: 'Option 1' },
|
||||||
|
{ value: 'option2', label: 'Option 2' },
|
||||||
|
{ value: 'option3', label: 'Option 3' },
|
||||||
|
]},
|
||||||
|
{ type: 'number', label: 'Number counter', default: 12 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
console.log(JSON.stringify(input, null, 2));
|
||||||
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
 
|
||||||
@@ -2,72 +2,169 @@
|
|||||||
title: Menu
|
title: Menu
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Keyboard navigation menu with specific event functions.
|
Keyboard navigation menu with specific event functions.
|
||||||
|
|
||||||
### lib.registerMenu
|
### lib.registerMenu
|
||||||
Registers and caches a menu under the specified id.
|
Registers and caches a menu under the specified id.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- data: table
|
lib.registerMenu(data, cb)
|
||||||
-- id: string
|
```
|
||||||
-- title: string
|
</TabItem>
|
||||||
-- options: table
|
<TabItem value='JS/TS'>
|
||||||
-- label: string
|
|
||||||
-- icon: string (optinal)
|
```ts
|
||||||
-- values: table of strings (optional - if provided creates a side scrollable list)
|
import lib from '@overextended/ox_lib/client'
|
||||||
-- description?: string (optional)
|
|
||||||
-- defaultIndex: number (optional - sets the current index for the list to specified number)
|
|
||||||
-- args: any (optional)
|
|
||||||
-- position: 'top-left' or 'top-right' or 'bottom-left' or 'bottom-right' (optional - default is top-left)
|
|
||||||
-- disableInput: boolean (optional - default false)
|
|
||||||
-- onClose: function (optional)
|
|
||||||
-- onSelected: function (optional - triggers every time a new button is selected)
|
|
||||||
-- onSideScroll: function (optional - triggers every time a side list is scrolled)
|
|
||||||
-- cb: function
|
|
||||||
|
|
||||||
lib.registerMenu(data, cb)
|
lib.registerMenu(data, cb)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* data: `table` (`object`)
|
||||||
|
* id: `string`
|
||||||
|
* title: `string`
|
||||||
|
* options: `table` (`array`)
|
||||||
|
* label: `string`
|
||||||
|
* icon?: `string`
|
||||||
|
* values?: `table` (`string[]`)
|
||||||
|
* If provided creates a side scrollabel list.
|
||||||
|
* description?: `string`
|
||||||
|
* Displays tooltip below menu on hovered item with provided description.
|
||||||
|
* defaultIndex?: `number`
|
||||||
|
* Sets the current index for the list to specified number.
|
||||||
|
* args?: `any`
|
||||||
|
* position?: `'top-left'` or `'top-right'` or `'bottom-left'` or `'bottom-right'`
|
||||||
|
* Default: `'top-left'`
|
||||||
|
* disableInput?: `boolean`
|
||||||
|
* Default: `false`
|
||||||
|
* onClose: `function`
|
||||||
|
* Function that runs when the menu is exited via ESC/Backspace.
|
||||||
|
* onSelected: `function`(selected: `number`: scrollIndex: `number`: args: `any`)
|
||||||
|
* Function being ran when the selected button in the menu changes.
|
||||||
|
* onSideScroll: `function`(selected: `number`: scrollIndex: `number`: args: `any`)
|
||||||
|
* Function ran whenever a scroll list item is changed.
|
||||||
|
* cb: `function`(selected: `number`: scrollIndex: `number`: args: `any`)
|
||||||
|
* Callback function when the menu item is pressed.
|
||||||
|
|
||||||
### lib.showMenu
|
### lib.showMenu
|
||||||
Displays the menu with the provided id.
|
Displays the menu with the provided id.
|
||||||
|
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string
|
lib.showMenu(id)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.showMenu(id)
|
lib.showMenu(id)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* id: `string`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### lib.hideMenu
|
### lib.hideMenu
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- onExit: boolean (optional - if true runs the menu's onClose function)
|
lib.hideMenu(onExit)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.hideMenu(onExit)
|
lib.hideMenu(onExit)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* onExit?: `boolean`
|
||||||
|
* If true runs the menu's `onClose` function.
|
||||||
|
|
||||||
### lib.getOpenMenu
|
### lib.getOpenMenu
|
||||||
Returns the id of the currently open menu.
|
Returns the id of the currently open menu.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.getOpenMenu()
|
lib.getOpenMenu()
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.getOpenMenu()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
### lib.setMenuOptions
|
### lib.setMenuOptions
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string
|
lib.setMenuOptions(id, options, index)
|
||||||
-- options: table
|
```
|
||||||
-- index: number (optional - if specified only sets the options table on the specified options index)
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.setMenuOptions(id, options, index)
|
lib.setMenuOptions(id, options, index)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* id: `string`
|
||||||
|
* options: `table` (`object` or `array`)
|
||||||
|
* index?: `number`
|
||||||
|
* If specified only sets the options table on the specified options index.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```lua
|
Replaces the 3rd index option of the specified menu
|
||||||
-- Replaces the option on 3rd index of specified menu
|
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.setMenuOptions('some_menu_id', {label: 'New option', icon: 'plus'}, 3)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
First we register the menu with our specified options then we call the show function in the command.
|
First we register the menu with our specified options then we call the show function in the command.
|
||||||
@@ -77,6 +174,9 @@ Avoid constantly re-registering a menu that does not depend on any outside value
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.registerMenu({
|
lib.registerMenu({
|
||||||
id = 'some_menu_id',
|
id = 'some_menu_id',
|
||||||
@@ -107,4 +207,42 @@ RegisterCommand('testmenu', function()
|
|||||||
lib.showMenu('some_menu_id')
|
lib.showMenu('some_menu_id')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```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(selected, scrollIndex, args)
|
||||||
|
},
|
||||||
|
onSelected: (selected, scrollIndex, args) => {
|
||||||
|
console.log(selected, scrollIndex, args)
|
||||||
|
},
|
||||||
|
onClose: () => {
|
||||||
|
console.log('Menu closed')
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{label: 'Simple button', description: 'It has a description!'},
|
||||||
|
{label: 'Simple button with icon', icon: 'arrows-up-down-left-right'},
|
||||||
|
{label: 'Button with args', args: 'nice_button'},
|
||||||
|
{label: 'List button', values: ['You', 'can', 'side', 'scroll', 'this'], description: 'It also has a description!'},
|
||||||
|
{label: 'List button with default index', values: ['You', 'can', 'side', 'scroll', 'this'], defaultIndex: 5},
|
||||||
|
{label: 'List button with args', values: ['You', 'can', 'side', 'scroll', 'this'], args: {someValue: 3, otherValue: 'value'}},
|
||||||
|
]
|
||||||
|
}, (selected, scrollIndex, args) => {
|
||||||
|
console.log(selected, scrollIndex, args)
|
||||||
|
})
|
||||||
|
|
||||||
|
RegisterCommand('testmenu', () => {
|
||||||
|
lib.showMenu('some_menu_id')
|
||||||
|
}, false)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
@@ -5,35 +5,49 @@ title: Notifications
|
|||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.notify
|
## lib.notify
|
||||||
Custom notifications with a lot of styling options.
|
Custom notifications with a lot of styling options.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string (optional)
|
lib.notify(data)
|
||||||
-- title: string (if description then optional)
|
```
|
||||||
-- description: string (if title then optional)
|
</TabItem>
|
||||||
-- duration: number (optional)
|
<TabItem value='JS/TS'>
|
||||||
-- position: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' (optional)
|
|
||||||
-- type: 'inform' | 'error' | 'success'
|
```ts
|
||||||
-- style: table (optional)
|
import lib from '@overextended/ox_lib/client'
|
||||||
-- icon: string (optional)
|
|
||||||
-- iconColor: string (optional)
|
|
||||||
|
|
||||||
lib.notify(data)
|
lib.notify(data)
|
||||||
```
|
```
|
||||||
`id` - When set the current notification will be unique and only shown once on screen
|
</TabItem>
|
||||||
`title` - Must provide if there is no description
|
</Tabs>
|
||||||
`description` - Must provide if there is no title
|
|
||||||
`position` - Default: `'top-right'`
|
|
||||||
`type` - Default: `'inform'`
|
|
||||||
`style` - React CSS styling, works the same as in [TextUI](textui.md)
|
|
||||||
`icon` - Font Awesome 6 icon, works the same as in [TextUI](textui.md)
|
|
||||||
`iconColor` - Set a different color for the provided icon
|
|
||||||
|
|
||||||
|
* id?: `string`
|
||||||
|
* When set the current notification will be unique and only shown once on screen when spammed.
|
||||||
|
* title?: `string`
|
||||||
|
* Must provide if there is no description
|
||||||
|
* description?: `string`
|
||||||
|
* Must provide if there is no title
|
||||||
|
* duration?: `number`
|
||||||
|
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
|
||||||
|
* Default: `'top-right'`
|
||||||
|
* type?: `'inform'` or `'error'` or `'success'`
|
||||||
|
* Default: `'inform'`
|
||||||
|
* style?: `table` (`object`)
|
||||||
|
* React CSS styling format
|
||||||
|
* icon?: `string`
|
||||||
|
* Font Awesome 6 icon name
|
||||||
|
* iconColor: `string`
|
||||||
|
|
||||||
|
### Usage Example
|
||||||
|
|
||||||
|
### Standard
|
||||||
|
|
||||||
**Example:**
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='standard' label="Standard">
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.notify({
|
lib.notify({
|
||||||
@@ -42,9 +56,27 @@ lib.notify({
|
|||||||
type = 'success'
|
type = 'success'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||

|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='custom' label="Custom">
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.notify({
|
||||||
|
title: 'Notification title',
|
||||||
|
description: 'Notification description',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Custom
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.notify({
|
lib.notify({
|
||||||
@@ -60,25 +92,64 @@ lib.notify({
|
|||||||
iconColor = '#C53030'
|
iconColor = '#C53030'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||

|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```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: '#909296'
|
||||||
|
},
|
||||||
|
icon: 'ban',
|
||||||
|
iconColor: '#C53030'
|
||||||
|
})
|
||||||
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### lib.defaultNotify
|
|
||||||
|

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

|

|
||||||
@@ -2,54 +2,81 @@
|
|||||||
title: Progress
|
title: Progress
|
||||||
---
|
---
|
||||||
|
|
||||||
### lib.progressBar
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
## lib.progressBar
|
||||||
Displays a running progress bar.
|
Displays a running progress bar.
|
||||||
|
|
||||||
```lua
|
<Tabs>
|
||||||
-- duration: number
|
<TabItem value='Lua'>
|
||||||
-- label: string
|
|
||||||
-- useWhileDead: boolean (optional)
|
|
||||||
-- allowRagdoll: boolean (optional)
|
|
||||||
-- allowCuffed: boolean (optional)
|
|
||||||
-- allowFalling: boolean (optional)
|
|
||||||
-- canCancel: boolean (optional)
|
|
||||||
-- anim: table (optional)
|
|
||||||
-- dict: string (optional - either scenario or dict)
|
|
||||||
-- clip: string
|
|
||||||
-- flag: number (optional - default is 49)
|
|
||||||
-- blendIn: float (optional - default is 3.0)
|
|
||||||
-- blendOut: float (optional - default is 1.0)
|
|
||||||
-- duration: number (optional - default is -1)
|
|
||||||
-- playbackRate: number (optional - default is 0)
|
|
||||||
-- lockX: boolean (optional)
|
|
||||||
-- lockY: boolean (optional)
|
|
||||||
-- lockZ: boolean (optional)
|
|
||||||
|
|
||||||
-- scenario: string (optional - either scenario or dict)
|
```lua
|
||||||
-- playEnter: boolean (optional - default is true)
|
lib.progressBar(data)
|
||||||
-- prop: table (optional)
|
```
|
||||||
-- model: hash
|
</TabItem>
|
||||||
-- bone: number (optional - default is 60309)
|
<TabItem value='JS/TS'>
|
||||||
-- pos: table
|
|
||||||
-- x: number
|
```ts
|
||||||
-- y: number
|
import lib from '@overextended/ox_lib/client'
|
||||||
-- z: number
|
|
||||||
-- rot: table
|
|
||||||
-- x: number
|
|
||||||
-- y: number
|
|
||||||
-- z: number
|
|
||||||
-- disable: table (optional)
|
|
||||||
-- move: boolean (optional)
|
|
||||||
-- car: boolean (optional)
|
|
||||||
-- combat: boolean (optional)
|
|
||||||
-- mouse: boolean (optional)
|
|
||||||
|
|
||||||
lib.progressBar(data)
|
lib.progressBar(data)
|
||||||
```
|
```
|
||||||
If you want to define multiple props, you can pass them
|
</TabItem>
|
||||||
as individual tables in the `prop` table.
|
</Tabs>
|
||||||
|
|
||||||
|
* duration: `number`
|
||||||
|
* label: `string`
|
||||||
|
* useWhileDead?: `boolean`
|
||||||
|
* allowRagdoll?: `boolean`
|
||||||
|
* allowCuffed?: `boolean`
|
||||||
|
* allowFalling?: `boolean`
|
||||||
|
* canCancel?: `boolean`
|
||||||
|
* anim?: `table` (`object`)
|
||||||
|
* dict?: `string`
|
||||||
|
* Must specify either scenario or dict
|
||||||
|
* clip: `string`
|
||||||
|
* flag?: `number`
|
||||||
|
* Default: `49`
|
||||||
|
* blendIn?: `float`
|
||||||
|
* Default: `3.0`
|
||||||
|
* blendOut?: `float`
|
||||||
|
* Default: `1.0`
|
||||||
|
* duration?: `number`
|
||||||
|
Default: `-1`
|
||||||
|
* playbackRate?: `number`
|
||||||
|
Default: `0`
|
||||||
|
* lockX?: `boolean`
|
||||||
|
* lockY?: `boolean`
|
||||||
|
* lockZ?: `boolean`
|
||||||
|
* scenario?: `string`
|
||||||
|
* Must specify either scenario or dict
|
||||||
|
* playEnter?: `boolean`
|
||||||
|
* Default: `true`
|
||||||
|
* prop?: `table` (`object` or `array`)
|
||||||
|
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
|
||||||
|
* model: `hash`
|
||||||
|
* bone?: `number`
|
||||||
|
* Default: `60309`
|
||||||
|
* pos: `table`
|
||||||
|
* x: `number`
|
||||||
|
* y: `number`
|
||||||
|
* z: `number`
|
||||||
|
* rot: `table` (`object`)
|
||||||
|
* x: `number`
|
||||||
|
* y: `number`
|
||||||
|
* z: `number`
|
||||||
|
* disable?: `table` (`object`)
|
||||||
|
* move?: `boolean`
|
||||||
|
* car?: `boolean`
|
||||||
|
* combat?: `boolean`
|
||||||
|
* mouse?: `boolean`
|
||||||
|
|
||||||
|
### Usage Example
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
**Example:**
|
|
||||||
```lua
|
```lua
|
||||||
if lib.progressBar({
|
if lib.progressBar({
|
||||||
duration = 2000,
|
duration = 2000,
|
||||||
@@ -70,54 +97,115 @@ if lib.progressBar({
|
|||||||
},
|
},
|
||||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
||||||
|
:::
|
||||||
|
|
||||||
|
```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')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
### lib.progressActive
|
## lib.progressActive
|
||||||
Returns true if a progress bar is currently active.
|
Returns true if a progress bar is currently active.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.progressActive()
|
lib.progressActive()
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
### lib.cancelProgress
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.progressActive()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
|
## lib.cancelProgress
|
||||||
If there is a progress bar active and the
|
If there is a progress bar active and the
|
||||||
progress bar can be cancelled then it cancels it.
|
progress bar can be cancelled then it cancels it.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.cancelProgress()
|
lib.cancelProgress()
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.cancelProgress()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
@@ -5,32 +5,63 @@ title: TextUI
|
|||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.showTextUI
|
## lib.showTextUI
|
||||||
Show the TextUI window.
|
Show the TextUI window.
|
||||||
|
|
||||||
**DO NOT** run this every tick, it's intented to be used as a toggle.
|
**DO NOT** run this every tick, it's intented to be used as a toggle.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- text: string
|
|
||||||
-- options: table (optional)
|
|
||||||
-- position: "right-center" or "left-center" or "top-center" (default - "right-center")
|
|
||||||
-- icon: string or table
|
|
||||||
-- iconColor: string
|
|
||||||
-- style: React.CSSProperties
|
|
||||||
lib.showTextUI(text, options)
|
lib.showTextUI(text, options)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.showTextUI(text, options)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* text: `string`
|
||||||
|
* options?: `table`
|
||||||
|
* position?: `'right-center'` or `'left-center'` or `'top-center'`
|
||||||
|
* Default: `'right-center'`
|
||||||
|
* icon?: `string` or `table` (`array`)
|
||||||
|
* iconColor?: `string`
|
||||||
|
* style?: React.CSSProperties
|
||||||
|
|
||||||
|
### Usage Example
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
|
||||||
**Example:**
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem label="Basic" value="basic">
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.showTextUI('[E] - Fuel vehicle')
|
lib.showTextUI('[E] - Fuel vehicle')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.showTextUI('[E] - Fuel vehicle')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
</TabItem>
|
|
||||||
<TabItem label="Custom style" value="custom">
|
### Custom styling
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.showTextUI('[E] - Pick apple', {
|
lib.showTextUI('[E] - Pick apple', {
|
||||||
@@ -43,22 +74,46 @@ lib.showTextUI('[E] - Pick apple', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||

|
```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'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
The icon library used is Font Awesome 6.0, if for the icon you define only a string
|

|
||||||
the default icon type will be `solid`.
|
|
||||||
If you want to use a different icon type, i.e
|
|
||||||
apple as a brand, you need to define icon as a table with the first value being
|
|
||||||
the icon type as a string, and the second being the icon name.
|
|
||||||
|
|
||||||
`icon = {'fab', 'apple'}`
|
|
||||||
|
|
||||||
### lib.hideTextUI
|
### lib.hideTextUI
|
||||||
Hides the currently visible TextUI window
|
Hides the currently visible TextUI window
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.hideTextUI()
|
lib.hideTextUI()
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.hideTextUI()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
@@ -4,11 +4,12 @@ Locale files should use the [ISO Language Code](http://www.lingoes.net/en/transl
|
|||||||
Players can use `setlocale [langcode]`, and admins can use `serverlocale [langcode]` to change the loaded file.
|
Players can use `setlocale [langcode]`, and admins can use `serverlocale [langcode]` to change the loaded file.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- str: string
|
|
||||||
-- ...: string | number
|
|
||||||
locale(str, ...)
|
locale(str, ...)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* str: `string`
|
||||||
|
* ...: `string` or `number`
|
||||||
|
|
||||||
Additional arguments can be sent to format the locale output.
|
Additional arguments can be sent to format the locale output.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ set datadog:site "datadoghq.com"
|
|||||||
```
|
```
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- source: string | number
|
|
||||||
-- event: string
|
|
||||||
-- message: string
|
|
||||||
-- ...: string
|
|
||||||
lib.logger(source, event, message, ...)
|
lib.logger(source, event, message, ...)
|
||||||
```
|
```
|
||||||
|
* source: `string` or `number`
|
||||||
|
* event: `string`
|
||||||
|
* message: `string`
|
||||||
|
* ...: `string`
|
||||||
|
|
||||||
|
|
||||||
Source is passed to ddsource and creates a tag. Could be playerId, identifier, -1, or server.
|
Source is passed to ddsource and creates a tag. Could be playerId, identifier, -1, or server.
|
||||||
Event is passed to ddservice and displays in the logs list.
|
Event is passed to ddservice and displays in the logs list.
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- coords: vector3
|
|
||||||
-- distance: number
|
|
||||||
-- data: table
|
|
||||||
lib.points.new(coords, distance, data)
|
lib.points.new(coords, distance, data)
|
||||||
|
```
|
||||||
|
* coords: `vector3`
|
||||||
|
* distance: `number`
|
||||||
|
* data: `table`
|
||||||
|
|
||||||
|
```lua
|
||||||
local point = lib.points.new(playerCoords, 5, {
|
local point = lib.points.new(playerCoords, 5, {
|
||||||
dunak = 'nerd',
|
dunak = 'nerd',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,12 +3,16 @@
|
|||||||
Starts a shapetest originating from the camera, extending to ~10m.
|
Starts a shapetest originating from the camera, extending to ~10m.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param flags number? Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
|
||||||
---@param p8 number? A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
|
||||||
---@return boolean hit
|
|
||||||
---@return number entityHit
|
|
||||||
---@return vector3 endCoords
|
|
||||||
---@return vector3 surfaceNormal
|
|
||||||
---@return number materialHash
|
|
||||||
function lib.raycast.cam(flags, p8) end
|
function lib.raycast.cam(flags, p8) end
|
||||||
```
|
```
|
||||||
|
* flags?: `number`
|
||||||
|
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
||||||
|
* p8?: `numbe`
|
||||||
|
* A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
* hit: `boolean`
|
||||||
|
* entityHit: `number`
|
||||||
|
* endCoords: `vector3`
|
||||||
|
* surfaceNormal: `vector3`
|
||||||
|
* materialHash: `number`
|
||||||
@@ -1,37 +1,125 @@
|
|||||||
Check if assets exist, such as models, and loads them into memory.
|
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.
|
Throws errors for invalid assets and returns true if the asset is loaded.
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.requestAnimDict
|
### lib.requestAnimDict
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- dict: string
|
|
||||||
-- timeout: number [default: 100]
|
|
||||||
lib.requestAnimDict(dict, timeout)
|
lib.requestAnimDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.requestAnimDict(dict, timeout)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* dict: `string`
|
||||||
|
* timeout: `number`
|
||||||
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestAnimSet
|
### lib.requestAnimSet
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- set: string
|
|
||||||
-- timeout: number [default: 100]
|
|
||||||
lib.requestAnimSet(set, timeout)
|
lib.requestAnimSet(set, timeout)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.requestAnimSet(set, timeout)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* set: `string`
|
||||||
|
* timeout: `number`
|
||||||
|
* Default: `100`
|
||||||
|
|
||||||
### lib.requestModel
|
### lib.requestModel
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- model: string
|
|
||||||
-- timeout: number [default: 100]
|
|
||||||
lib.requestModel(model, timeout)
|
lib.requestModel(model, timeout)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.requestModel(model, timeout)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* model: `string`
|
||||||
|
* timeout: `number`
|
||||||
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestStreamedTextureDict
|
### lib.requestStreamedTextureDict
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- dict: string
|
|
||||||
-- timeout: number [default: 100]
|
|
||||||
lib.requestStreamedTextureDict(dict, timeout)
|
lib.requestStreamedTextureDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
lib.requestStreamedTextureDict(dict, timeout)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* dict: `string`
|
||||||
|
* timeout: `number`
|
||||||
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestNamedPtfxAsset
|
### lib.requestNamedPtfxAsset
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- fxName: string
|
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||||
-- timeout: number [default: 100]
|
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
* fxName: `string`
|
||||||
|
* timeout: `number`
|
||||||
|
* Default: `100`
|
||||||
|
|
||||||
@@ -1,25 +1,66 @@
|
|||||||
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
|
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#L5
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.getVehicleProperties
|
### lib.getVehicleProperties
|
||||||
```lua
|
|
||||||
-- vehicle: entity
|
|
||||||
|
```ts
|
||||||
lib.getVehicleProperties(vehicle)
|
lib.getVehicleProperties(vehicle)
|
||||||
|
```
|
||||||
|
* vehicle: `entity`
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
### lib.setVehicleProperties
|
### lib.setVehicleProperties
|
||||||
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
||||||
```lua
|
|
||||||
-- vehicle: entity
|
|
||||||
-- props: table
|
|
||||||
lib.setVehicleProperties(vehicle, props)
|
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.setVehicleProperties(vehicle, props)
|
||||||
|
```
|
||||||
|
* vehicle: `entity`
|
||||||
|
* props: `table` (`object`)
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
||||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/client'
|
||||||
|
|
||||||
|
onNet('ox_lib:setVehicleProperties', (netid, data) => {
|
||||||
|
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Recommended usage
|
#### Recommended usage
|
||||||
The server should tell the owner of the entity to set properties, using the following trigger.
|
The server should tell the owner of the entity to set properties, using the following trigger.
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
### lib.versionCheck
|
### lib.versionCheck
|
||||||
Compares the resource version to the latest published release on GitHub.
|
Compares the resource version to the latest published release on GitHub.
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- repository: string
|
|
||||||
lib.versionCheck(repository)
|
lib.versionCheck(repository)
|
||||||
|
```
|
||||||
|
* repository: `string`
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.versionCheck('overextended/ox_lib')
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
|
||||||
lib.versionCheck('overextended/ox_lib')
|
lib.versionCheck('overextended/ox_lib')
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
|
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
|
||||||
@@ -1,9 +1,31 @@
|
|||||||
### lib.checkDependency
|
### lib.checkDependency
|
||||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||||
```lua
|
|
||||||
-- resource: string
|
|
||||||
-- version: string
|
|
||||||
lib.checkDependency(resource, version)
|
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
```lua
|
||||||
|
lib.checkDependency(resource, version)
|
||||||
|
```
|
||||||
|
* resource: `string`
|
||||||
|
* version: `string`
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/shared'
|
||||||
|
// import { checkDependency } from '@overextended/ox_lib/shared'
|
||||||
|
|
||||||
|
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
+47
-14
@@ -1,25 +1,51 @@
|
|||||||
An alternative to PolyZone utilising [glm.polygon](https://github.com/gottfriedleibniz/lua/blob/luaglm/EXTENDED.md#polygon).
|
Faster alternative to PolyZone utilising [glm.polygon](https://github.com/gottfriedleibniz/lua/blob/luaglm/EXTENDED.md#polygon).
|
||||||
|
|
||||||
|
## lib.zones.poly
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- data: table
|
|
||||||
-- points: vector3[] all z values must match
|
|
||||||
-- thickness: number (optional), default 4
|
|
||||||
-- debug: bool (optional)
|
|
||||||
lib.zones.poly(data)
|
lib.zones.poly(data)
|
||||||
|
```
|
||||||
|
* data: `table`
|
||||||
|
* points: `vector3[]`
|
||||||
|
* All z values must match
|
||||||
|
* thickness?: `number`
|
||||||
|
* Default: `4`
|
||||||
|
* onEnter: `function`(self: `table`)
|
||||||
|
* onExit: `function`(self: `table`)
|
||||||
|
* inside: `function`(self: `table`)
|
||||||
|
* debug?: `boolean`
|
||||||
|
|
||||||
-- data: table
|
## lib.zones.box
|
||||||
-- coords: vector3
|
|
||||||
-- size: vector3 (optional), default is vec3(4, 4, 4)
|
```lua
|
||||||
-- rotation: number (optional), angle in degrees
|
|
||||||
-- debug: bool (optional)
|
|
||||||
lib.zones.box(data)
|
lib.zones.box(data)
|
||||||
|
```
|
||||||
|
* data: `table`
|
||||||
|
* coords: `vector3`
|
||||||
|
* size?: `vector3`
|
||||||
|
* Default: `vec3(4, 4, 4)`
|
||||||
|
* rotation?: `number`
|
||||||
|
* Angle in degrees
|
||||||
|
* onEnter: `function`(self: `table`)
|
||||||
|
* onExit: `function`(self: `table`)
|
||||||
|
* inside: `function`(self: `table`)
|
||||||
|
* debug?: `boolean`
|
||||||
|
|
||||||
-- data: table
|
## lib.zones.sphere
|
||||||
-- coords: vector3
|
|
||||||
-- radius: number (optional), default is 2
|
```lua
|
||||||
-- debug: bool (optional)
|
|
||||||
lib.zones.sphere(data)
|
lib.zones.sphere(data)
|
||||||
```
|
```
|
||||||
|
* data: `table`
|
||||||
|
* coords: `vector3`
|
||||||
|
* radius?: `number`
|
||||||
|
* Default: `2`
|
||||||
|
* onEnter: `function`(self: `table`)
|
||||||
|
* onExit: `function`(self: `table`)
|
||||||
|
* inside: `function`(self: `table`)
|
||||||
|
* debug?: `boolean`
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
function onEnter(self)
|
function onEnter(self)
|
||||||
@@ -82,3 +108,10 @@ poly:remove()
|
|||||||
sphere:remove()
|
sphere:remove()
|
||||||
box:remove()
|
box:remove()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Zone creation script
|
||||||
|
Similarly to PolyZone, there is a zone creation script included.
|
||||||
|
|
||||||
|
To use it use the `/zone` with `poly`, `box` or `sphere` as args.
|
||||||
|
|
||||||
|
Available controls will be displayed on the right side.
|
||||||
@@ -3,11 +3,17 @@ title: Getting Started
|
|||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
ox_lib is a collection of Lua and UI functions to utilise in other resources.
|
ox_lib is a collection of Lua and UI functions to utilise in other resources.
|
||||||
|
|
||||||
The UI is built in React so the code needs to be compiled into standard JS.
|
The UI is built in React so the code needs to be compiled into standard JS.
|
||||||
If you don't know how to do this then please download the [release](https://github.com/overextended/ox_lib/releases/latest) (ox_lib.zip) which is *already* compiled into a working resource.
|
If you don't know how to do this then please download the [release](https://github.com/overextended/ox_lib/releases/latest) (ox_lib.zip) which is *already* compiled into a working resource.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
To enable the library inside of your resource just add `@ox_lib/init.lua` to `shared_scripts` or
|
To enable the library inside of your resource just add `@ox_lib/init.lua` to `shared_scripts` or
|
||||||
a `shared_script` in your `fxmanifest.lua` file.
|
a `shared_script` in your `fxmanifest.lua` file.
|
||||||
|
|
||||||
@@ -22,6 +28,30 @@ Or if the library is the only shared script you use you can do:
|
|||||||
```lua
|
```lua
|
||||||
shared_script '@ox_lib/init.lua'
|
shared_script '@ox_lib/init.lua'
|
||||||
```
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
Npm package for the lib does **not** support all the functions that are available for Lua.
|
||||||
|
|
||||||
|
All supported functions are located inside the `resource` folder in the lib.
|
||||||
|
:::
|
||||||
|
|
||||||
|
You can get the npm package [here](https://npmjs.com/package/@overextended/ox_library).
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
You can either import the whole library object which contains all the functions for that scope (client/server/shared) or
|
||||||
|
you can deconstruct it and import the functions you find needed at the time.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import lib from '@overextended/ox_lib/server'
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { versionCheck } from '@overextended/ox_lib/server'
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
**ACE Permissions:**
|
**ACE Permissions:**
|
||||||
```
|
```
|
||||||
@@ -35,6 +65,29 @@ That's it!
|
|||||||
You can now use the library functions inside of your resource, check the rest of the
|
You can now use the library functions inside of your resource, check the rest of the
|
||||||
documentation to see how to utilise them.
|
documentation to see how to utilise them.
|
||||||
|
|
||||||
|
# Using icons for interface functions
|
||||||
|
|
||||||
|
The icon library used is Font Awesome 6.0, if for the icon you define only a string
|
||||||
|
the default icon type will be `solid`.
|
||||||
|
If you want to use a different icon type, i.e
|
||||||
|
apple as a brand, you need to define icon as a table (`array`) with the first value being
|
||||||
|
the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
```lua
|
||||||
|
icon = {'fab', 'apple'}
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
icon: ['fab', 'apple']
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
# Building the UI
|
# Building the UI
|
||||||
|
|
||||||
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then
|
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then
|
||||||
|
|||||||
Generated
+2379
-1728
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user