mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
move ox_lib modules to subdirectory
This commit is contained in:
1 parent
97b129e0fa
commit
ba094e1fb3
42 files changed
+1
-1
No files matched your search
@@ -0,0 +1,127 @@
|
||||
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
|
||||
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.addAce
|
||||
|
||||
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.addAce(principal, ace, allow)
|
||||
|
||||
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
|
||||
|
||||
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.removeAce(principal, ace, allow)
|
||||
|
||||
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
|
||||
|
||||
Assigns a principal to a parent principal. Children inherit permissions from the parent.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.addPrincipal(child, parent)
|
||||
|
||||
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
|
||||
|
||||
Removes a principal from a parent principal.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.removePrincipal(child, parent)
|
||||
|
||||
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`
|
||||
@@ -0,0 +1,50 @@
|
||||
Registers commands and simplifies argument validation, permissions, and chat suggestions.
|
||||
|
||||
```lua
|
||||
lib.addCommand(commandName, properties, cb)
|
||||
```
|
||||
|
||||
- commandName: `string` or `string[]`
|
||||
- properties: `table` or `false`
|
||||
- help?: `string`
|
||||
- restricted?: `boolean` or `string` or `string[]`
|
||||
- params?: `table[]`
|
||||
- name: `string`
|
||||
- help?: `string`
|
||||
- type?: `'number'` or `'playerId'` or `'string'`
|
||||
- optional?: `boolean`
|
||||
|
||||
```lua
|
||||
lib.addCommand('giveitem', {
|
||||
help = 'Gives an item to a player',
|
||||
params = {
|
||||
{
|
||||
name = 'target',
|
||||
type = 'playerId',
|
||||
help = 'Target player\'s server id', },
|
||||
{
|
||||
name = 'item',
|
||||
type = 'string',
|
||||
help = 'Name of the item to give',
|
||||
},
|
||||
{
|
||||
name = 'count',
|
||||
type = 'number',
|
||||
help = 'Amount of the item to give, or blank to give 1',
|
||||
optional = true,
|
||||
},
|
||||
{
|
||||
name = 'metatype',
|
||||
help = 'Sets the item\'s "metadata.type"',
|
||||
optional = true,
|
||||
},
|
||||
},
|
||||
restricted = 'group.admin'
|
||||
}, function(source, args, raw)
|
||||
local item = Items(args.item)
|
||||
|
||||
if item then
|
||||
Inventory.AddItem(args.target, item.name, args.count or 1, args.metatype)
|
||||
end
|
||||
end)
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
```lua
|
||||
lib.addKeybind(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* name: `string`
|
||||
* description: `string`
|
||||
* defaultKey?: `string`
|
||||
* Default: None
|
||||
* currentKey: `string`
|
||||
* disabled?: `boolean`
|
||||
* disable?: `function`(self: `table`, toggle: `boolean`)
|
||||
* onPressed?: `function`(self: `table`)
|
||||
* onReleased?: `function`(self: `table`)
|
||||
|
||||
```lua
|
||||
local keybind = lib.addKeybind({
|
||||
name = 'respects',
|
||||
description = 'press F to pay respects',
|
||||
defaultKey = 'F',
|
||||
onPressed = function(self)
|
||||
print(('pressed %s (%s)'):format(self.currentKey, self.name))
|
||||
end,
|
||||
onReleased = function(self)
|
||||
print(('released %s (%s)'):format(self.currentKey, self.name))
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
Keybinds can be enabled/disabled by using the disable method.
|
||||
|
||||
```lua
|
||||
keybind:disable(true) -- disable
|
||||
keybind:disable(false) -- enable
|
||||
```
|
||||
@@ -0,0 +1,73 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
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.
|
||||
|
||||
## States
|
||||
|
||||
- ped: `number`
|
||||
- player entity id
|
||||
- playerId: `number`
|
||||
- player id
|
||||
- serverId: `number`
|
||||
- player server id
|
||||
- vehicle: `number` or `false`
|
||||
- vehicle entity id
|
||||
- seat: `number` or `false`
|
||||
- vehicle seat index
|
||||
- resource: `string`
|
||||
- invoking resource name
|
||||
- weapon: `number` or `false`
|
||||
- current ped weapon
|
||||
- coords: `vec3`
|
||||
- current player coords
|
||||
- only populated if using `zones` or `points`
|
||||
- cannot be listened for with `onCache`
|
||||
- mount: `number` or `false` (RedM only)
|
||||
- mount entity id
|
||||
|
||||
## lib.onCache
|
||||
|
||||
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
|
||||
lib.onCache('vehicle', function(value)
|
||||
print('old vehicle:', cache.vehicle)
|
||||
print('new vehicle:', value)
|
||||
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>
|
||||
@@ -0,0 +1,48 @@
|
||||
## Trigger Server Callback
|
||||
|
||||
### triggerServerCallback
|
||||
|
||||
```ts
|
||||
triggerServerCallback(eventName, delay, ...args)
|
||||
```
|
||||
|
||||
* eventName: `string`
|
||||
* delay: `number` or `null`
|
||||
* ..args: `any`
|
||||
|
||||
## Register Client Callback
|
||||
|
||||
### onServerCallback
|
||||
|
||||
```ts
|
||||
onServerCallback(eventName, cb)
|
||||
```
|
||||
|
||||
* eventName: `string`
|
||||
* cb: `function`(...args: `any`)
|
||||
|
||||
## Usage Example
|
||||
|
||||
For this example to fully make sense take a look at the example on the [server](./Server#usage-example) page for the callbacks.
|
||||
|
||||
```ts
|
||||
import { onServerCallback, triggerServerCallback } from '@overextended/ox_lib/client'
|
||||
```
|
||||
|
||||
```ts
|
||||
onServerCallback('test:client', (...args: [number, number, string]) => {
|
||||
console.log(args);
|
||||
return {
|
||||
clientValue: 'Value from the client',
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
```ts
|
||||
setTimeout(async () => {
|
||||
const args = [1, null, 3, null, null, 6];
|
||||
const response = await triggerServerCallback<{ serverValue: number }>('test:server', 1, args);
|
||||
if (!response) return;
|
||||
console.log('Response from server', response);
|
||||
}, 100);
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
## Trigger Client Callback
|
||||
|
||||
### triggerClientCallback
|
||||
|
||||
```ts
|
||||
triggerClientCallback(eventName, playerId, ...args)
|
||||
```
|
||||
|
||||
* eventName: `string`
|
||||
* playerId: `number`
|
||||
* ...args: `any`
|
||||
|
||||
## Register Client Callback
|
||||
|
||||
### onClientCallback
|
||||
|
||||
```ts
|
||||
onClientCallback(eventName, cb)
|
||||
```
|
||||
|
||||
* eventName: `string`
|
||||
* cb: `function`(playerId: `number`, ...args: `any`)
|
||||
|
||||
## Usage Example
|
||||
|
||||
For this example to fully make sense take a look at the example on the [client](./Client#usage-example) page for the callbacks.
|
||||
|
||||
```ts
|
||||
import { onClientCallback, triggerClientCallback } from '@overextended/ox_lib/server';
|
||||
```
|
||||
|
||||
```ts
|
||||
onClientCallback('test:server', (playerId, ...args: [number, null, number, null, null, number]) => {
|
||||
console.log('onClientCallback', playerId, ...args);
|
||||
return {
|
||||
serverValue: 3000,
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
```ts
|
||||
setTimeout(async () => {
|
||||
const response = await triggerClientCallback<{ clientValue: string }>('test:client', 1, [1, null, 3, null, null, 6])
|
||||
if (!response) return;
|
||||
console.log(response.clientValue);
|
||||
console.log('Response from client', response);
|
||||
}, 100);
|
||||
```
|
||||
@@ -0,0 +1,57 @@
|
||||
## Trigger Server Callback
|
||||
|
||||
### lib.callback
|
||||
|
||||
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)
|
||||
print(count)
|
||||
end, 'water', {type = 'fresh'})
|
||||
```
|
||||
|
||||
### lib.callback.await
|
||||
|
||||
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'})
|
||||
print(count)
|
||||
```
|
||||
|
||||
## Register Client Callback
|
||||
|
||||
### lib.callback.register
|
||||
|
||||
Register an event handler for responding to server requests.
|
||||
|
||||
```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)
|
||||
```
|
||||
@@ -0,0 +1,62 @@
|
||||
## Trigger Client Callback
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
## Register Server Callback
|
||||
|
||||
### lib.callback.register
|
||||
|
||||
Register an event handler for responding to client requests.
|
||||
|
||||
```lua
|
||||
lib.callback.register(name, cb)
|
||||
```
|
||||
|
||||
- name: `string`
|
||||
- cb: `function`
|
||||
|
||||
```lua
|
||||
lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
|
||||
local inventory = target and Inventory(target) or Inventory(source)
|
||||
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
|
||||
end)
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
# Cron
|
||||
|
||||
A Lua implementation of cron, allowing tasks to be scheduled to run periodically at fixed times, dates, and intervals.
|
||||
|
||||
## Cron expression
|
||||
|
||||
A string containing five values separated by white spaces, representing a set of times to execute a task.
|
||||
|
||||
| Field | Valid values |
|
||||
| ------------ | ------------------- |
|
||||
| Minutes | `0-59` |
|
||||
| Hours | `0-23` |
|
||||
| Day of month | `1-31` |
|
||||
| Month | `1-12` or `jan-dec` |
|
||||
| Day of week | `1-7` or `sun-sat` |
|
||||
|
||||
**Note:** Day of the week is set to match `os.date` and starts at 1, unlike the cron-standard which starts at 0.
|
||||
|
||||
### `*` Wildcards
|
||||
Represents all values, e.g. `* * * * *` will run every minute, or `* * * * 1` will run every minute on Sunday.
|
||||
|
||||
### `,` Lists
|
||||
Commas can be used to create a list of values, e.g. `* * * * sun,mon,tue` will run every minute on Sunday, Monday, and Tuesday.
|
||||
|
||||
### `-` Ranges
|
||||
Dashes define a range of values, e.g. `10-30 * * * *` will start running the task at the 10th minute, and every minute until the 30th minute.
|
||||
|
||||
### `/` Steps
|
||||
Slashes can be used for step values, e.g. `* */4 * * *` will run every 4 hours and is shorthand for `* 0,4,8,12,16,20 * * *`.
|
||||
|
||||
## Functions
|
||||
|
||||
### lib.cron.new
|
||||
|
||||
Creates a new [cronjob](https://en.wikipedia.org/wiki/Cron), scheduling a task to run at fixed times or intervals.
|
||||
|
||||
```lua
|
||||
lib.cron.new(expression, job, options)
|
||||
```
|
||||
|
||||
* expression:
|
||||
* string A cron expression such as `* * * * *` representing minute, hour, day, month, and day of the week
|
||||
* job:
|
||||
* fun(task: `OxTask`, date: `osdate`)
|
||||
* options?:
|
||||
* debug?: `boolean`
|
||||
|
||||
**returns**: OxTask
|
||||
@@ -0,0 +1,31 @@
|
||||
### lib.disableControls
|
||||
|
||||
Call on frame to disable all stored keys.
|
||||
|
||||
```lua
|
||||
lib.disableControls()
|
||||
```
|
||||
|
||||
### lib.disableControls:Add
|
||||
|
||||
```lua
|
||||
lib.disableControls:Add(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
|
||||
### lib.disableControls:Remove
|
||||
|
||||
```lua
|
||||
lib.disableControls:Remove(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
|
||||
### lib.disableControls:Clear
|
||||
|
||||
```lua
|
||||
lib.disableControls:Clear(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
@@ -0,0 +1,17 @@
|
||||
### lib.getClosestObject
|
||||
|
||||
Get the object handle and coords of the closest object to a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getClosestObject(coords, maxDistance)
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
* The max distance to check.
|
||||
|
||||
Return:
|
||||
|
||||
* ped?: `number`
|
||||
* coords?: `number`
|
||||
@@ -0,0 +1,17 @@
|
||||
### lib.getClosestPed
|
||||
|
||||
Get the ped handle and coords of the closest ped to a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getClosestPed(coords, maxDistance)
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
* The max distance to check.
|
||||
|
||||
Return:
|
||||
|
||||
* ped?: `number`
|
||||
* coords?: `number`
|
||||
@@ -0,0 +1,20 @@
|
||||
### lib.getClosestPlayer
|
||||
|
||||
Get the id, ped, and coords of the closest player to a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getClosestPlayer(coords, maxDistance, includePlayer)
|
||||
```
|
||||
|
||||
* 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?: `number`
|
||||
* playerCoords?: `vector3`
|
||||
@@ -0,0 +1,19 @@
|
||||
### lib.getClosestVehicle
|
||||
|
||||
Get the id and coords of the closest vehicle to a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle)
|
||||
```
|
||||
|
||||
* 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`
|
||||
@@ -0,0 +1,16 @@
|
||||
### lib.getNearbyObjects
|
||||
|
||||
Get the object handle and coords of all objects within range of a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getNearbyObjects(coords, maxDistance)
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
* The max distance to check.
|
||||
|
||||
Return:
|
||||
|
||||
* `{ object: number, coords: vector3 }[]`
|
||||
@@ -0,0 +1,16 @@
|
||||
### lib.getNearbyPeds
|
||||
|
||||
Get the ped handle and coords of all peds within range of a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getNearbyPeds(coords, maxDistance)
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
* The max distance to check.
|
||||
|
||||
Return:
|
||||
|
||||
* `{ ped: number, coords: vector3 }[]`
|
||||
@@ -0,0 +1,18 @@
|
||||
### lib.getNearbyPlayers
|
||||
|
||||
Get the id, ped, and coords of all players within range of a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getNearbyPlayers(coords, maxDistance, includePlayer)
|
||||
```
|
||||
|
||||
* 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:
|
||||
|
||||
* `{ id: number, ped: number, coords: vector3 }[]`
|
||||
@@ -0,0 +1,18 @@
|
||||
### lib.getNearbyVehicles
|
||||
|
||||
Get the id and coords of all vehicles within range of a set of coordinates.
|
||||
|
||||
```lua
|
||||
lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle)
|
||||
```
|
||||
|
||||
* 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, coords: vector3 }[]`
|
||||
@@ -0,0 +1,126 @@
|
||||
---
|
||||
title: Alert Dialog
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Simple alert dialog that can display a message to the player.
|
||||
Returns whether the player pressed the confirm button or canceled the dialog.
|
||||
|
||||
### lib.alertDialog
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Client'>
|
||||
|
||||
```lua
|
||||
lib.alertDialog(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='Server'>
|
||||
|
||||
```lua
|
||||
TriggerClientEvent('ox_lib:alertDialog', source, data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
</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'
|
||||
|
||||
lib.alertDialog(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* data: `table` (`object`)
|
||||
* header: `string`
|
||||
* Dialog title.
|
||||
* content: `string`
|
||||
* Dialog body content, supports markdown.
|
||||
* centered?: `boolean`
|
||||
* Centers the dialog vertically and horizontally.
|
||||
* cancel?: `boolean`
|
||||
* Displays a cancel button (ESC is still available if this is not defined).
|
||||
* size?: `'xs'` or `'sm'` or `'md'` or `'lg'` or `'xl'`
|
||||
* overflow?: `boolean`
|
||||
* labels?: `table`
|
||||
* Allows you to define the displayed labels for cancel and/or confirm buttons.
|
||||
* cancel?: `string`
|
||||
* confirm?: `string`
|
||||
|
||||
Returns `confirm` if the player pressed the confirm button, otherwise if the player pressed the cancel button
|
||||
or has exited the dialog with ESC the return will be `cancel`.
|
||||
|
||||
### lib.closeAlertDialog
|
||||
|
||||
Force closes the active alert dialog and sets its return data as `nil`
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
**Example:**
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
local alert = lib.alertDialog({
|
||||
header = 'Hello there',
|
||||
content = 'General Kenobi \n Markdown support!',
|
||||
centered = true,
|
||||
cancel = true
|
||||
})
|
||||
|
||||
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>
|
||||
|
||||

|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Clipboard
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
|
||||
|
||||
### lib.setClipboard
|
||||
|
||||
Sets the player's clipboard to the specified string value.
|
||||
|
||||
:::caution
|
||||
|
||||
Will not work if focus is already taken by some NUI component.
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
To create a new line use `\t\n` not just `\n` in your string.
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* value: `string`
|
||||
@@ -0,0 +1,391 @@
|
||||
---
|
||||
title: Context Menu
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.registerContext
|
||||
|
||||
Used for registering a context menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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; has markdown support.
|
||||
* menu?: `string`
|
||||
* Menu identifier - if defined there will be a back arrow next to the menu title that will take you to the menu you defined.
|
||||
* canClose: `boolean`
|
||||
* If set to false the user won't be able to exit the menu without pressing one of the buttons.
|
||||
* onExit?: `function`
|
||||
* Function that will be ran when the user closes their context menu with ESC.
|
||||
* onBack?: `function`
|
||||
* Function that will be ran when the user presses the back button to return to a previous menu.
|
||||
* options: `table` (`object` or `array`)
|
||||
* item: `key` (`string`) or `table` (`object`)
|
||||
* title?: `string`
|
||||
* If not using keys then sets the title for the button; has markdown support.
|
||||
* disabled?: `boolean`
|
||||
* Grays out the button and makes it unclickable.
|
||||
* menu?: `string`
|
||||
* Menu identifier that the button will take you to, when defined an arrow.
|
||||
* onSelect: `function`
|
||||
* Function that's ran when the button is clicked.
|
||||
* icon?: `string`
|
||||
* FontAwesome icon that will be displayed on the left side, works the same as notification and textui icons.
|
||||
* Also supports image urls, png and webp files but are not recommend to use over font awesome icons.
|
||||
* iconColor?: `string`
|
||||
* Colour of the displayed icon.
|
||||
* progress?: `number`
|
||||
* Adds a progress bar filled to this percentage
|
||||
* colorScheme?: `string`
|
||||
* Sets the color scheme of the progress bar. Current options can be found here:
|
||||
* https://mantine.dev/theming/colors/#default-colors
|
||||
* For example: `blue` or `teal`
|
||||
* arrow?: `boolean`
|
||||
* Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it.
|
||||
* description?: `string`
|
||||
* Description that will appear under the button title that is defined as a key; has markdown support.
|
||||
* image?: `string`
|
||||
* Url to an image that will be displayed in the button's metadata.
|
||||
* metadata?: `string[]` or `object` or `array`
|
||||
* Information that will display on the side upon hovering a button.
|
||||
* label: `string`
|
||||
* value: `any`
|
||||
* progress?: `number`
|
||||
* Display a progress bar in the metadata.
|
||||
* event?: `string`
|
||||
* Event that the button is going to trigger.
|
||||
* serverEvent?: `string`
|
||||
* Server event that the button is going to trigger.
|
||||
* args?: `any`
|
||||
* Arguments that will be sent to the events or onSelect function.
|
||||
|
||||
You can register as many context menus in one `lib.registerContext` function
|
||||
as you'd like.
|
||||
|
||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
||||
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys, otherwise not using keys and instead using tables will make the menu be in the order you define it as.
|
||||
|
||||
### lib.showContext
|
||||
|
||||
Opens a registered context menu by it's id.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
|
||||
### lib.hideContext
|
||||
|
||||
Hides any currently visible context menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
Returns the id of the currently open context menu.
|
||||
|
||||
If no context menu is open returns `nil`.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
:::tip
|
||||
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.registerContext({
|
||||
id = 'some_menu',
|
||||
title = 'Some context menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Empty button',
|
||||
},
|
||||
{
|
||||
title = 'Disabled button',
|
||||
description = 'This button is disabled',
|
||||
icon = 'hand',
|
||||
disabled = true
|
||||
},
|
||||
{
|
||||
title = 'Example button',
|
||||
description = 'Example button description',
|
||||
icon = 'circle',
|
||||
onSelect = function()
|
||||
print("Pressed the button!")
|
||||
end,
|
||||
metadata = {
|
||||
{label = 'Value 1', value = 'Some value'},
|
||||
{label = 'Value 2', value = 300}
|
||||
},
|
||||
},
|
||||
{
|
||||
title = 'Menu button',
|
||||
description = 'Takes you to another menu!',
|
||||
menu = 'other_menu',
|
||||
icon = 'bars'
|
||||
},
|
||||
{
|
||||
title = 'Event button',
|
||||
description = 'Open a menu from the event and send event data',
|
||||
icon = 'check',
|
||||
event = 'test_event',
|
||||
arrow = true,
|
||||
args = {
|
||||
someValue = 500
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.registerContext({
|
||||
id: 'some_menu',
|
||||
title: 'Some context menu',
|
||||
options: [
|
||||
{
|
||||
title: 'Empty button',
|
||||
},
|
||||
{
|
||||
title: 'Disabled button',
|
||||
description: 'This button is disabled',
|
||||
icon: 'hand',
|
||||
disabled: true
|
||||
},
|
||||
{
|
||||
title: 'Example button',
|
||||
description: 'Example button description',
|
||||
icon: 'circle',
|
||||
onSelect: () => {
|
||||
console.log("Pressed the button!")
|
||||
},
|
||||
metadata: [
|
||||
{label: 'Value 1', value: 'Some value'},
|
||||
{label: 'Value 2', value: 300}
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Menu button',
|
||||
description: 'Takes you to another menu!',
|
||||
menu: 'other_menu',
|
||||
icon: 'bars'
|
||||
},
|
||||
{
|
||||
title: 'Event button',
|
||||
description: 'Open a menu from the event and send event data',
|
||||
icon: 'check',
|
||||
event: 'test_event',
|
||||
arrow: true,
|
||||
args: {
|
||||
someValue: 500
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Then we can also register our second menu called `other_menu`
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.registerContext({
|
||||
id = 'other_menu',
|
||||
title = 'Other context menu',
|
||||
menu = 'some_menu',
|
||||
onBack = function()
|
||||
print('Went back!')
|
||||
end,
|
||||
options = {
|
||||
{
|
||||
title = 'Nothing here'
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
lib.registerContext({
|
||||
id: 'other_menu',
|
||||
title: 'Other context menu',
|
||||
menu: 'some_menu',
|
||||
onBack: () => {
|
||||
console.log('Went back!')
|
||||
},
|
||||
options: [
|
||||
{
|
||||
title: 'Nothing here'
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
And the event that we are going to run from the `some_menu` menu, which is going to open another menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('test_event', function(args)
|
||||
lib.registerContext({
|
||||
id = 'event_menu',
|
||||
title = 'Event menu',
|
||||
menu = 'some_menu',
|
||||
options = {
|
||||
{
|
||||
title = 'Event value: '..args.someValue,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lib.showContext('event_menu')
|
||||
end)
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
onNet('test_event', (args: {someValue: number}) => {
|
||||
lib.registerContext({
|
||||
id:'event_menu',
|
||||
title:'Event menu',
|
||||
menu:'some_menu',
|
||||
options: [
|
||||
{
|
||||
title: `Event value: ${args.someValue}`,
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
lib.showContext('event_menu')
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
Lastly we register a test command to show the `some_menu` menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
RegisterCommand('testcontext', function()
|
||||
lib.showContext('some_menu')
|
||||
end)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
```ts
|
||||
RegisterCommand('testcontext', () => {
|
||||
lib.showContext('some_menu')
|
||||
})
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
The data from the `args` table in the menu is passed as a first argument to the event you register.
|
||||
|
||||
Using this event we also register a new context menu with it's own options.
|
||||
|
||||
By defining a `menu` param to be the id of the first menu we can get the back arrow button next to the menu title that will take us back.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
@@ -0,0 +1,275 @@
|
||||
---
|
||||
title: Input Dialog
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
The input dialog window allows you to take data from the user
|
||||
by setting input fields.
|
||||
|
||||
### lib.inputDialog
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.inputDialog(heading, rows, options)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* heading: `string`
|
||||
* rows: `string[]` or `table` (`array`)
|
||||
* type: `'input'` or `'number'` or `'checkbox'` or `'select'` or `'slider'` or `'color'` or `'multi-select'` or `'date'` or `'date-range'` or `'time'` or `'textarea'`
|
||||
* options?: `table`(`object`)
|
||||
* allowCancel: `boolean`
|
||||
* If true the user will not be able to cancel and close the input dialog until submitted.
|
||||
|
||||
Available properties per field type:
|
||||
|
||||
* input
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* password?: `boolean`
|
||||
* min?: `number`
|
||||
* max?: `number`
|
||||
|
||||
* number
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* max?: `number`
|
||||
|
||||
* checkbox
|
||||
* label: `string`
|
||||
* checked?: `boolean`
|
||||
* disabled?: `boolean`
|
||||
* required?: `boolean`
|
||||
|
||||
* select and multi-select
|
||||
* label: `string`
|
||||
* options: `table`(`array`)
|
||||
* value: `string`
|
||||
* label?: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* value of the default option.
|
||||
* clearable?: `boolean`
|
||||
|
||||
* slider
|
||||
* label: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* max?: `number`
|
||||
* step?: `number`
|
||||
|
||||
* color
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* format?: `'hex'` | `'hexa'` | `'rgb'` | `'rgba'` | `'hsl'` | `'hsla'`;
|
||||
|
||||
* date
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string` or `true`
|
||||
* True defaults to current date
|
||||
* format?: `string`
|
||||
* Date format to display in the field
|
||||
* clearable?: `boolean`
|
||||
|
||||
* date-range
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `[string, string]`
|
||||
* format?: `string`
|
||||
* Date format to display in the field
|
||||
* clearable?: `boolean`
|
||||
|
||||
* time
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `string`
|
||||
* format?: `'12'` or `'24'`
|
||||
* clearable?: `boolean`
|
||||
|
||||
* textarea
|
||||
* label: `string`
|
||||
* description?: `string`
|
||||
* placeholder?: `string`
|
||||
* icon?: `string`
|
||||
* required? `boolean`
|
||||
* disabled?: `boolean`
|
||||
* default?: `number`
|
||||
* min?: `number`
|
||||
* Minimum amount of rows the text area will take.
|
||||
* max?: `number`
|
||||
* Maxmimum amount of rows the text area will take, when exceeded goes into overflow.
|
||||
* autosize?: `boolean`
|
||||
* If true text area will grow with content until max rows are reached.
|
||||
|
||||
The callback data is promise based meaning that the thread will not continue executing until the user either sends the data or exits the popup.
|
||||
|
||||
The data returned will be a table (array), indexes represent the rows sent to the dialog, so if we want data from the first field that would be index `1` (`0`), if we want data from the third field, that would be index `3` (`2`), etc...
|
||||
|
||||
:::caution
|
||||
|
||||
Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value.
|
||||
:::
|
||||
|
||||
### lib.closeInputDialog
|
||||
|
||||
Force closes the active input dialog and sets its return data as `nil`
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Usage Example
|
||||
|
||||
### Basic
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
|
||||
|
||||
if not input then return end
|
||||
print(input, input[1], input[2])
|
||||
```
|
||||
|
||||
</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('Basic dialog', ['First row', 'Second row'])
|
||||
|
||||
if (!input) return
|
||||
console.log(input, input[0], input[1])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||
|
||||
### Advanced
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="Lua">
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Dialog title', {
|
||||
{type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16},
|
||||
{type = 'number', label = 'Number input', description = 'Some number description', icon = 'hashtag'},
|
||||
{type = 'checkbox', label = 'Simple checkbox'},
|
||||
{type = 'color', label = 'Colour input', default = '#eb4034'},
|
||||
{type = 'date', label = 'Date input', icon = {'far', 'calendar'}, default = true, format = "DD/MM/YYYY"}
|
||||
})
|
||||
|
||||
print(json.encode(input))
|
||||
|
||||
-- Getting r, g and b values from colour picker
|
||||
local r, g, b = string.match(input[4], "rgb%((%d+), (%d+), (%d+)%)")
|
||||
|
||||
-- Transforming unit date return to be used with Lua's os library
|
||||
local date = input[5] / 1000
|
||||
```
|
||||
|
||||
</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: 'Text input', description: 'Some input description', required: true, min: 3, max: 16},
|
||||
{type: 'number', label: 'Number input', description: 'Some number description', icon: 'hashtag'},
|
||||
{type: 'checkbox', label: 'Simple checkbox'},
|
||||
{type: 'color', label: 'Colour input', default: '#eb4034'},
|
||||
{type: 'date', label: 'Date input', icon: ['far', 'calendar'], default: true, format: "DD/MM/YYYY"}
|
||||
]);
|
||||
|
||||
console.log(JSON.stringify(input, null, 2));
|
||||
|
||||
// Getting r, g and b values from colour picker
|
||||
const regExp = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
||||
const colourInput = input[3];
|
||||
|
||||
const color = regExp.exec(colourInput);
|
||||
|
||||
if (!color) return
|
||||
|
||||
console.log(+color[1], +color[2], +color[3])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

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

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

|
||||
@@ -0,0 +1,319 @@
|
||||
---
|
||||
title: Progress
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## lib.progressBar
|
||||
|
||||
Displays a running progress bar.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressBar(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</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'>
|
||||
|
||||
```lua
|
||||
if lib.progressBar({
|
||||
duration = 2000,
|
||||
label = 'Drinking water',
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = {
|
||||
car = true,
|
||||
},
|
||||
anim = {
|
||||
dict = 'mp_player_intdrink',
|
||||
clip = 'loop_bottle'
|
||||
},
|
||||
prop = {
|
||||
model = `prop_ld_flow_bottle`,
|
||||
pos = vec3(0.03, 0.03, 0.02),
|
||||
rot = vec3(0.0, 0.0, -1.5)
|
||||
},
|
||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||
```
|
||||
|
||||
</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
|
||||
|
||||
Similar to `lib.progressBar` except it displays a circle and you can define a position.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.progressCircle(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
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'>
|
||||
|
||||
```lua
|
||||
if lib.progressCircle({
|
||||
duration = 2000,
|
||||
position = 'bottom',
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = {
|
||||
car = true,
|
||||
},
|
||||
anim = {
|
||||
dict = 'mp_player_intdrink',
|
||||
clip = 'loop_bottle'
|
||||
},
|
||||
prop = {
|
||||
model = `prop_ld_flow_bottle`,
|
||||
pos = vec3(0.03, 0.03, 0.02),
|
||||
rot = vec3(0.0, 0.0, -1.5)
|
||||
},
|
||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||
```
|
||||
|
||||
</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
|
||||
|
||||
Returns true if a progress bar is currently active.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.progressActive()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## lib.cancelProgress
|
||||
|
||||
If there is a progress bar active and the
|
||||
progress bar can be cancelled then it cancels it.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.cancelProgress()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
@@ -0,0 +1,324 @@
|
||||
---
|
||||
title: Radial Menu
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
* Radial menu has a global menu that's by default accessed with `z` and only displays when there is at least one item.
|
||||
* You can add and remove items from the global menu using `lib.addRadialItem` and `lib.removeRadialItem`.
|
||||
* Use `lib.registerRadial` for creating sub menus and use the `menu` property on the items to open those sub menus.
|
||||
|
||||
### lib.addRadialItem
|
||||
|
||||
Item or array of items added to the global radial menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.addRadialItem(items)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
* Id that is used for removing options.
|
||||
* icon: `string`
|
||||
* label: `string`
|
||||
* Label uses ` \n` to insert a newline
|
||||
* menu?: `string`
|
||||
* Id of a menu to open.
|
||||
* onSelect: `function(currentMenu: string | nil, itemIndex: number)` | `string`
|
||||
* Function that's ran when a user clicks the item.
|
||||
* keepOpen?: `boolean`
|
||||
|
||||
### lib.removeRadialItem
|
||||
|
||||
Id of an item to be removed from the global menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.removeRadialItem(item)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
|
||||
### lib.clearRadialItems
|
||||
|
||||
Removes all items from the radial menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.clearRadialItems()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.clearRadialItems()
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### lib.registerRadial
|
||||
|
||||
Registers a radial sub menu with predefined options.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.registerRadial(radial)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
* Unique menu id used to open with `menu` prop on an item.
|
||||
* items: `array`
|
||||
* icon: `string`
|
||||
* label: `string`
|
||||
* Label uses ` \n` to insert a newline
|
||||
* menu?: `string`
|
||||
* Id of a menu to open.
|
||||
* onSelect?: `function(currentMenu: string | nil, itemIndex: number)` | `string`
|
||||
* Function that's ran when a user clicks the item.
|
||||
|
||||
### lib.hideRadial
|
||||
|
||||
Hides the radial menu if one is open.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.hideRadial()
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideRadial()
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
### lib.disableRadial
|
||||
|
||||
Disallow players from opening the radial menu.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.disableRadial(state)
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.disableRadial(state)
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* state: `boolean`
|
||||
* Whether or not radial menu should be disabled
|
||||
|
||||
### Usage Example
|
||||
|
||||
:::tip
|
||||
|
||||
When adding radial menu items whether they are global or for a sub menu, make sure to stick to short as possible labels
|
||||
as long labels will look out of place and should not be used with the radial menu because of it's density.
|
||||
:::
|
||||
|
||||
|
||||
Here's a use case example with some global options and an option utilising the lib's points system.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
exports('myMenuHandler', function(menu, item)
|
||||
print(menu, item)
|
||||
|
||||
if menu == 'police_menu' and item == 1 then
|
||||
print('Handcuffs')
|
||||
end
|
||||
end)
|
||||
|
||||
lib.registerRadial({
|
||||
id = 'police_menu',
|
||||
items = {
|
||||
{
|
||||
label = 'Handcuff',
|
||||
icon = 'handcuffs',
|
||||
onSelect = 'myMenuHandler'
|
||||
},
|
||||
{
|
||||
label = 'Frisk',
|
||||
icon = 'hand'
|
||||
},
|
||||
{
|
||||
label = 'Fingerprint',
|
||||
icon = 'fingerprint'
|
||||
},
|
||||
{
|
||||
label = 'Jail',
|
||||
icon = 'bus'
|
||||
},
|
||||
{
|
||||
label = 'Search',
|
||||
icon = 'magnifying-glass',
|
||||
onSelect = function()
|
||||
print('Search')
|
||||
end
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
lib.addRadialItem({
|
||||
{
|
||||
id = 'police',
|
||||
label = 'Police',
|
||||
icon = 'shield-halved',
|
||||
menu = 'police_menu'
|
||||
},
|
||||
{
|
||||
id = 'business_stuff',
|
||||
label = 'Business',
|
||||
icon = 'briefcase',
|
||||
onSelect = function()
|
||||
print("Business")
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
local coords = GetEntityCoords(cache.ped)
|
||||
local point = lib.points.new(coords, 5)
|
||||
|
||||
function point:onEnter()
|
||||
lib.addRadialItem({
|
||||
id = 'garage_access',
|
||||
icon = 'warehouse',
|
||||
label = 'Garage',
|
||||
onSelect = function()
|
||||
print('Garage')
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
function point:onExit()
|
||||
lib.removeRadialItem('garage_access')
|
||||
end
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
:::caution
|
||||
|
||||
Points system in the lib isn't available for the npm package.
|
||||
:::
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
exports('myMenuHandler', (menu, item) => {
|
||||
console.log(menu, item)
|
||||
|
||||
if (menu === 'police_menu' and item === 1) {
|
||||
console.log('Handcuffs')
|
||||
}
|
||||
})
|
||||
|
||||
lib.registerRadial({
|
||||
id: 'police_menu',
|
||||
items: [
|
||||
{
|
||||
label: 'Handcuff',
|
||||
icon: 'handcuffs',
|
||||
onSelect: 'myMenuHandler'
|
||||
},
|
||||
{
|
||||
label: 'Frisk',
|
||||
icon: 'hand'
|
||||
},
|
||||
{
|
||||
label: 'Fingerprint',
|
||||
icon: 'fingerprint'
|
||||
},
|
||||
{
|
||||
label: 'Jail',
|
||||
icon: 'bus'
|
||||
},
|
||||
{
|
||||
label: 'Search',
|
||||
icon: 'magnifying-glass',
|
||||
onSelect: () => {
|
||||
console.log('Search')
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
lib.addRadialItem([
|
||||
{
|
||||
id: 'police',
|
||||
label: 'Police',
|
||||
icon: 'shield-halved',
|
||||
menu: 'police_menu'
|
||||
},
|
||||
{
|
||||
id: 'business_stuff',
|
||||
label: 'Business',
|
||||
icon: 'briefcase',
|
||||
onSelect: () => {
|
||||
console.log('Business')
|
||||
}
|
||||
}
|
||||
])
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
title: Skill Check
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.skillCheck
|
||||
|
||||
Runs a skill check with the defined difficulty.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.skillCheck(difficulty, inputs)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* difficulty: `easy` or `medium` or `hard` or `object`
|
||||
* Can set custom difficulty by sending a object instead of string
|
||||
* { areaSize: `number`, speedMultiplier: `number` }
|
||||
* easy: { areaSize: 50, speedMultiplier: 1 }
|
||||
* medium: { areaSize: 40, speedMultiplier: 1.5 }
|
||||
* hard: { areaSize: 25, speedMultiplier: 1.75 }
|
||||
* `areaSize` size of the area in degrees.
|
||||
* Sending an array will chain the checks together and return false if one fails and true if all succeed
|
||||
* inputs: `string[]`
|
||||
* Picks a random key from the inputs table to use on each skill check pass.
|
||||
|
||||
### Usage Example
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard'], ['w', 'a', 's', 'd'])
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,129 @@
|
||||
---
|
||||
title: TextUI
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.showTextUI
|
||||
|
||||
Show the TextUI window.
|
||||
|
||||
:::danger
|
||||
|
||||
**DO NOT** run this function every tick, it's intented to be used as a toggle.
|
||||
:::
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
### lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
#### Basic
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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>
|
||||
|
||||

|
||||
|
||||
#### Custom styling
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.showTextUI('[E] - Pick apple', {
|
||||
position = "top-center",
|
||||
icon = 'hand',
|
||||
style = {
|
||||
borderRadius = 0,
|
||||
backgroundColor = '#48BB78',
|
||||
color = 'white'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</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>
|
||||
</Tabs>
|
||||
|
||||

|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Interface
|
||||
---
|
||||
|
||||
If you wish to change the primary colour for the UI to better match your server's theme you can do so easily through the available convars.
|
||||
|
||||
They don't require you to build the UI, just restart the resource.
|
||||
|
||||
Convars:
|
||||
|
||||
```yaml
|
||||
setr ox:primaryColor blue
|
||||
setr ox:primaryShade 8
|
||||
```
|
||||
|
||||
Changing the primary colour will change the colour in elements such as the progress bar/circle, skill check, radial menu center button and hover,
|
||||
dialog confirm buttons, input field focus, and more.
|
||||
|
||||
You can find the full list of preset colours and shades here:
|
||||
|
||||
https://mantine.dev/theming/colors/#default-colors
|
||||
|
||||
If you wish to create your own pallete I suggest following the guide on that page.
|
||||
Keep in mind doing so *will* require you to download the source code and build the UI.
|
||||
@@ -0,0 +1,77 @@
|
||||
Allows servers to set a preferred language and attempt to load locale files in any resources using the module.
|
||||
Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json`
|
||||
|
||||
## Setup
|
||||
To change the preferred language from English, add the convar to your server.cfg
|
||||
|
||||
```yaml
|
||||
setr ox:locale en
|
||||
```
|
||||
|
||||
Create a locales directory and a file for your language.
|
||||
|
||||
```json title="locales/en.json"
|
||||
{
|
||||
"grand_theft_auto": "grand theft auto",
|
||||
"male": "male",
|
||||
"female": "female",
|
||||
"suspect_sex": "suspect is %s",
|
||||
}
|
||||
```
|
||||
|
||||
```json title="locales/fr.json"
|
||||
{
|
||||
"grand_theft_auto": "vol de voiture",
|
||||
"male": "homme",
|
||||
"female": "femme",
|
||||
"suspect_sex": "le suspect est %s",
|
||||
}
|
||||
```
|
||||
|
||||
```lua title="fxmanifest.lua"
|
||||
files {
|
||||
'locales/*.json'
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Initialise the locale module in your resource (once).
|
||||
|
||||
```lua
|
||||
lib.locale()
|
||||
```
|
||||
|
||||
Format your strings with the new locale global.
|
||||
Additional arguments can be sent to format the locale output.
|
||||
|
||||
```lua
|
||||
locale(str, ...)
|
||||
```
|
||||
|
||||
* str: `string`
|
||||
* ...: `string` or `number`
|
||||
|
||||
```lua
|
||||
-- Load the locale module
|
||||
lib.locale()
|
||||
|
||||
SetInterval(function()
|
||||
print(locale('grand_theft_auto'))
|
||||
print(locale('suspect_sex', locale('male')))
|
||||
end, 5000)
|
||||
```
|
||||
|
||||
## Phrases
|
||||
|
||||
You can create a locale string that references other locales to construct a phrase, rather than calling locale multiple times.
|
||||
```json title="locales/en.json"
|
||||
{
|
||||
"hello": "hello %s",
|
||||
"my_name_is": "my name is %s",
|
||||
"hello_my_name_is": "${hello}! ${my_name_is}."
|
||||
}
|
||||
```
|
||||
```lua
|
||||
print(locale('hello_my_name_is', 'doka', 'linden'))
|
||||
```
|
||||
@@ -0,0 +1,94 @@
|
||||
## Submit logs to Datadog
|
||||
|
||||
Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys).
|
||||
Modify your `server.cfg` with the newly generated API key and [intake server](https://docs.datadoghq.com/api/latest/logs/#send-logs).
|
||||
|
||||
- datadoghq.com
|
||||
- us3.datadoghq.com
|
||||
- us5.datadoghq.com
|
||||
- datadoghq.eu
|
||||
|
||||
```yaml
|
||||
set datadog:key "yourapikey"
|
||||
set datadog:site "datadoghq.com"
|
||||
```
|
||||
|
||||
```lua
|
||||
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.
|
||||
Event is passed to `ddservice` and displays in the logs list.
|
||||
Additional arguments are converted into tags for additional filtering and search options.
|
||||
|
||||
```lua
|
||||
local vehicle = Ox.CreateVehicle(false, `sultanrs`, vec(-56.479122, -1116.870362, 26.432250, 0.000030517578))
|
||||
lib.logger(-1, 'CreateVehicle', json.encode(vehicle))
|
||||
```
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Submit logs to Grafana Loki
|
||||
|
||||
Loki is a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus. It is designed to be very cost effective and easy to operate. It does not index the contents of the logs, but rather a set of labels for each log stream.
|
||||
|
||||
You can take two routes with Grafana Loki:
|
||||
|
||||
[Grafana Cloud](https://grafana.com/)
|
||||
|
||||
- Has free tier with some restrictions
|
||||
- Easy to manage
|
||||
- Easier to setup
|
||||
- Mostly Managed by Grafana
|
||||
|
||||
Self-Host [Grafana Stack](https://grafana.com/get/?plcmt=top-nav&cta=downloads&tab=self-managed)
|
||||
|
||||
- No imposed restrictions
|
||||
- Requires own server
|
||||
- Complicated to setup
|
||||
- Self-Managed
|
||||
|
||||
### Grafana Cloud Setup (Easy)
|
||||
|
||||
Once registered with Grafana Cloud, head to [My Account](https://grafana.com/auth/sign-in/?plcmt=top-nav&cta=myaccount) click your named stack (should be under Grafana Cloud section) and then click Details on the Loki section. Click Generate Now where it says password. Save the key for later. Save your user and url also, you don't need the `https://`
|
||||
|
||||
### Grafana Self-Hosted Setup (Experience Required)
|
||||
|
||||
To setup a grafana instance you'll require docker, and knowledge on containers or kubernetes. Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that. Once done, setup authentication and use the username and password securing your endpoint.
|
||||
|
||||
[*] Please note: By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
|
||||
|
||||
#### Setting up Server Config
|
||||
|
||||
Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg.
|
||||
|
||||
```yaml
|
||||
set ox:logger "loki"
|
||||
set loki:user "<insert your user>"
|
||||
set loki:password "<insert the api key or password>"
|
||||
set loki:endpoint "<insert loki url without http:// or https://>"
|
||||
```
|
||||
|
||||
Here is an example
|
||||
|
||||
```yaml
|
||||
set ox:logger "loki"
|
||||
set loki:user "1337"
|
||||
set loki:password "alongcomplicatedsecurepassword"
|
||||
set loki:endpoint "logs.mywebsite.com"
|
||||
```
|
||||
|
||||
#### Inserting data
|
||||
|
||||
The data can be inserted into Loki the same way as datadog so you can follow the log format from the above datadog section.
|
||||
|
||||
#### Browsing Data
|
||||
|
||||
If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite in-depth with what you can do, you can even track metrics and economic health all from logs.
|
||||
@@ -0,0 +1,71 @@
|
||||
## lib.math
|
||||
|
||||
Extends the standard Lua math table with extra functions.
|
||||
|
||||
```
|
||||
math = lib.math
|
||||
```
|
||||
|
||||
### math.toscalars
|
||||
|
||||
Takes a string and returns a set of scalar values.
|
||||
|
||||
```lua
|
||||
math.toscalars(input, min, max, round)
|
||||
```
|
||||
|
||||
- input: `string`
|
||||
- min?: `number`
|
||||
- max?: `number`
|
||||
- round?: `boolean`
|
||||
|
||||
Return:
|
||||
|
||||
- ...: `number`
|
||||
|
||||
### math.tovector
|
||||
|
||||
Takes a string or table and returns a vector value, or a number if only one value was found.
|
||||
|
||||
```lua
|
||||
math.tovector(input, min, max, round)
|
||||
```
|
||||
|
||||
- input: `string` or `table`
|
||||
- min?: `number`
|
||||
- max?: `number`
|
||||
- round?: `boolean`
|
||||
|
||||
Return:
|
||||
|
||||
- value: `number` or `vector2` or `vector3` or `vector4`
|
||||
|
||||
### math.torgba
|
||||
|
||||
Takes a string or table and returns a vector value, or a number if only one value was found.
|
||||
Values are rounded and must be within the range of 0-255.
|
||||
|
||||
```lua
|
||||
math.torgba(input)
|
||||
```
|
||||
|
||||
- input: `string` or `table`
|
||||
|
||||
Return:
|
||||
|
||||
- value: `number` or `vector2` or `vector3` or `vector4`
|
||||
|
||||
### math.tohex
|
||||
|
||||
Takes a number or string and formats it as a hexadecimal string.
|
||||
|
||||
```lua
|
||||
math.tohex(n, upper)
|
||||
```
|
||||
|
||||
- n: `number` or `string`
|
||||
- upper?: `boolean`
|
||||
|
||||
Return:
|
||||
|
||||
- hex: `string`
|
||||
@@ -0,0 +1,46 @@
|
||||
# Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
```ts
|
||||
Point<T>({coords, distance, onEnter, onExit, nearby, args})
|
||||
```
|
||||
|
||||
* coords: `number[]`
|
||||
* distance: `number`
|
||||
* onEnter?: `function`
|
||||
* onExit?: `function`
|
||||
* nearby?: `function`
|
||||
* args?: `T`
|
||||
|
||||
```ts
|
||||
import { Point, cache } from '@overextended/ox_lib/client'
|
||||
|
||||
function nearby(this: Point<{dunak: string}>) {
|
||||
// @ts-ignore
|
||||
DrawMarker(2, this.coords.x, this.coords.y, this.coords.z, 0, 0, 0, 0, 180, 0, 1, 1, 1, 200, 20, 20, 50, false, true, 2, false, null, null, false)
|
||||
|
||||
if (this.currentDistance && this.currentDistance < 1 && IsControlJustReleased(0, 38)) {
|
||||
console.log('Inside marker', this.id)
|
||||
console.log(this.args?.dunak)
|
||||
}
|
||||
}
|
||||
|
||||
const point = new Point({
|
||||
coords: GetEntityCoords(cache.ped, false),
|
||||
distance: 5,
|
||||
nearby: nearby,
|
||||
args: {
|
||||
dunak: 'nerd'
|
||||
}
|
||||
})
|
||||
|
||||
point.onEnter = () => {
|
||||
console.log('Entered range of point', point.id)
|
||||
}
|
||||
|
||||
point.onExit = () => {
|
||||
console.log('Left range of point', point.id)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Points
|
||||
|
||||
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
|
||||
|
||||
### CPoint
|
||||
|
||||
A table representing a point, with the following properties.
|
||||
|
||||
* id: `number`
|
||||
* coords: `vector3`
|
||||
* distance: `number`
|
||||
* The distance for the player to be "inside" a point (i.e. the point's radius).
|
||||
* currentDistance: `number`
|
||||
* The players current distance from the centre of the point.
|
||||
* isClosest?: `boolean`
|
||||
* remove: `function()`
|
||||
* Removes the point from the points registry.
|
||||
|
||||
### lib.points.new
|
||||
|
||||
```lua
|
||||
lib.points.new(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* coords: `vector3`
|
||||
* distance: `number`
|
||||
|
||||
**Returns:** CPoint
|
||||
|
||||
```lua
|
||||
local point = lib.points.new({
|
||||
coords = GetEntityCoords(cache.ped),
|
||||
distance = 5,
|
||||
dunak = 'nerd',
|
||||
})
|
||||
|
||||
function point:onEnter()
|
||||
print('entered range of point', self.id)
|
||||
end
|
||||
|
||||
function point:onExit()
|
||||
print('left range of point', self.id)
|
||||
end
|
||||
|
||||
function point:nearby()
|
||||
DrawMarker(2, self.coords.x, self.coords.y, self.coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 200, 20, 20, 50, false, true, 2, false, nil, nil, false)
|
||||
|
||||
if self.currentDistance < 1 and IsControlJustReleased(0, 38) then
|
||||
print('inside marker', self.id, 'dunak is a '.. self.dunak)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
### lib.points.getAllPoints
|
||||
|
||||
Get a table of all points created in the resource.
|
||||
|
||||
```lua
|
||||
lib.points.getAllPoints()
|
||||
```
|
||||
|
||||
**Return:** `table<number, CPoint>`
|
||||
|
||||
### lib.points.getNearbyPoints
|
||||
|
||||
Get an array of all points in range of the player.
|
||||
|
||||
```lua
|
||||
lib.points.getNearbyPoints()
|
||||
```
|
||||
|
||||
**Return:** `CPoint[]`
|
||||
|
||||
### lib.points.getClosestPoint
|
||||
|
||||
Get the data for the closest point to the player.
|
||||
|
||||
```lua
|
||||
lib.points.getClosestPoint()
|
||||
```
|
||||
|
||||
**Returns:** `CPoint`
|
||||
@@ -0,0 +1,21 @@
|
||||
### lib.raycast.cam
|
||||
|
||||
Starts a shapetest originating from the camera, extending to ~10m.
|
||||
|
||||
```lua
|
||||
lib.raycast.cam(flags, ignore, distance)
|
||||
```
|
||||
|
||||
* flags?: `number`
|
||||
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
||||
* ignore?: `number`
|
||||
* A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
||||
* distance?: `number`
|
||||
|
||||
Return:
|
||||
|
||||
* hit: `boolean`
|
||||
* entityHit: `number`
|
||||
* endCoords: `vector3`
|
||||
* surfaceNormal: `vector3`
|
||||
* materialHash: `number`
|
||||
@@ -0,0 +1,210 @@
|
||||
Check if assets exist, such as models, and loads them into memory.
|
||||
Throws errors for invalid assets and returns true if the asset is loaded.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.requestAnimDict
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
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
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* fxName: `string`
|
||||
* timeout: `number`
|
||||
* Default: `100`
|
||||
|
||||
### lib.requestScaleformMovie
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.requestScaleformMovie(scaleformMovie, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestScaleformMovie(scaleformMovie, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* dict: `string`
|
||||
* timeout: `number`
|
||||
* Default: `100`
|
||||
|
||||
### lib.requestWeaponAsset
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* weaponType: `string | number`
|
||||
* timeout: `number?`
|
||||
* Number of ticks to wait for the asset to load. Default is `500`
|
||||
* weaponResourceFlags: `WeaponResourceFlags?`
|
||||
* Default is `31`
|
||||
* extraWeaponComponentFlags: `ExtraWeaponComponentFlags?`
|
||||
* Default is `0`
|
||||
|
||||
Return:
|
||||
* `string | number?` weaponType
|
||||
|
||||
### WeaponResourceFlags
|
||||
|
||||
```
|
||||
1 WRF_REQUEST_BASE_ANIMS
|
||||
2 WRF_REQUEST_COVER_ANIMS
|
||||
4 WRF_REQUEST_MELEE_ANIMS
|
||||
8 WRF_REQUEST_MOTION_ANIMS
|
||||
16 WRF_REQUEST_STEALTH_ANIMS
|
||||
32 WRF_REQUEST_ALL_MOVEMENT_VARIATION_ANIMS
|
||||
31 WRF_REQUEST_ALL_ANIMS
|
||||
```
|
||||
|
||||
### ExtraWeaponComponentFlags
|
||||
|
||||
```
|
||||
0 WEAPON_COMPONENT_NONE
|
||||
1 WEAPON_COMPONENT_FLASH
|
||||
2 WEAPON_COMPONENT_SCOPE
|
||||
4 WEAPON_COMPONENT_SUPP
|
||||
8 WEAPON_COMPONENT_SCLIP2
|
||||
16 WEAPON_COMPONENT_GRIP
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
## lib.table.contains
|
||||
|
||||
```lua
|
||||
lib.table.contains(table, value)
|
||||
```
|
||||
|
||||
* table: `table`
|
||||
* value: `any`
|
||||
|
||||
## lib.table.matches
|
||||
|
||||
```lua
|
||||
lib.table.matches(tableOne, tableTwo)
|
||||
```
|
||||
|
||||
* tableOne: `table`.
|
||||
* tableTwo: `table`
|
||||
|
||||
## lib.table.deepclone
|
||||
|
||||
```lua
|
||||
lib.table.deepclone(table)
|
||||
```
|
||||
|
||||
* table: `table`
|
||||
|
||||
## lib.table.merge
|
||||
|
||||
```lua
|
||||
lib.table.merge(tableOne, tableTwo)
|
||||
```
|
||||
|
||||
* tableOne: `table`
|
||||
* tableTwo: `table`
|
||||
@@ -0,0 +1,74 @@
|
||||
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
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.getVehicleProperties
|
||||
|
||||
```ts
|
||||
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()))
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### lib.setVehicleProperties
|
||||
|
||||
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
||||
|
||||
```lua
|
||||
lib.setVehicleProperties(vehicle, props)
|
||||
```
|
||||
|
||||
* vehicle: `entity`
|
||||
* props: `table` (`object`)
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
```lua
|
||||
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
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
|
||||
|
||||
The server should tell the owner of the entity to set properties, using the following trigger.
|
||||
|
||||
```lua
|
||||
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
### lib.versionCheck
|
||||
|
||||
Compares the resource version to the latest published release on GitHub.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
```lua
|
||||
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')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
|
||||
@@ -0,0 +1,33 @@
|
||||
### lib.checkDependency
|
||||
|
||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
</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>
|
||||
@@ -0,0 +1,124 @@
|
||||
Faster alternative to PolyZone utilising [glm.polygon](https://github.com/gottfriedleibniz/lua/blob/luaglm/EXTENDED.md#polygon).
|
||||
|
||||
## lib.zones.poly
|
||||
|
||||
```lua
|
||||
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`
|
||||
|
||||
## lib.zones.box
|
||||
|
||||
```lua
|
||||
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`
|
||||
|
||||
## lib.zones.sphere
|
||||
|
||||
```lua
|
||||
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
|
||||
function onEnter(self)
|
||||
print('entered zone', self.id)
|
||||
end
|
||||
|
||||
function onExit(self)
|
||||
print('exited zone', self.id)
|
||||
end
|
||||
|
||||
function inside(self)
|
||||
print('you are inside zone ' .. self.id)
|
||||
end
|
||||
|
||||
local poly = lib.zones.poly({
|
||||
points = {
|
||||
vec(413.8, -1026.1, 29),
|
||||
vec(411.6, -1023.1, 29),
|
||||
vec(412.2, -1018.0, 29),
|
||||
vec(417.2, -1016.3, 29),
|
||||
vec(422.3, -1020.0, 29),
|
||||
vec(426.8, -1015.9, 29),
|
||||
vec(431.8, -1013.0, 29),
|
||||
vec(437.3, -1018.4, 29),
|
||||
vec(432.4, -1027.2, 29),
|
||||
vec(424.7, -1023.5, 29),
|
||||
vec(420.0, -1030.2, 29),
|
||||
vec(409.8, -1028.4, 29),
|
||||
},
|
||||
thickness = 2,
|
||||
debug = true,
|
||||
inside = inside,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
})
|
||||
|
||||
local sphere = lib.zones.sphere({
|
||||
coords = vec3(442.5363, -1017.666, 28.65637),
|
||||
radius = 1,
|
||||
debug = true,
|
||||
inside = inside,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
})
|
||||
|
||||
local box = lib.zones.box({
|
||||
coords = vec3(442.5363, -1017.666, 28.65637),
|
||||
size = vec3(1, 1, 1),
|
||||
rotation = 45,
|
||||
debug = true,
|
||||
inside = inside,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
})
|
||||
```
|
||||
|
||||
Zones can be deleted by using the remove method.
|
||||
|
||||
```lua
|
||||
poly:remove()
|
||||
sphere: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.
|
||||
|
||||
Once saved you will find the created zone details in created_zones.lua within ox_lib
|
||||
Reference in new issue
Block a user