refactor: Add h1 headers to all pages missing it (#137)

* refactor: Add h1 headers to all pages missing it

* refactor: missed example h3

* change hooks example heading to bold text

---------

Co-authored-by: Luke <[email protected]>
This commit is contained in:
JagandLuke authored and GitHub committed 2023-07-08 11:08:43 +02:00
1 parent 74227cc262
commit 1d2c490b26
95 files changed
+576 -698

No files matched your search

+6 -5
View File
@@ -6,6 +6,7 @@ interface Props {
children?: React.ReactNode; children?: React.ReactNode;
side?: 'left' | 'right'; side?: 'left' | 'right';
link?: string; link?: string;
label?: string;
} }
const Button: React.FC = ({ side = 'left', children, icon, link }: Props) => { const Button: React.FC = ({ side = 'left', children, icon, link }: Props) => {
@@ -27,7 +28,7 @@ export default Button;
export function GhButton(props: Props) { export function GhButton(props: Props) {
return ( return (
<Button icon={<IconBrandGithub />} side={props.side} link={props.link}> <Button icon={<IconBrandGithub />} side={props.side} link={props.link}>
GitHub {props.label || "Github"}
</Button> </Button>
); );
} }
@@ -35,7 +36,7 @@ export function GhButton(props: Props) {
export function DocButton(props: Props) { export function DocButton(props: Props) {
return ( return (
<Button icon={<IconFileText />} side={props.side} link={props.link}> <Button icon={<IconFileText />} side={props.side} link={props.link}>
Documentation {props.label || "Documentation"}
</Button> </Button>
); );
} }
@@ -43,7 +44,7 @@ export function DocButton(props: Props) {
export function DownloadButton(props: Props) { export function DownloadButton(props: Props) {
return ( return (
<Button icon={<IconDownload />} side={props.side} link={props.link}> <Button icon={<IconDownload />} side={props.side} link={props.link}>
Download {props.label || "Download"}
</Button> </Button>
); );
} }
@@ -51,7 +52,7 @@ export function DownloadButton(props: Props) {
export function ReleaseButton(props: Props) { export function ReleaseButton(props: Props) {
return ( return (
<Button icon={<IconTag />} side={props.side} link={props.link}> <Button icon={<IconTag />} side={props.side} link={props.link}>
Releases {props.label || "Releases"}
</Button> </Button>
); );
} }
@@ -59,7 +60,7 @@ export function ReleaseButton(props: Props) {
export function NpmButton(props: Props) { export function NpmButton(props: Props) {
return ( return (
<Button icon={<IconBrandNpm />} side={props.side} link={props.link}> <Button icon={<IconBrandNpm />} side={props.side} link={props.link}>
Package {props.label || "Package"}
</Button> </Button>
); );
} }
+2
View File
@@ -1,3 +1,5 @@
# Git
Git is a version control system, allowing changes to be effectively tracked, merged, and reverted. Git is a version control system, allowing changes to be effectively tracked, merged, and reverted.
As our resources are hosted on GitHub, it can be incredibly useful to learn how to create your own repository to track changes and keep up-to-date. If you plan on making your own changes to our resources, this will allow you to keep your own changes and prevent loss of data. As our resources are hosted on GitHub, it can be incredibly useful to learn how to create your own repository to track changes and keep up-to-date. If you plan on making your own changes to our resources, this will allow you to keep your own changes and prevent loss of data.
+2
View File
@@ -2,6 +2,8 @@
title: Node.js title: Node.js
--- ---
# Node.js
Node.js is a JavaScript runtime and is used for building applications. In the context of FiveM it is necessary to bundle resources into a single package that can be ran on both the server and client. Node.js is a JavaScript runtime and is used for building applications. In the context of FiveM it is necessary to bundle resources into a single package that can be ran on both the server and client.
- [Download](https://nodejs.org) and install the LTS version of Node.js. - [Download](https://nodejs.org) and install the LTS version of Node.js.
+2
View File
@@ -2,6 +2,8 @@
title: pnpm title: pnpm
--- ---
# pnpm
pnpm is a fast and disk space efficient package manager, serving as an alternative to npm and yarn. pnpm is a fast and disk space efficient package manager, serving as an alternative to npm and yarn.
- Ensure you have [installed Node.js](./nodejs). - Ensure you have [installed Node.js](./nodejs).
+2
View File
@@ -4,6 +4,8 @@ title: VS Code
import { DownloadButton, GhButton, DocButton } from '@components/button'; import { DownloadButton, GhButton, DocButton } from '@components/button';
# VS Code
Visual Studio Code is our recommended editor when working with Lua. Visual Studio Code is our recommended editor when working with Lua.
<DownloadButton link="https://code.visualstudio.com/Download" /> <DownloadButton link="https://code.visualstudio.com/Download" />
+2
View File
@@ -4,6 +4,8 @@ title: Introduction
import DonateLink from '@components/DonateLink'; import DonateLink from '@components/DonateLink';
# Introduction
Here you can find all of the official documentation for resources developed by the Overextended team. Here you can find all of the official documentation for resources developed by the Overextended team.
If you feel like the documentation is lacking in some department then feel free to go onto that page and click the "Edit this page" at the bottom and submit a Pull Request. If you feel like the documentation is lacking in some department then feel free to go onto that page and click the "Edit this page" at the bottom and submit a Pull Request.
+2
View File
@@ -3,6 +3,8 @@ import { Callout } from 'nextra/components';
import ResourceLinks from '@components/resource-links'; import ResourceLinks from '@components/resource-links';
import { NpmButton } from '@components/button'; import { NpmButton } from '@components/button';
# Ox Core
<ResourceLinks repo="https://github.com/overextended/ox_core" /> <ResourceLinks repo="https://github.com/overextended/ox_core" />
An experimental framework for FiveM. Limited support and breaking changes guaranteed. An experimental framework for FiveM. Limited support and breaking changes guaranteed.
+2
View File
@@ -1,3 +1,5 @@
# Client
When ox_core is imported into a resource it will create the `player` global. When ox_core is imported into a resource it will create the `player` global.
If `player` is nil, then the client has not yet selected a character and spawned. If `player` is nil, then the client has not yet selected a character and spawned.
@@ -2,6 +2,8 @@
title: Callbacks title: Callbacks
--- ---
# Callbacks
### ox:getStatus ### ox:getStatus
```lua ```lua
+2
View File
@@ -2,6 +2,8 @@
title: Events title: Events
--- ---
# Events
## Client events ## Client events
### ox:playerLoaded ### ox:playerLoaded
+2
View File
@@ -1,5 +1,7 @@
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# Server
## Ox.GetPlayer ## Ox.GetPlayer
Return an instance of OxPlayer for the given player source. Return an instance of OxPlayer for the given player source.
+2
View File
@@ -2,6 +2,8 @@
title: Events title: Events
--- ---
# Events
## Server events ## Server events
### ox:playerLoaded ### ox:playerLoaded
+2
View File
@@ -4,6 +4,8 @@ title: Methods
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# Methods
These functions are inherited from the [Player class](../Server/). These functions are inherited from the [Player class](../Server/).
## player.set ## player.set
+2
View File
@@ -3,6 +3,8 @@ title: Server
sidebar_position: 1 sidebar_position: 1
--- ---
# Server
## Ox.GetVehicle ## Ox.GetVehicle
Return an instance of OxVehicle for the given entity. Return an instance of OxVehicle for the given entity.
@@ -2,6 +2,8 @@
title: Callbacks title: Callbacks
--- ---
# Callbacks
### ox:getNearbyVehicles ### ox:getNearbyVehicles
Get all vehicles within range of the target player. Get all vehicles within range of the target player.
+2
View File
@@ -2,6 +2,8 @@
title: Methods title: Methods
--- ---
# Methods
These functions are inherited from the [Vehicle class](../Server/). These functions are inherited from the [Vehicle class](../Server/).
## vehicle.set ## vehicle.set
+2
View File
@@ -2,6 +2,8 @@ import { Steps } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
import ResourceLinks from '@components/resource-links'; import ResourceLinks from '@components/resource-links';
# Ox Doorlock
<ResourceLinks repo="https://github.com/overextended/ox_doorlock" /> <ResourceLinks repo="https://github.com/overextended/ox_doorlock" />
A door management resource that can be used standalone or alongside ox_core, qb-core, and es_extended. A door management resource that can be used standalone or alongside ox_core, qb-core, and es_extended.
+2
View File
@@ -1,3 +1,5 @@
# Functions
## pickClosestDoor ## pickClosestDoor
Attempt to pick the lock of the closest door. Dependant on server-side checks and may fail. Attempt to pick the lock of the closest door. Dependant on server-side checks and may fail.
+6 -4
View File
@@ -1,8 +1,10 @@
# Triggers # Events
## Triggers
These events are safe to trigger and handle in other scripts. These events are safe to trigger and handle in other scripts.
## ox_doorlock:setState ### ox_doorlock:setState
Can be triggered to lock or unlock a door. Can be triggered to lock or unlock a door.
@@ -13,11 +15,11 @@ TriggerEvent('ox_doorlock:setState', doorId, state)
- doorId: `number` - doorId: `number`
- state: `0` or `1` - state: `0` or `1`
# Handlers ## Handlers
These events shouldn't be triggered by any other scripts. These events shouldn't be triggered by any other scripts.
## ox_doorlock:stateChanged ### ox_doorlock:stateChanged
Triggered when a doors state is updated. Triggered when a doors state is updated.
+2
View File
@@ -1,3 +1,5 @@
# Functions
Gets data for a door with the given id, matching the id for the database entry. Gets data for a door with the given id, matching the id for the database entry.
## getDoor ## getDoor
+3 -1
View File
@@ -1,7 +1,9 @@
--- ---
title: Door settings title: Door Settings
--- ---
# Door Settings
## General ## General
- Door name - Door name
+2
View File
@@ -1,6 +1,8 @@
import { Steps } from 'nextra-theme-docs'; import { Steps } from 'nextra-theme-docs';
import ResourceLinks from '@components/resource-links'; import ResourceLinks from '@components/resource-links';
# Ox Fuel
<ResourceLinks repo="https://github.com/overextended/ox_fuel" /> <ResourceLinks repo="https://github.com/overextended/ox_fuel" />
A simple fuel resource meant to replace LegacyFuel or serve as a showcase for using petrol cans as an item. A simple fuel resource meant to replace LegacyFuel or serve as a showcase for using petrol cans as an item.
+2
View File
@@ -1,3 +1,5 @@
# Functions
## setMoneyCheck ## setMoneyCheck
Override the built-in money check. Override the built-in money check.
+2
View File
@@ -1,3 +1,5 @@
# Functions
## setPaymentMethod ## setPaymentMethod
Override the built-in payment method. Override the built-in payment method.
+2
View File
@@ -2,6 +2,8 @@ import ResourceLinks from '@components/resource-links';
import { Steps, Tabs, Tab } from 'nextra-theme-docs'; import { Steps, Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Ox Inventory
<ResourceLinks repo="https://github.com/overextended/ox_inventory" /> <ResourceLinks repo="https://github.com/overextended/ox_inventory" />
A slot-based inventory with item metadata for "item uniqueness". A slot-based inventory with item metadata for "item uniqueness".
+19 -6
View File
@@ -1,10 +1,14 @@
# Client events import { Callout } from 'nextra/components';
# Client
This is not a comprehensive list of events and is missing events intended for internal use only. This is not a comprehensive list of events and is missing events intended for internal use only.
## Triggers ## Event Triggers
These events are safe to trigger and handle in other scripts. <Callout type="info">
These events **are safe** to trigger and handle in other scripts.
</Callout>
### ox_inventory:disarm ### ox_inventory:disarm
@@ -14,14 +18,20 @@ Can be triggered to force the player to disarm.
TriggerClientEvent('ox_inventory:disarm', playerId, noAnim) TriggerClientEvent('ox_inventory:disarm', playerId, noAnim)
``` ```
## Handlers - playerId: `number`
- noAnim: `boolean`
- If `true`, disarm animation will be skipped
These events shouldn't be triggered by any other scripts. ## Event Handlers
<Callout type="warning">
These events **should not** be triggered by any other scripts.
</Callout>
### ox_inventory:updateInventory ### ox_inventory:updateInventory
Triggered after inventory slots have been updated, included on load. Triggered after inventory slots have been updated, included on load.
Changes is a table containing all updated slot data indexed by slotId. Empty slots are "false". Changes is a table containing all updated slot data indexed by slotId. Empty slots are `false`.
```lua ```lua
AddEventHandler('ox_inventory:updateInventory', function(changes) end) AddEventHandler('ox_inventory:updateInventory', function(changes) end)
@@ -47,3 +57,6 @@ _Note: Not available for ESX, use esx:addInventoryItem or esx:removeInventoryIte
```lua ```lua
AddEventHandler('ox_inventory:itemCount', function(itemName, totalCount) end) AddEventHandler('ox_inventory:itemCount', function(itemName, totalCount) end)
``` ```
- itemName: `string`
- totalCount: `number`
+7 -3
View File
@@ -1,10 +1,14 @@
# Server events import { Callout } from 'nextra/components';
# Server
This is not a comprehensive list of events and is missing events intended for internal use only. This is not a comprehensive list of events and is missing events intended for internal use only.
## Handlers ## Handlers
These events shouldn't be triggered by any other scripts. <Callout type="warning">
These events **should not** be triggered by any other scripts.
</Callout>
### ox_inventory:openedInventory ### ox_inventory:openedInventory
@@ -22,5 +26,5 @@ AddEventHandler('ox_inventory:openedInventory', function(playerId, inventoryId)
Triggered after an inventory is closed by a player. Triggered after an inventory is closed by a player.
```lua ```lua
AddEventHandler('ox_inventory:closeInventory', function(playerId, inventoryId) end) AddEventHandler('ox_inventory:closeInventory', function() end)
``` ```
+3 -5
View File
@@ -4,6 +4,8 @@ title: ESX
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# ESX
## Compatibility ## Compatibility
Ox Inventory is a complete replacement for existing item, inventory, and weapon systems; it is inherently incompatible with ESX and any resources that rely on default behaviour. Ox Inventory is a complete replacement for existing item, inventory, and weapon systems; it is inherently incompatible with ESX and any resources that rely on default behaviour.
@@ -31,7 +33,7 @@ start ox_inventory
- Optionally, type `convertinventory esxproperty` into the server console. - Optionally, type `convertinventory esxproperty` into the server console.
- Restart the server once conversion is complete. - Restart the server once conversion is complete.
## Optional optimisation ## Optional Optimisation
All item related functions from xPlayer, such as `xPlayer.getInventoryItem`, have been modified for compatibility purposes; however they are considered deprecated. All item related functions from xPlayer, such as `xPlayer.getInventoryItem`, have been modified for compatibility purposes; however they are considered deprecated.
@@ -41,7 +43,6 @@ You should read through the functions section for further information, but the f
<Tabs items={["ESX", "Ox Inventory"]}> <Tabs items={["ESX", "Ox Inventory"]}>
<Tab> <Tab>
```lua ```lua
if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('antifreeze').count > 4 and xPlayer.getInventoryItem('sudo').count > 9 then if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('antifreeze').count > 4 and xPlayer.getInventoryItem('sudo').count > 9 then
xPlayer.removeInventoryItem("acetone", 3) xPlayer.removeInventoryItem("acetone", 3)
@@ -49,10 +50,8 @@ if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('a
xPlayer.removeInventoryItem("sudo", 10) xPlayer.removeInventoryItem("sudo", 10)
end end
``` ```
</Tab> </Tab>
<Tab> <Tab>
Add the following code somewhere in your resource to cache the exports metatable. Add the following code somewhere in your resource to cache the exports metatable.
```lua ```lua
@@ -69,6 +68,5 @@ if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'sudo', 10) ox_inventory:RemoveItem(source, 'sudo', 10)
end end
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
+3 -7
View File
@@ -5,10 +5,10 @@ title: QBCore
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# QBCore
<Callout type="warning"> <Callout type="warning">
QBCore support is experimental and cannot work as a "drag and drop" solution due to many incompatibilities. QBCore support is experimental and cannot work as a "drag and drop" solution due to many incompatibilities.
</Callout> </Callout>
## Compatibility ## Compatibility
@@ -43,7 +43,7 @@ If you have existing player data, you will need to convert it to a compatible fo
- Start the server and type `convertinventory qb` into the server console. - Start the server and type `convertinventory qb` into the server console.
- Restart the server once conversion is complete. - Restart the server once conversion is complete.
## Optional optimisation ## Optional Optimisation
All item related functions from Player, such as `Player.Functions.GetItemByName`, have been modified for compatibility purposes; however they are considered deprecated. All item related functions from Player, such as `Player.Functions.GetItemByName`, have been modified for compatibility purposes; however they are considered deprecated.
@@ -53,7 +53,6 @@ You should read through the functions section for further information, but the f
<Tabs items={["QBCore", "Ox Inventory"]}> <Tabs items={["QBCore", "Ox Inventory"]}>
<Tab> <Tab>
```lua ```lua
local acetone = Player.Functions.GetItemByName('acetone') local acetone = Player.Functions.GetItemByName('acetone')
local antifreeze = Player.Functions.GetItemByName('antifreeze') local antifreeze = Player.Functions.GetItemByName('antifreeze')
@@ -64,10 +63,8 @@ if acetone?.amount > 2 and antifreeze?.amount > 4 and sudo?.amount > 9 then
Player.Functions.RemoveItem("sudo", 10) Player.Functions.RemoveItem("sudo", 10)
end end
``` ```
</Tab> </Tab>
<Tab> <Tab>
Add the following code somewhere in your resource to cache the exports metatable. Add the following code somewhere in your resource to cache the exports metatable.
```lua ```lua
@@ -84,6 +81,5 @@ if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'sudo', 10) ox_inventory:RemoveItem(source, 'sudo', 10)
end end
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
+34 -32
View File
@@ -1,5 +1,7 @@
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# Client
## openInventory ## openInventory
Opens an inventory using the passed data. Opens an inventory using the passed data.
@@ -20,45 +22,41 @@ exports.ox_inventory:openInventory(invType, data)
- `'dumpster'` - `'dumpster'`
- data: `number` or `string` or `table` - data: `number` or `string` or `table`
### Examples
<Tabs items={['Player', 'Shop', 'Stash']}> <Tabs items={['Player', 'Shop', 'Stash']}>
<Tab> <Tab>
Open the target player's inventory.
**Open the target player's inventory.**
```lua ```lua
exports.ox_inventory:openInventory('player', 3) exports.ox_inventory:openInventory('player', 3)
``` ```
</Tab> </Tab>
<Tab> <Tab>
Open the fourth "General Store" [location](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua#L14).
**Open the fourth "General Store" [location](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua#L14).**
```lua ```lua
exports.ox_inventory:openInventory('shop', { type = 'General', id = 4 }) exports.ox_inventory:openInventory('shop', { type = 'General', id = 4 })
``` ```
</Tab> </Tab>
<Tab> <Tab>
Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).
**Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).**
```lua ```lua
exports.ox_inventory:openInventory('stash', 1) exports.ox_inventory:openInventory('stash', 1)
``` ```
**Open a custom stash (created on the server with RegisterStash).** Open a custom stash (created on the server with RegisterStash).
```lua ```lua
exports.ox_inventory:openInventory('stash', 'society_police') exports.ox_inventory:openInventory('stash', 'society_police')
``` ```
**Open a stash with a specific owner.** Open a stash with a specific owner.
```lua ```lua
exports.ox_inventory:openInventory('stash', { id = 'police_locker', owner = 'license:xxxxxxxx' }) exports.ox_inventory:openInventory('stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -157,7 +155,7 @@ exports.ox_inventory:setStashTarget(id, owner)
- Stash id. - Stash id.
- owner?: `string` or `number` - owner?: `string` or `number`
**Example:** ### Example
```lua ```lua
exports.ox_inventory:setStashTarget('motel5', 'bobsmith') exports.ox_inventory:setStashTarget('motel5', 'bobsmith')
@@ -208,7 +206,7 @@ exports.ox_inventory:displayMetadata(metadata, value)
- value?: `string` - value?: `string`
- Label for the string metadata property to be displayed. - Label for the string metadata property to be displayed.
**Example:** ### Example
```lua ```lua
exports.ox_inventory:displayMetadata('mustard', 'Mustard') exports.ox_inventory:displayMetadata('mustard', 'Mustard')
@@ -250,19 +248,16 @@ exports.ox_inventory:Search(search, item, metadata)
- metadata?: `table` or `string` - metadata?: `table` or `string`
- If metadata is provided as a string it will search the item's `metadata.type` property. - If metadata is provided as a string it will search the item's `metadata.type` property.
**Count** ### Count
<Tabs items={["Single item", "Multiple items"]}> <Tabs items={["Single item", "Multiple items"]}>
<Tab> <Tab>
```lua ```lua
local count = exports.ox_inventory:Search('count', 'water') local count = exports.ox_inventory:Search('count', 'water')
print('You have '..count.. ' water') print('You have '..count.. ' water')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
local inventory = exports.ox_inventory:Search('count', {'meat', 'skin'}, {grade="1"}) local inventory = exports.ox_inventory:Search('count', {'meat', 'skin'}, {grade="1"})
@@ -272,45 +267,44 @@ if inventory then
end end
end end
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
**Slots** ### Slots
<Tabs items={["Single item", "Multiple items"]}> <Tabs items={["Single item", "Multiple items"]}>
<Tab> <Tab>
```lua ```lua
local water = exports.ox_inventory:Search('slots', 'water') local water = exports.ox_inventory:Search('slots', 'water')
local count = 0 local count = 0
for _, v in pairs(water) do for _, v in pairs(water) do
print(v.slot..' contains '..v.count..' water '..json.encode(v.metadata)) print(v.slot..' contains '..v.count..' water '..json.encode(v.metadata))
count = count + v.count count = count + v.count
end end
print('You have '..count..' water') print('You have '..count..' water')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
local items = exports.ox_inventory:Search('slots', {'meat', 'skin'}, 'deer') local items = exports.ox_inventory:Search('slots', {'meat', 'skin'}, 'deer')
if items then if items then
for name, data in pairs(items) do for name, data in pairs(items) do
local count = 0 local count = 0
for _, v in pairs(data) do for _, v in pairs(data) do
if v.slot then if v.slot then
print(v.slot..' contains '..v.count..' '..name..' '..json.encode(v.metadata)) print(v.slot..' contains '..v.count..' '..name..' '..json.encode(v.metadata))
count = count + v.count count = count + v.count
end end
end end
print('You have '..count..' '..name) print('You have '..count..' '..name)
end end
end end
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -327,7 +321,8 @@ exports.ox_inventory:GetItemCount(itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number` Return:
- count: `number`
## GetPlayerItems ## GetPlayerItems
@@ -337,7 +332,8 @@ Get all items in the player's inventory.
exports.ox_inventory:GetPlayerItems() exports.ox_inventory:GetPlayerItems()
``` ```
**Returns:** `table` Return:
- items: `table`
## GetPlayerWeight ## GetPlayerWeight
@@ -347,7 +343,8 @@ Get the total weight of all items in the player's inventory.
exports.ox_inventory:GetPlayerWeight() exports.ox_inventory:GetPlayerWeight()
``` ```
**Returns:** `number` Return:
- totalWeight: `number`
## GetPlayerMaxWeight ## GetPlayerMaxWeight
@@ -357,7 +354,8 @@ Get the maximum carry weight of the player's inventory.
exports.ox_inventory:GetPlayerMaxWeight() exports.ox_inventory:GetPlayerMaxWeight()
``` ```
**Returns:** `number` Return:
- maxWeight: `number`
## GetSlotIdWithItem ## GetSlotIdWithItem
@@ -372,7 +370,8 @@ exports.ox_inventory:GetSlotIdWithItem(itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number?` Return:
- slotId: `number?`
## GetSlotsIdWithItem ## GetSlotsIdWithItem
@@ -387,7 +386,8 @@ exports.ox_inventory:GetSlotIdsWithItem(itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number[]?` Return:
- slotIds: `number[]?`
## GetSlotWithItem ## GetSlotWithItem
@@ -402,7 +402,8 @@ exports.ox_inventory:GetSlotWithItem(itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table?` Return:
- slotData: `table?`
## GetSlotsWithItem ## GetSlotsWithItem
@@ -417,7 +418,8 @@ exports.ox_inventory:GetSlotsWithItem(itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table[]?` Return:
- slotsData: `table[]?`
## Statebags ## Statebags
@@ -438,7 +440,7 @@ else
end end
``` ```
**Disable opening inventory** #### Disable opening inventory
```lua ```lua
LocalPlayer.state.invBusy = true LocalPlayer.state.invBusy = true
+49 -51
View File
@@ -1,6 +1,8 @@
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Server
## setPlayerInventory ## setPlayerInventory
Creates and sets the player's inventory. Creates and sets the player's inventory.
@@ -41,42 +43,33 @@ exports.ox_inventory:forceOpenInventory(playerId, invType, data)
<Tabs items={["Player", "Stash"]}> <Tabs items={["Player", "Stash"]}>
<Tab> <Tab>
Open the target player's inventory.
**Open the target player's inventory.**
```lua ```lua
exports.ox_inventory:forceOpenInventory(1, 'player', 3) exports.ox_inventory:forceOpenInventory(1, 'player', 3)
``` ```
**Admin command to open a player's inventory.** Admin command to open a player's inventory.
```lua ```lua
RegisterCommand('openplayerinv', function(source, args) RegisterCommand('openplayerinv', function(source, args)
exports.ox_inventory:forceOpenInventory(source, 'player', tonumber(args[1])) exports.ox_inventory:forceOpenInventory(source, 'player', tonumber(args[1]))
end, true) end, true)
``` ```
</Tab> </Tab>
<Tab> <Tab>
**Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).** Open a custom stash (created on the server with RegisterStash).
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', 'apartment420')
```
**Open a custom stash (created on the server with RegisterStash).**
```lua ```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', 'society_police') exports.ox_inventory:forceOpenInventory(1, 'stash', 'society_police')
``` ```
**Open a stash with a specific owner.** Open a stash with a specific owner.
```lua ```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', { id = 'police_locker', owner = 'license:xxxxxxxx' }) exports.ox_inventory:forceOpenInventory(1, 'stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -103,6 +96,7 @@ The following snippet can be used in crafting resources such as okokCrafting or
```lua ```lua
local itemNames local itemNames
ESX.RegisterServerCallback('crafting:itemNames', function(source, cb) ESX.RegisterServerCallback('crafting:itemNames', function(source, cb)
if not itemNames then if not itemNames then
itemNames = {} itemNames = {}
@@ -118,7 +112,7 @@ end)
Adds an item into the specified inventory. Adds an item into the specified inventory.
Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximum weight may be exceeded. Should be used alongside [CanCarryItem](#cancarryitem) otherwise, the maximum weight may be exceeded.
```lua ```lua
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb) exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
@@ -143,7 +137,13 @@ If used for glovebox, trunk or stash you must first check the inventory is loade
Returns `success, response` if cb is undefined, otherwise they are used in the callback only. Returns `success, response` if cb is undefined, otherwise they are used in the callback only.
**Example:** **Possible value of the "response" argument, on failure:**
- "invalid_item": the item doesn't exist
- "invalid_inventory": the inventory doesn't exist
- "inventory_full": no free slots
### Example
```lua ```lua
local success, response = exports.ox_inventory:AddItem('gloveVGH283', 'bread', 4) local success, response = exports.ox_inventory:AddItem('gloveVGH283', 'bread', 4)
@@ -168,12 +168,6 @@ print(json.encode(response, {indent=true}))
]] ]]
``` ```
**Possible value of the "response" argument, on failure:**
- "invalid_item": the item doesn't exist
- "invalid_inventory": the inventory doesn't exist
- "inventory_full": no free slots
## RemoveItem ## RemoveItem
Removes the specified item from the specified inventory. Removes the specified item from the specified inventory.
@@ -205,7 +199,7 @@ Returns success: `boolean`, response: `string?`.
- "invalid_inventory": the inventory doesn't exist - "invalid_inventory": the inventory doesn't exist
- "not_enough_items": inventory did not contain enough of the given item - "not_enough_items": inventory did not contain enough of the given item
**Example:** ### Example
```lua ```lua
-- Removes 2 water from the glovebox for the given plate. -- Removes 2 water from the glovebox for the given plate.
@@ -232,7 +226,7 @@ how many times the item was found.
Otherwise returns the data related to the item _and_ its total count found in the inventory. Otherwise returns the data related to the item _and_ its total count found in the inventory.
**Example**: ### Example
```lua ```lua
local item = ox_inventory:GetItem(source, 'water', nil, false) local item = ox_inventory:GetItem(source, 'water', nil, false)
@@ -287,7 +281,7 @@ exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
- metadata?: `table` or `string` - metadata?: `table` or `string`
- If metadata is passed as string then `metadata.type` will be checked. - If metadata is passed as string then `metadata.type` will be checked.
**Example:** ### Example
```lua ```lua
-- Checks if the player calling the event can carry 3 water items -- Checks if the player calling the event can carry 3 water items
@@ -310,7 +304,7 @@ exports.ox_inventory:CanCarryAmount(inv, item)
- item: `table` or `string` - item: `table` or `string`
- Can be array to check multiple items. - Can be array to check multiple items.
Example: ### Example
```lua ```lua
-- Checks how much you can carry -- Checks how much you can carry
@@ -359,7 +353,7 @@ exports.ox_inventory:SetMaxWeight(inv, maxWeight)
- inv: `table` or `string` or `number` - inv: `table` or `string` or `number`
- maxWeight: `number` - maxWeight: `number`
**Example:** ### Example
```lua ```lua
local ox_inventory = exports.ox_inventory local ox_inventory = exports.ox_inventory
@@ -396,7 +390,8 @@ exports.ox_inventory:GetItemCount(inv, itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number` Return:
- itemCount: `number`
## GetItemSlots ## GetItemSlots
@@ -422,7 +417,7 @@ exports.ox_inventory:GetSlot(inv, slot)
- inv: `table` or `string` or `number` - inv: `table` or `string` or `number`
- slot: `number` - slot: `number`
**Example:** ### Example
```lua ```lua
local slot = exports.ox_inventory:GetSlot(source, 1) local slot = exports.ox_inventory:GetSlot(source, 1)
@@ -454,11 +449,12 @@ exports.ox_inventory:GetSlotForItem(inv, itemName, metadata)
- itemName: `string` - itemName: `string`
- metadata: `table?` - metadata: `table?`
**Returns:** `number?` Return:
- slotId: `number?`
## GetSlotIdWithItem ## GetSlotIdWithItem
Get a slot id in an inventory matching the given name and metadata. Get a slot id in an inventory matching the given item name and metadata.
```lua ```lua
exports.ox_inventory:GetSlotIdWithItem(inv, itemName, metadata, strict) exports.ox_inventory:GetSlotIdWithItem(inv, itemName, metadata, strict)
@@ -470,7 +466,8 @@ exports.ox_inventory:GetSlotIdWithItem(inv, itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number?` Return:
- slotId: `number?`
## GetSlotIdsWithItem ## GetSlotIdsWithItem
@@ -486,7 +483,8 @@ exports.ox_inventory:GetSlotIdsWithItem(inv, itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number[]?` Return:
- slotIds: `number[]?`
## GetSlotWithItem ## GetSlotWithItem
@@ -502,7 +500,8 @@ exports.ox_inventory:GetSlotWithItem(inv, itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table?` Return:
- slotData: `table?`
## GetSlotsWithItem ## GetSlotsWithItem
@@ -518,7 +517,8 @@ exports.ox_inventory:GetSlotsWithItem(inv, itemName, metadata, strict)
- strict?: `boolean` - strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching. - Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table[]?` Return:
- slotsData: `table[]?`
## GetEmptySlot ## GetEmptySlot
@@ -530,7 +530,8 @@ exports.ox_inventory:GetEmptySlot(inv)
- inv: `table` or `string` or `number` - inv: `table` or `string` or `number`
**Returns:** `number?` Return:
- slotId: `number?`
## GetContainerFromSlot ## GetContainerFromSlot
@@ -543,7 +544,8 @@ exports.ox_inventory:GetContainerFromSlot(inv, slotId)
- inv: `table` or `string` or `number` - inv: `table` or `string` or `number`
- slotId: `number` - slotId: `number`
**Returns:** `table?` Return:
- containerData: `table?`
## SetSlotCount ## SetSlotCount
@@ -556,7 +558,7 @@ exports.ox_inventory:SetSlotCount(inv, slots)
- inv: `table` or `string` or `number` - inv: `table` or `string` or `number`
- slots: `number` - slots: `number`
**Example:** ### Example
```lua ```lua
local ox_inventory = exports.ox_inventory local ox_inventory = exports.ox_inventory
@@ -576,7 +578,7 @@ exports.ox_inventory:GetInventory(inv, owner)
- inv: `number` or `table` - inv: `number` or `table`
- owner?: `string` or `boolean` - owner?: `string` or `boolean`
**Example:** ### Example
```lua ```lua
local inventory = exports.ox_inventory:GetInventory('example_stash', false) local inventory = exports.ox_inventory:GetInventory('example_stash', false)
@@ -606,7 +608,7 @@ exports.ox_inventory:GetInventoryItems(inv, owner)
- inv: `number` or `table` - inv: `number` or `table`
- owner?: `string` or `boolean` - owner?: `string` or `boolean`
**Example:** ### Example
```lua ```lua
local playerItems = exports.ox_inventory:GetInventoryItems(source) local playerItems = exports.ox_inventory:GetInventoryItems(source)
@@ -616,7 +618,7 @@ local playerItems = exports.ox_inventory:GetInventoryItems(source)
Clears a player's inventory and saves it to a stash. Clears a player's inventory and saves it to a stash.
Use [ReturnInventory](./Server/#returninventory) to return the confiscated inventory back to Use [ReturnInventory](#returninventory) to return the confiscated inventory back to
the player. the player.
```lua ```lua
@@ -629,7 +631,7 @@ exports.ox_inventory:ConfiscateInventory(source)
Returns the confiscated inventory back to the player. Returns the confiscated inventory back to the player.
Use it alongside [ConfiscateInventory](./Server/#confiscateinventory.md). Use it alongside [ConfiscateInventory](#confiscateinventory).
```lua ```lua
exports.ox_inventory:ReturnInventory(source) exports.ox_inventory:ReturnInventory(source)
@@ -702,14 +704,12 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c
- coords?: `vector3` or `vector3[]` - coords?: `vector3` or `vector3[]`
<Callout> <Callout>
This function needs to be triggered before a player can open the stash. This function needs to be triggered before a player can open the stash.
</Callout> </Callout>
**Example:** ### Example
For a use case example on this function check out the written [Guide](../../../Guides/stashes.md) for it. For a use case example on this function check out the written [Guide](../Guides/stashes) for it.
## CreateTemporaryStash ## CreateTemporaryStash
@@ -736,10 +736,9 @@ exports.ox_inventory:CreateTemporaryStash(properties)
- An array of tables, containing a sequence of itemName, count, metadata. - An array of tables, containing a sequence of itemName, count, metadata.
Return: Return:
- inventoryId: `string` - inventoryId: `string`
**Example** ### Example
```lua ```lua
local mystash = exports.ox_inventory:CreateTemporaryStash({ local mystash = exports.ox_inventory:CreateTemporaryStash({
@@ -800,10 +799,9 @@ exports.ox_inventory:CreateDropFromPlayer(playerId)
- playerId: `number` - playerId: `number`
Return: Return:
- dropId: `string` - dropId: `string`
**Example** ### Example
```lua ```lua
local dropId = exports.ox_inventory:CreateDropFromPlayer(1) local dropId = exports.ox_inventory:CreateDropFromPlayer(1)
@@ -834,7 +832,7 @@ exports.ox_inventory:SetDurability(inv, slot, durability)
- slot: `number` - slot: `number`
- durability: `number` - durability: `number`
**Example:** ### Example
```lua ```lua
local ox_inventory = exports.ox_inventory local ox_inventory = exports.ox_inventory
@@ -862,7 +860,7 @@ ox_inventory:SetMetadata(inv, slot, metadata)
- slot: `number` - slot: `number`
- metadata: `table` - metadata: `table`
**Example:** ### Example
```lua ```lua
local ox_inventory = exports.ox_inventory local ox_inventory = exports.ox_inventory
+25 -29
View File
@@ -1,4 +1,4 @@
# Event Hooks # Hooks
Event hooks allow 3rd party resources to define new behaviour without modifying the inventory code directly. Event hooks allow 3rd party resources to define new behaviour without modifying the inventory code directly.
@@ -29,8 +29,7 @@ Return:
Triggered when moving any item from one slot to another, or when "giving" an item. Triggered when moving any item from one slot to another, or when "giving" an item.
By returning `false`, you can cancel the action and revert the inventory state. By returning `false`, you can cancel the action and revert the inventory state.
**Payload:** - Payload: `table`
- source: `number` - source: `number`
- action: `'move'` or `'stack'` or `'swap'` or `'give'` - action: `'move'` or `'stack'` or `'swap'` or `'give'`
- fromInventory: `table` or `string` or `number` - fromInventory: `table` or `string` or `number`
@@ -41,7 +40,9 @@ By returning `false`, you can cancel the action and revert the inventory state.
- toSlot?: `table` or `number` - toSlot?: `table` or `number`
- count: `number` - count: `number`
**Example:** **Example**
Blacklists "water" from being moved into or from gloveboxes and trunks.
```lua ```lua
local hookId = exports.ox_inventory:registerHook('swapItems', function(payload) local hookId = exports.ox_inventory:registerHook('swapItems', function(payload)
@@ -59,12 +60,9 @@ end, {
}) })
``` ```
Blacklists "water" from being moved into or from gloveboxes and trunks. openInventory
### openInventory
**Payload:**
- Payload: `table`
- source: `number` - source: `number`
- inventoryId: `number` or `string` - inventoryId: `number` or `string`
- inventoryType: `string` - inventoryType: `string`
@@ -72,7 +70,9 @@ Blacklists "water" from being moved into or from gloveboxes and trunks.
Triggered when a player tries to open a secondary inventory. Triggered when a player tries to open a secondary inventory.
By returning `false`, you can cancel the action and keep the player's inventory closed. By returning `false`, you can cancel the action and keep the player's inventory closed.
**Example:** **Example**
Disables gloveboxes and trunks.
```lua ```lua
local hookId = exports.ox_inventory:registerHook('openInventory', function(payload) local hookId = exports.ox_inventory:registerHook('openInventory', function(payload)
@@ -87,12 +87,9 @@ end, {
}) })
``` ```
Disables gloveboxes and trunks.
### createItem ### createItem
**Payload:** - Payload: `table`
- inventoryId?: `number` or `string` - inventoryId?: `number` or `string`
- metadata: `table` - metadata: `table`
- item: `table` - item: `table`
@@ -101,7 +98,9 @@ Disables gloveboxes and trunks.
Triggered when an item is created, either by buying it, using AddItem, or when converting inventory data. Triggered when an item is created, either by buying it, using AddItem, or when converting inventory data.
By returning a table you can modify or replace the metadata given to an item. By returning a table you can modify or replace the metadata given to an item.
**Example:** **Example**
Sets the label for "water" to "Mineral Water".
```lua ```lua
local hookId = exports.ox_inventory:registerHook('createItem', function(payload) local hookId = exports.ox_inventory:registerHook('createItem', function(payload)
@@ -117,11 +116,9 @@ end, {
}) })
``` ```
Sets the label for "water" to "Mineral Water".
### buyItem ### buyItem
**Payload:** - Payload: `table`
- source: `number` - source: `number`
- shopType: `string` - shopType: `string`
- shopId: `number` - shopId: `number`
@@ -136,7 +133,9 @@ Sets the label for "water" to "Mineral Water".
Triggered when an item is about to be purchased and can return `false` to prevent the transaction. Triggered when an item is about to be purchased and can return `false` to prevent the transaction.
**Example:** **Example**
Prevents players from purchasing items at General stores.
```lua ```lua
local hookId = exports.ox_inventory:registerHook('buyItem', function(payload) local hookId = exports.ox_inventory:registerHook('buyItem', function(payload)
@@ -151,12 +150,9 @@ end, {
``` ```
Prevents players from purchasing items at General stores.
### craftItem ### craftItem
**Payload:** - Payload: `table`
- source: `number` - source: `number`
- benchId: `number` - benchId: `number`
- benchIndex: `number` - benchIndex: `number`
@@ -170,7 +166,9 @@ Prevents players from purchasing items at General stores.
- toInventory: `number` - toInventory: `number`
- toSlot: `number` - toSlot: `number`
**Example:** **Example**
Prevent lockpicks from being crafted by players.
```lua ```lua
local hookId = exports.ox_inventory:registerHook('craftItem', function(payload) local hookId = exports.ox_inventory:registerHook('craftItem', function(payload)
@@ -185,15 +183,13 @@ end, {
``` ```
Prevent lockpicks from being crafted by players.
## removeHooks ## removeHooks
Removes a hook created by the invoking resource with the the specified id.
If no id is specified then all hooks registered by the resource are removed.
```lua ```lua
exports.ox_inventory:removeHooks(id) exports.ox_inventory:removeHooks(id)
``` ```
- id?: `number` - id?: `number`
Removes a hook created by the invoking resource with the the specified id.
If no id is specified then all hooks registered by the resource are removed.
+2
View File
@@ -2,6 +2,8 @@
title: Crafting title: Crafting
--- ---
# Crafting
Crafting locations, items and their ingredients are defined in [data/crafting.lua](https://github.com/overextended/ox_inventory/blob/main/data/crafting.lua). Crafting locations, items and their ingredients are defined in [data/crafting.lua](https://github.com/overextended/ox_inventory/blob/main/data/crafting.lua).
## Crafting definition ## Crafting definition
+18 -25
View File
@@ -1,19 +1,20 @@
--- ---
title: Creating items title: Creating Items
--- ---
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# Creating Items
## Defining item data ## Defining item data
Before being able to see or use an item in game it **must** first be defined. Before being able to see or use an item in game it **must** first be defined.
All of the items are defined in the `/data/items.lua` file with key, value pairs. All of the items are defined in the [/data/items.lua](https://github.com/overextended/ox_inventory/blob/main/data/items.lua) file with key, value pairs.
Key is the name (not the label) of an item and the value is a table containing the Key is the name (not the label) of an item and the value is a table containing the
options for the item. options for the item.
**Item options:** - Item options: `table`
- label: `string` - label: `string`
- weight?: `number` - weight?: `number`
- stack?: `boolean` - stack?: `boolean`
@@ -70,11 +71,10 @@ options for the item.
- action: `function`(slot: `number`) - action: `function`(slot: `number`)
- Callback function when button is clicked in context menu, returns item slot. - Callback function when button is clicked in context menu, returns item slot.
**Examples:** ### Examples
<Tabs items={["Burger", "Burger with description", "Burger with notification"]}> <Tabs items={["Burger", "Burger with description", "Burger with notification"]}>
<Tab> <Tab>
```lua ```lua
['burger'] = { ['burger'] = {
label = 'Burger', label = 'Burger',
@@ -93,10 +93,8 @@ options for the item.
} }
} }
``` ```
</Tab> </Tab>
<Tab> <Tab>
A modified burger item which includes a description. A modified burger item which includes a description.
```lua ```lua
@@ -118,10 +116,8 @@ A modified burger item which includes a description.
} }
} }
``` ```
</Tab> </Tab>
<Tab> <Tab>
A modified burger item, which gives you notifications on add and remove arguments. A modified burger item, which gives you notifications on add and remove arguments.
```lua ```lua
@@ -145,7 +141,6 @@ A modified burger item, which gives you notifications on add and remove argument
} }
} }
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -229,18 +224,6 @@ end)
Like with other items the item must first be registered. Like with other items the item must first be registered.
**Example:**
```lua
['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},
```
When registered you can define the item as a container in `/modules/items/containers.lua` When registered you can define the item as a container in `/modules/items/containers.lua`
The key for the container is the `name` you gave it when registering the item. The key for the container is the `name` you gave it when registering the item.
You can also define the number of slots, the maximum weight, blacklist and whitelist items. You can also define the number of slots, the maximum weight, blacklist and whitelist items.
@@ -257,9 +240,19 @@ You can also define the number of slots, the maximum weight, blacklist and white
- Supports single and multiple items - Supports single and multiple items
- `{ 'testburger', 'testburger2' }` - `{ 'testburger', 'testburger2' }`
**Example:** ### Example
```lua ```lua filename="Register Example"
['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},
```
```lua filename="Properties Example"
setContainerProperties('paperbag', { setContainerProperties('paperbag', {
slots = 5, slots = 5,
maxWeight = 1000, maxWeight = 1000,
+4 -2
View File
@@ -1,7 +1,9 @@
--- ---
title: Creating shops title: Creating Shops
--- ---
# Creating Shops
Builtin shops are defined in [data/shops.lua](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua), and more can be added here to benefit from the built-in markers or zones support. Builtin shops are defined in [data/shops.lua](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua), and more can be added here to benefit from the built-in markers or zones support.
## Shop definition ## Shop definition
@@ -84,7 +86,7 @@ Shops can be added using `exports.ox_inventory:RegisterShop` on the server, howe
- Blips, markers, and zones will not be created. - Blips, markers, and zones will not be created.
- Must use "locations" and not "targets" to define each shop using the archetype. - Must use "locations" and not "targets" to define each shop using the archetype.
**Example:** ### Example
```lua ```lua
exports.ox_inventory:RegisterShop('TestShop', { exports.ox_inventory:RegisterShop('TestShop', {
+6 -4
View File
@@ -1,14 +1,16 @@
--- ---
title: Custom stashes title: Custom Stashes
--- ---
import { GhButton } from '@components/button'; import { GhButton } from '@components/button';
# Custom Stashes
We can set up custom stashes from outside the resource utilising the exported RegisterStash function. We can set up custom stashes from outside the resource utilising the exported RegisterStash function.
Firstly, we need to define the stashes properties. Firstly, we need to define the stashes properties.
### Stash properties ## Stash properties
- id: `string` - id: `string`
- Unique name to identify the stash in the database. - Unique name to identify the stash in the database.
@@ -81,8 +83,8 @@ if ox_inventory:openInventory('stash', property.id) == false then
end end
``` ```
## Example resource ## Example Resource
We put together an example resource showcasing how to properly utilise the stash API: We put together an example resource showcasing how to properly utilise the stash API:
<GhButton link="https://www.github.com/overextended/ox_inventory_examples" /> <GhButton link="https://www.github.com/overextended/ox_inventory_examples" label="Ox Inventory Examples" />
+3 -1
View File
@@ -1,7 +1,9 @@
--- ---
title: Common issues title: Common Issues
--- ---
# Common Issues
## UI has not been built ## UI has not been built
Because the UI for inventory is written in React it can't run natively under FiveM so it must first be bundled into html/css/js. Because the UI for inventory is written in React it can't run natively under FiveM so it must first be bundled into html/css/js.
+2
View File
@@ -2,6 +2,8 @@ import { Callout } from 'nextra/components';
import { Tabs, Tab, Steps } from 'nextra-theme-docs'; import { Tabs, Tab, Steps } from 'nextra-theme-docs';
import ResourceLinks from '@components/resource-links'; import ResourceLinks from '@components/resource-links';
# Ox Lib
A standalone library for providing easily reusable code as importable modules and exports. A standalone library for providing easily reusable code as importable modules and exports.
<ResourceLinks repo="https://github.com/overextended/ox_lib" /> <ResourceLinks repo="https://github.com/overextended/ox_lib" />
+18 -32
View File
@@ -1,24 +1,23 @@
import { Tabs, Tab } from 'nextra-theme-docs';
# Server
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions. Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information. Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
import { Tabs, Tab } from 'nextra-theme-docs'; ## lib.addAce
### lib.addAce
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'. Assigns the ace permission to a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.addAce(principal, ace, allow) lib.addAce(principal, ace, allow)
lib.addAce('group.admin', 'command.say') lib.addAce('group.admin', 'command.say')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/server' import lib from '@overextended/ox_lib/server'
@@ -26,30 +25,26 @@ lib.addAce(principal, ace, allow)
lib.addAce('group.admin', 'command.say') lib.addAce('group.admin', 'command.say')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* principal: `string` - principal: `string`
* ace: `string` - ace: `string`
* allow: `boolean` - allow: `boolean`
### lib.removeAce ## lib.removeAce
Removes the ace permission from a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'. Removes the ace permission from a principal. Third parameter defaults to 'allow', while passing `false` sets the permission to 'deny'.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.removeAce(principal, ace, allow) lib.removeAce(principal, ace, allow)
lib.removeAce('group.admin', 'command.say') lib.removeAce('group.admin', 'command.say')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/server' import lib from '@overextended/ox_lib/server'
@@ -57,30 +52,26 @@ lib.removeAce(principal, ace, allow)
lib.removeAce('group.admin', 'command.say') lib.removeAce('group.admin', 'command.say')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* principal: `string` - principal: `string`
* ace: `string` - ace: `string`
* allow: `boolean` - allow: `boolean`
### lib.addPrincipal ## lib.addPrincipal
Assigns a principal to a parent principal. Children inherit permissions from the parent. Assigns a principal to a parent principal. Children inherit permissions from the parent.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.addPrincipal(child, parent) lib.addPrincipal(child, parent)
lib.addPrincipal('player.1', 'group.moderator') lib.addPrincipal('player.1', 'group.moderator')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/server' import lib from '@overextended/ox_lib/server'
@@ -88,29 +79,25 @@ lib.addPrincipal(child, parent)
lib.addPrincipal('player.1', 'group.moderator') lib.addPrincipal('player.1', 'group.moderator')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* child: `string` - child: `string`
* parent: `string` - parent: `string`
### lib.removePrincipal ## lib.removePrincipal
Removes a principal from a parent principal. Removes a principal from a parent principal.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.removePrincipal(child, parent) lib.removePrincipal(child, parent)
lib.removePrincipal('player.1', 'group.moderator') lib.removePrincipal('player.1', 'group.moderator')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/server' import lib from '@overextended/ox_lib/server'
@@ -118,9 +105,8 @@ lib.removePrincipal(child, parent)
lib.removePrincipal('player.1', 'group.moderator') lib.removePrincipal('player.1', 'group.moderator')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* child: `string` - child: `string`
* parent: `string` - parent: `string`
@@ -1,3 +1,5 @@
# Server
Registers commands and simplifies argument validation, permissions, and chat suggestions. Registers commands and simplifies argument validation, permissions, and chat suggestions.
```lua ```lua
+4 -2
View File
@@ -1,6 +1,8 @@
# Client
Registers keybinds and simplifies interactions of the keybinds. Registers keybinds and simplifies interactions of the keybinds.
### CKeybind ## CKeybind Class
A table representing a keybind with the following properties. A table representing a keybind with the following properties.
@@ -24,7 +26,7 @@ A table representing a keybind with the following properties.
- onReleased?: `function(self: CKeybind)` - onReleased?: `function(self: CKeybind)`
- User-defined function triggered on keybind release - User-defined function triggered on keybind release
### lib.addKeybind ## lib.addKeybind
```lua ```lua
lib.addKeybind(data) lib.addKeybind(data)
+8 -5
View File
@@ -1,9 +1,11 @@
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
# Client
Caches data related to the player. Caches data related to the player.
An interval runs every 100ms to update data that cannot be checked via handlers. An interval runs every 100ms to update data that cannot be checked via handlers.
## States ## Cache States
- ped: `number` - ped: `number`
- player entity id - player entity id
@@ -32,7 +34,6 @@ Register an event handler that is triggered when the cached value is updated.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.onCache(key, function(value) end) lib.onCache(key, function(value) end)
``` ```
@@ -51,10 +52,8 @@ lib.onCache('vehicle', function(value)
print('new vehicle:', value) print('new vehicle:', value)
end) end)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import { onCache } from '@overextended/ox_lib/client'; import { onCache } from '@overextended/ox_lib/client';
@@ -62,6 +61,11 @@ onCache(key, (value) => {});
``` ```
- key: `string` - key: `string`
- `ped`
- `vehicle`
- `seat`
- `weapon`
- `mount` (RedM only)
- value: `any` - value: `any`
```ts ```ts
@@ -72,6 +76,5 @@ lib.onCache('vehicle', (value) => {
console.log('new vehicle:', value); console.log('new vehicle:', value);
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -1,3 +1,5 @@
# Client
## Trigger Server Callback ## Trigger Server Callback
### triggerServerCallback ### triggerServerCallback
@@ -1,3 +1,5 @@
# Server
## Trigger Client Callback ## Trigger Client Callback
### triggerClientCallback ### triggerClientCallback
@@ -1,3 +1,5 @@
# Client
## Trigger Server Callback ## Trigger Server Callback
### lib.callback ### lib.callback
@@ -1,3 +1,5 @@
# Server
## Trigger Client Callback ## Trigger Client Callback
### lib.callback ### lib.callback
+4 -2
View File
@@ -1,4 +1,4 @@
# Cron # Server
A Lua implementation of cron, allowing tasks to be scheduled to run periodically at fixed times, dates, and intervals. A Lua implementation of cron, allowing tasks to be scheduled to run periodically at fixed times, dates, and intervals.
@@ -44,4 +44,6 @@ lib.cron.new(expression, job, options)
- options?: `table` - options?: `table`
- debug?: `boolean` - debug?: `boolean`
**returns**: OxTask Return:
- task: `OxTask`
@@ -1,6 +1,8 @@
# Client
A centralized way to track and disable controls. A centralized way to track and disable controls.
### lib.disableControls ## lib.disableControls
Call on frame to disable all stored controls. Call on frame to disable all stored controls.
@@ -8,7 +10,7 @@ Call on frame to disable all stored controls.
lib.disableControls() lib.disableControls()
``` ```
### lib.disableControls:Add ## lib.disableControls:Add
Adds the specified control(s) to the stored list. Adds the specified control(s) to the stored list.
If the control is already being tracked, the stored counter will be incremented. If the control is already being tracked, the stored counter will be incremented.
@@ -20,7 +22,7 @@ lib.disableControls:Add(...)
- vararg: `number` or `table` - vararg: `number` or `table`
- Control(s) to add a stored count of - Control(s) to add a stored count of
### lib.disableControls:Remove ## lib.disableControls:Remove
Removes the specified control(s) from the stored list. Removes the specified control(s) from the stored list.
If the stored counter for a given control is greater than one, the stored counter will be decremented. If the stored counter for a given control is greater than one, the stored counter will be decremented.
@@ -32,7 +34,7 @@ lib.disableControls:Remove(...)
- vararg: `number` or `table` - vararg: `number` or `table`
- Control(s) to remove a stored count of - Control(s) to remove a stored count of
### lib.disableControls:Clear ## lib.disableControls:Clear
Clears the stored counter(s) for the specified control(s). Clears the stored counter(s) for the specified control(s).
@@ -1,4 +1,6 @@
### lib.getClosestObject # Client
## lib.getClosestObject
Get the object handle and coords of the closest object to a set of coordinates. Get the object handle and coords of the closest object to a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getClosestPed # Client
## lib.getClosestPed
Get the ped handle and coords of the closest ped to a set of coordinates. Get the ped handle and coords of the closest ped to a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getClosestPlayer # Client
## lib.getClosestPlayer
Get the player id, ped handle, and coords of the closest player to a set of coordinates. Get the player id, ped handle, and coords of the closest player to a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getClosestVehicle # Client
## lib.getClosestVehicle
Get the vehicle handle and coords of the closest vehicle to a set of coordinates. Get the vehicle handle and coords of the closest vehicle to a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getNearbyObjects # Client
## lib.getNearbyObjects
Get the object handle and coords of all objects within range of a set of coordinates. Get the object handle and coords of all objects within range of a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getNearbyPeds # Client
## lib.getNearbyPeds
Get the ped handle and coords of all peds within range of a set of coordinates. Get the ped handle and coords of all peds within range of a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getNearbyPlayers # Client
## lib.getNearbyPlayers
Get the player id, ped handle, and coords of all players within range of a set of coordinates. Get the player id, ped handle, and coords of all players within range of a set of coordinates.
@@ -1,4 +1,6 @@
### lib.getNearbyVehicles # Client
## lib.getNearbyVehicles
Get the vehicle handle and coords of all vehicles within range of a set of coordinates. Get the vehicle handle and coords of all vehicles within range of a set of coordinates.
+2
View File
@@ -2,6 +2,8 @@
title: Interface title: Interface
--- ---
# Interface
If you wish to change the primary colour for the UI to better match your server's theme you can do so easily through the available convars. 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. They don't require you to build the UI, just restart the resource.
@@ -5,34 +5,29 @@ title: Alert Dialog
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Alert Dialog
Simple alert dialog that can display a message to the player. Simple alert dialog that can display a message to the player.
Returns whether the player pressed the confirm button or canceled the dialog. Returns whether the player pressed the confirm button or canceled the dialog.
### lib.alertDialog ## lib.alertDialog
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
<Tabs items={["Client", "Server"]}> <Tabs items={["Client", "Server"]}>
<Tab> <Tab>
```lua ```lua
lib.alertDialog(data) lib.alertDialog(data)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
TriggerClientEvent('ox_lib:alertDialog', source, data) TriggerClientEvent('ox_lib:alertDialog', source, data)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
</Callout> </Callout>
@@ -42,7 +37,6 @@ import lib from '@overextended/ox_lib/client';
lib.alertDialog(data); lib.alertDialog(data);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -65,34 +59,29 @@ lib.alertDialog(data);
Returns `'confirm'` if the player pressed the confirm button, otherwise if the player pressed the cancel button Returns `'confirm'` if the player pressed the confirm button, otherwise if the player pressed the cancel button
or has exited the dialog with ESC the return will be `'cancel'`. or has exited the dialog with ESC the return will be `'cancel'`.
### lib.closeAlertDialog ## lib.closeAlertDialog
Force closes the active alert dialog and sets its return data as `nil` Force closes the active alert dialog and sets its return data as `nil`
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.closeAlertDialog() lib.closeAlertDialog()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.closeAlertDialog(); lib.closeAlertDialog();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
**Example:** ## Example
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
local alert = lib.alertDialog({ local alert = lib.alertDialog({
header = 'Hello there', header = 'Hello there',
@@ -103,10 +92,8 @@ local alert = lib.alertDialog({
print(alert) print(alert)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -119,7 +106,6 @@ const alert = await lib.alertDialog({
console.log(alert); console.log(alert);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,38 +5,32 @@ title: Clipboard
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
### lib.setClipboard # Clipboard
## lib.setClipboard
Sets the player's clipboard to the specified string value. Sets the player's clipboard to the specified string value.
<Callout> <Callout>
Will not work if focus is already taken by some NUI component. Will not work if focus is already taken by some NUI component.
</Callout> </Callout>
<Callout> <Callout>
To create a new line use `\t\n` not just `\n` in your string. To create a new line use `\t\n` not just `\n` in your string.
</Callout> </Callout>
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.setClipboard(value) lib.setClipboard(value)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.setClipboard(value); lib.setClipboard(value);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,26 +5,24 @@ title: Context Menu
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
### lib.registerContext # Context Menu
## lib.registerContext
Used for registering a context menu. Used for registering a context menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerContext(context) lib.registerContext(context)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.registerContext(context); lib.registerContext(context);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -86,58 +84,50 @@ as you'd like.
The menu can be either in the order you write it in, or sorted alphabetically. The menu can be either in the order you write it in, or sorted alphabetically.
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys, otherwise not using keys and instead using tables will make the menu be in the order you define it as. To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys, otherwise not using keys and instead using tables will make the menu be in the order you define it as.
### lib.showContext ## lib.showContext
Opens a registered context menu by its id. Opens a registered context menu by its id.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.showContext(id) lib.showContext(id)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.showContext(id); lib.showContext(id);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- id: `string` - id: `string`
### lib.hideContext ## lib.hideContext
Hides any currently visible context menu. Hides any currently visible context menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.hideContext(onExit) lib.hideContext(onExit)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.hideContext(onExit); lib.hideContext(onExit);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- onExit: `boolean` - onExit: `boolean`
- Defines whether the onExit function for the menu should be ran or not. - Defines whether the onExit function for the menu should be ran or not.
### lib.getOpenContextMenu ## lib.getOpenContextMenu
Returns the id of the currently open context menu. Returns the id of the currently open context menu.
@@ -145,24 +135,20 @@ If no context menu is open returns `nil`.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.getOpenContextMenu() lib.getOpenContextMenu()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.getOpenContextMenu(); lib.getOpenContextMenu();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### Usage Example ## Usage Example
First we register the menu with our specified options then we call the show function in the command. First we register the menu with our specified options then we call the show function in the command.
@@ -172,7 +158,6 @@ First we register the menu with our specified options then we call the show func
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerContext({ lib.registerContext({
id = 'some_menu', id = 'some_menu',
@@ -218,11 +203,8 @@ lib.registerContext({
} }
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -270,7 +252,6 @@ lib.registerContext({
], ],
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -278,7 +259,6 @@ Then we can also register our second menu called `other_menu`
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerContext({ lib.registerContext({
id = 'other_menu', id = 'other_menu',
@@ -294,10 +274,8 @@ lib.registerContext({
} }
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
lib.registerContext({ lib.registerContext({
id: 'other_menu', id: 'other_menu',
@@ -313,7 +291,6 @@ lib.registerContext({
], ],
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -321,7 +298,6 @@ And the event that we are going to run from the `some_menu` menu, which is going
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
RegisterNetEvent('test_event', function(args) RegisterNetEvent('test_event', function(args)
lib.registerContext({ lib.registerContext({
@@ -338,11 +314,8 @@ RegisterNetEvent('test_event', function(args)
lib.showContext('event_menu') lib.showContext('event_menu')
end) end)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
onNet('test_event', (args: { someValue: number }) => { onNet('test_event', (args: { someValue: number }) => {
lib.registerContext({ lib.registerContext({
@@ -359,7 +332,6 @@ onNet('test_event', (args: { someValue: number }) => {
lib.showContext('event_menu'); lib.showContext('event_menu');
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -367,22 +339,18 @@ Lastly we register a test command to show the `some_menu` menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
RegisterCommand('testcontext', function() RegisterCommand('testcontext', function()
lib.showContext('some_menu') lib.showContext('some_menu')
end) end)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
RegisterCommand('testcontext', () => { RegisterCommand('testcontext', () => {
lib.showContext('some_menu'); lib.showContext('some_menu');
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,27 +5,24 @@ title: Input Dialog
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
The input dialog window allows you to take data from the user # Input Dialog
by setting input fields.
### lib.inputDialog The input dialog window allows you to take data from the user by setting input fields.
## lib.inputDialog
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.inputDialog(heading, rows, options) lib.inputDialog(heading, rows, options)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.inputDialog(heading, rows, options); lib.inputDialog(heading, rows, options);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -36,7 +33,7 @@ lib.inputDialog(heading, rows, options);
- allowCancel: `boolean` - allowCancel: `boolean`
- If true the user will not be able to cancel and close the input dialog until submitted. - If true the user will not be able to cancel and close the input dialog until submitted.
Available properties per field type: ### Field Type Properties
- input - input
@@ -168,31 +165,25 @@ The callback data is promise based meaning that the thread will not continue exe
The data returned will be a table (array), indexes represent the rows sent to the dialog, so if we want data from the first field that would be index `1` (`0`), if we want data from the third field, that would be index `3` (`2`), etc... The data returned will be a table (array), indexes represent the rows sent to the dialog, so if we want data from the first field that would be index `1` (`0`), if we want data from the third field, that would be index `3` (`2`), etc...
<Callout> <Callout>
Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value. Field types such as `date`, `date-range` and `time` return a unix timestamp on the set value.
</Callout> </Callout>
### lib.closeInputDialog ## lib.closeInputDialog
Force closes the active input dialog and sets its return data as `nil` Force closes the active input dialog and sets its return data as `nil`.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.closeInputDialog() lib.closeInputDialog()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.closeInputDialog(); lib.closeInputDialog();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -202,21 +193,16 @@ lib.closeInputDialog();
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'}) local input = lib.inputDialog('Basic dialog', {'First row', 'Second row'})
if not input then return end if not input then return end
print(json.encode(input), input[1], input[2]) print(json.encode(input), input[1], input[2])
``` ```
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
</Callout> </Callout>
```ts ```ts
@@ -225,7 +211,6 @@ const input = await lib.inputDialog('Basic dialog', ['First row', 'Second row'])
if (!input) return; if (!input) return;
console.log(input, input[0], input[1]); console.log(input, input[0], input[1]);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -235,7 +220,6 @@ console.log(input, input[0], input[1]);
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
local input = lib.inputDialog('Dialog title', { local input = lib.inputDialog('Dialog title', {
{type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16}, {type = 'input', label = 'Text input', description = 'Some input description', required = true, min = 4, max = 16},
@@ -254,14 +238,10 @@ local rgb = lib.math.torgba(input[4])
local timestamp = math.floor(input[5] / 1000) local timestamp = math.floor(input[5] / 1000)
local date = os.date('%Y-%m-%d %H:%M:%S', timestamp) local date = os.date('%Y-%m-%d %H:%M:%S', timestamp)
``` ```
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
</Callout> </Callout>
```ts ```ts
@@ -285,7 +265,6 @@ if (!color) return;
console.log(+color[1], +color[2], +color[3]); console.log(+color[1], +color[2], +color[3]);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
+9 -35
View File
@@ -5,28 +5,26 @@ title: Menu
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Menu
Keyboard navigation menu with specific event functions. Keyboard navigation menu with specific event functions.
### lib.registerMenu ## lib.registerMenu
Registers and caches a menu under the specified id. Registers and caches a menu under the specified id.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerMenu(data, cb) lib.registerMenu(data, cb)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.registerMenu(data, cb); lib.registerMenu(data, cb);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -74,96 +72,80 @@ lib.registerMenu(data, cb);
- cb: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`) - cb: `function`(selected: `number`, scrollIndex: `number`, args: `{[string]: any}`)
- Callback function when the menu item is pressed. - Callback function when the menu item is pressed.
### lib.showMenu ## lib.showMenu
Displays the menu with the provided id. Displays the menu with the provided id.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.showMenu(id) lib.showMenu(id)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.showMenu(id); lib.showMenu(id);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- id: `string` - id: `string`
### lib.hideMenu ## lib.hideMenu
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.hideMenu(onExit) lib.hideMenu(onExit)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.hideMenu(onExit); lib.hideMenu(onExit);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- onExit?: `boolean` - onExit?: `boolean`
- If true runs the menu's `onClose` function. - If true runs the menu's `onClose` function.
### lib.getOpenMenu ## lib.getOpenMenu
Returns the id of the currently open menu. Returns the id of the currently open menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.getOpenMenu() lib.getOpenMenu()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.getOpenMenu(); lib.getOpenMenu();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### lib.setMenuOptions ## lib.setMenuOptions
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.setMenuOptions(id, options, index) lib.setMenuOptions(id, options, index)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.setMenuOptions(id, options, index); lib.setMenuOptions(id, options, index);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -172,30 +154,26 @@ lib.setMenuOptions(id, options, index);
- index?: `number` - index?: `number`
- If specified only sets the options table on the specified options index. - If specified only sets the options table on the specified options index.
**Example:** ### Example
Replaces the 3rd index option of the specified menu Replaces the 3rd index option of the specified menu
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3) lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3); lib.setMenuOptions('some_menu_id', { label: 'New option', icon: 'plus' }, 3);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### Usage Example ## Usage Example
First we register the menu with our specified options then we call the show function in the command. First we register the menu with our specified options then we call the show function in the command.
@@ -205,7 +183,6 @@ First we register the menu with our specified options then we call the show func
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerMenu({ lib.registerMenu({
id = 'some_menu_id', id = 'some_menu_id',
@@ -254,10 +231,8 @@ RegisterCommand('testmenu', function()
lib.showMenu('some_menu_id') lib.showMenu('some_menu_id')
end) end)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -323,7 +298,6 @@ RegisterCommand(
false false
); );
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,39 +5,33 @@ title: Notifications
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
### lib.notify # Notifications
## lib.notify
Custom notifications with a lot of styling options. Custom notifications with a lot of styling options.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
<Tabs items={["Client", "Server"]}> <Tabs items={["Client", "Server"]}>
<Tab> <Tab>
```lua ```lua
lib.notify(data) lib.notify(data)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
TriggerClientEvent('ox_lib:notify', source, data) TriggerClientEvent('ox_lib:notify', source, data)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.notify(data); lib.notify(data);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -57,21 +51,18 @@ lib.notify(data);
- React CSS styling format - React CSS styling format
- icon?: `string` - icon?: `string`
- Font Awesome 6 icon name - Font Awesome 6 icon name
- iconColor: `string` - iconColor?: `string`
<Callout> <Callout>
Setting `iconColor` will get rid of the contrasted icon colour and it's circular background. Setting `iconColor` will get rid of the contrasted icon colour and it's circular background.
</Callout> </Callout>
### Usage Example ## Usage Example
#### Standard ### Standard
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.notify({ lib.notify({
title = 'Notification title', title = 'Notification title',
@@ -79,10 +70,8 @@ lib.notify({
type = 'success' type = 'success'
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -92,17 +81,15 @@ lib.notify({
type: 'success', type: 'success',
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
![notification](https://i.imgur.com/HFeBTLg.png) ![notification](https://i.imgur.com/HFeBTLg.png)
#### Custom ### Custom
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.notify({ lib.notify({
id = 'some_identifier', id = 'some_identifier',
@@ -120,10 +107,8 @@ lib.notify({
iconColor = '#C53030' iconColor = '#C53030'
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -143,7 +128,6 @@ lib.notify({
iconColor: '#C53030', iconColor: '#C53030',
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,81 +5,78 @@ title: Progress
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Progress
## lib.progressBar ## lib.progressBar
Displays a running progress bar. Displays a running progress bar.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.progressBar(data) lib.progressBar(data)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.progressBar(data) lib.progressBar(data)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* duration: `number` - duration: `number`
* label: `string` - label: `string`
* useWhileDead?: `boolean` - useWhileDead?: `boolean`
* allowRagdoll?: `boolean` - allowRagdoll?: `boolean`
* allowCuffed?: `boolean` - allowCuffed?: `boolean`
* allowFalling?: `boolean` - allowFalling?: `boolean`
* canCancel?: `boolean` - canCancel?: `boolean`
* anim?: `table` (`object`) - anim?: `table` (`object`)
* dict?: `string` - dict?: `string`
* Must specify either scenario or dict - Must specify either scenario or dict
* clip: `string` - clip: `string`
* flag?: `number` - flag?: `number`
* Default: `49` - Default: `49`
* blendIn?: `float` - blendIn?: `float`
* Default: `3.0` - Default: `3.0`
* blendOut?: `float` - blendOut?: `float`
* Default: `1.0` - Default: `1.0`
* duration?: `number` - duration?: `number`
Default: `-1` - Default: `-1`
* playbackRate?: `number` - playbackRate?: `number`
Default: `0` - Default: `0`
* lockX?: `boolean` - lockX?: `boolean`
* lockY?: `boolean` - lockY?: `boolean`
* lockZ?: `boolean` - lockZ?: `boolean`
* scenario?: `string` - scenario?: `string`
* Must specify either scenario or dict - Must specify either scenario or dict
* playEnter?: `boolean` - playEnter?: `boolean`
* Default: `true` - Default: `true`
* prop?: `table` (`object` or `array`) - prop?: `table` (`object` or `array`)
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ] - [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
* model: `hash` - model: `hash`
* bone?: `number` - bone?: `number`
* Default: `60309` - Default: `60309`
* pos: `table` - pos: `table`
* x: `number` - x: `number`
* y: `number` - y: `number`
* z: `number` - z: `number`
* rot: `table` (`object`) - rot: `table` (`object`)
* x: `number` - x: `number`
* y: `number` - y: `number`
* z: `number` - z: `number`
* disable?: `table` (`object`) - disable?: `table` (`object`)
* move?: `boolean` - move?: `boolean`
* car?: `boolean` - car?: `boolean`
* combat?: `boolean` - combat?: `boolean`
* mouse?: `boolean` - mouse?: `boolean`
### Usage Example ### Usage Example
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
if lib.progressBar({ if lib.progressBar({
duration = 2000, duration = 2000,
@@ -100,10 +97,8 @@ if lib.progressBar({
}, },
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end }) then print('Do stuff when complete') else print('Do stuff when cancelled') end
``` ```
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
</Callout> </Callout>
@@ -131,7 +126,6 @@ if (await lib.progressBar({
})) console.log('Do stuff when complete'); })) console.log('Do stuff when complete');
else console.log('Do stuff when cancelled') else console.log('Do stuff when cancelled')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -143,77 +137,72 @@ Similar to `lib.progressBar` except it displays a circle and you can define a po
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.progressCircle(data) lib.progressCircle(data)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.progressCircle(data) lib.progressCircle(data)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
* duration: `number` - duration: `number`
* label?: `string` - label?: `string`
* position?: `'middle'` or `'bottom'` - position?: `'middle'` or `'bottom'`
* Default: `'middle'` - Default: `'middle'`
* useWhileDead?: `boolean` - useWhileDead?: `boolean`
* allowRagdoll?: `boolean` - allowRagdoll?: `boolean`
* allowCuffed?: `boolean` - allowCuffed?: `boolean`
* allowFalling?: `boolean` - allowFalling?: `boolean`
* canCancel?: `boolean` - canCancel?: `boolean`
* anim?: `table` (`object`) - anim?: `table` (`object`)
* dict?: `string` - dict?: `string`
* Must specify either scenario or dict - Must specify either scenario or dict
* clip: `string` - clip: `string`
* flag?: `number` - flag?: `number`
* Default: `49` - Default: `49`
* blendIn?: `float` - blendIn?: `float`
* Default: `3.0` - Default: `3.0`
* blendOut?: `float` - blendOut?: `float`
* Default: `1.0` - Default: `1.0`
* duration?: `number` - duration?: `number`
Default: `-1` - Default: `-1`
* playbackRate?: `number` - playbackRate?: `number`
Default: `0` - Default: `0`
* lockX?: `boolean` - lockX?: `boolean`
* lockY?: `boolean` - lockY?: `boolean`
* lockZ?: `boolean` - lockZ?: `boolean`
* scenario?: `string` - scenario?: `string`
* Must specify either scenario or dict - Must specify either scenario or dict
* playEnter?: `boolean` - playEnter?: `boolean`
* Default: `true` - Default: `true`
* prop?: `table` (`object` or `array`) - prop?: `table` (`object` or `array`)
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ] - [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
* model: `hash` - model: `hash`
* bone?: `number` - bone?: `number`
* Default: `60309` - Default: `60309`
* pos: `table` - pos: `table`
* x: `number` - x: `number`
* y: `number` - y: `number`
* z: `number` - z: `number`
* rot: `table` (`object`) - rot: `table` (`object`)
* x: `number` - x: `number`
* y: `number` - y: `number`
* z: `number` - z: `number`
* disable?: `table` (`object`) - disable?: `table` (`object`)
* move?: `boolean` - move?: `boolean`
* car?: `boolean` - car?: `boolean`
* combat?: `boolean` - combat?: `boolean`
* mouse?: `boolean` - mouse?: `boolean`
### Usage Example ### Usage Example
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
if lib.progressCircle({ if lib.progressCircle({
duration = 2000, duration = 2000,
@@ -234,10 +223,8 @@ if lib.progressCircle({
}, },
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end }) then print('Do stuff when complete') else print('Do stuff when cancelled') end
``` ```
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`. This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
</Callout> </Callout>
@@ -265,7 +252,6 @@ if (await lib.progressCircle({
})) console.log('Do stuff when complete') })) console.log('Do stuff when complete')
else console.log('Do stuff when cancelled') else console.log('Do stuff when cancelled')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -277,20 +263,16 @@ Returns true if a progress bar is currently active.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.progressActive() lib.progressActive()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.progressActive() lib.progressActive()
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -301,19 +283,15 @@ progress bar can be cancelled then it cancels it.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.cancelProgress() lib.cancelProgress()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.cancelProgress() lib.cancelProgress()
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,30 +5,28 @@ title: Radial Menu
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Radial Menu
- Radial menu has a global menu that's by default accessed with `z` and only displays when there is at least one item. - 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`. - 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. - Use `lib.registerRadial` for creating sub menus and use the `menu` property on the items to open those sub menus.
### lib.addRadialItem ## lib.addRadialItem
Item or array of items added to the global radial menu. Item or array of items added to the global radial menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.addRadialItem(items) lib.addRadialItem(items)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.addRadialItem(items); lib.addRadialItem(items);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -44,74 +42,62 @@ lib.addRadialItem(items);
- Function that's ran when a user clicks the item. - Function that's ran when a user clicks the item.
- keepOpen?: `boolean` - keepOpen?: `boolean`
### lib.removeRadialItem ## lib.removeRadialItem
Id of an item to be removed from the global menu. Id of an item to be removed from the global menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.removeRadialItem(item) lib.removeRadialItem(item)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.removeRadialItem(item); lib.removeRadialItem(item);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- id: `string` - id: `string`
### lib.clearRadialItems ## lib.clearRadialItems
Removes all items from the radial menu. Removes all items from the radial menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.clearRadialItems() lib.clearRadialItems()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.clearRadialItems(); lib.clearRadialItems();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### lib.registerRadial ## lib.registerRadial
Registers a radial sub menu with predefined options. Registers a radial sub menu with predefined options.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.registerRadial(radial) lib.registerRadial(radial)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.registerRadial(radial); lib.registerRadial(radial);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -127,92 +113,77 @@ lib.registerRadial(radial);
- onSelect?: `function(currentMenu: string | nil, itemIndex: number)` | `string` - onSelect?: `function(currentMenu: string | nil, itemIndex: number)` | `string`
- Function that's ran when a user clicks the item. - Function that's ran when a user clicks the item.
### lib.hideRadial ## lib.hideRadial
Hides the radial menu if one is open. Hides the radial menu if one is open.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.hideRadial() lib.hideRadial()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.hideRadial(); lib.hideRadial();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### lib.disableRadial ## lib.disableRadial
Disallow players from opening the radial menu. Disallow players from opening the radial menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.disableRadial(state) lib.disableRadial(state)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.disableRadial(state); lib.disableRadial(state);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
- state: `boolean` - state: `boolean`
- Whether or not radial menu should be disabled - Whether or not radial menu should be disabled
### lib.getCurrentRadialId ## lib.getCurrentRadialId
Returns the id of the currently open radial menu. Returns the id of the currently open radial menu.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
local id = lib.getCurrentRadialId() local id = lib.getCurrentRadialId()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
let id = lib.getCurrentRadialId(); let id = lib.getCurrentRadialId();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### Usage Example ## Usage Example
<Callout> <Callout>
When adding radial menu items whether they are global or for a sub menu, make sure to stick to short as possible labels When adding radial menu items whether they are global or for a sub menu, make sure to stick to short as possible labels
as long labels will look out of place and should not be used with the radial menu because of its density. as long labels will look out of place and should not be used with the radial menu because of its density.
</Callout> </Callout>
Here's a use case example with some global options and an option utilising the lib's points system. Here's a use case example with some global options and an option utilising the lib's points system.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
exports('myMenuHandler', function(menu, item) exports('myMenuHandler', function(menu, item)
print(menu, item) print(menu, item)
@@ -287,14 +258,10 @@ function point:onExit()
lib.removeRadialItem('garage_access') lib.removeRadialItem('garage_access')
end end
``` ```
</Tab> </Tab>
<Tab> <Tab>
<Callout> <Callout>
Points system in the lib isn't available for the npm package. Points system in the lib isn't available for the npm package.
</Callout> </Callout>
```ts ```ts
@@ -355,7 +322,6 @@ lib.addRadialItem([
} }
]) ])
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -4,26 +4,24 @@ title: Skill Check
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
### lib.skillCheck # Skill Check
## lib.skillCheck
Runs a skill check with the defined difficulty. Runs a skill check with the defined difficulty.
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.skillCheck(difficulty, inputs) lib.skillCheck(difficulty, inputs)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.skillCheck(difficulty, inputs); lib.skillCheck(difficulty, inputs);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -41,18 +39,15 @@ lib.skillCheck(difficulty, inputs);
- A random key will be picked from the inputs table for each skill check - A random key will be picked from the inputs table for each skill check
- If no inputs are defined the key is defaulted to `e` - If no inputs are defined the key is defaulted to `e`
### Usage Example ## Usage Example
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'}) local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -61,7 +56,6 @@ const success = await lib.skillCheck(
['w', 'a', 's', 'd'] ['w', 'a', 's', 'd']
); );
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -5,32 +5,28 @@ title: TextUI
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
### lib.showTextUI # TextUI
## lib.showTextUI
Show the TextUI window. Show the TextUI window.
<Callout type="warning"> <Callout type="warning">
**DO NOT** run this function every tick, it's intended to be used as a toggle. **DO NOT** run this function every tick, it's intended to be used as a toggle.
</Callout> </Callout>
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.showTextUI(text, options) lib.showTextUI(text, options)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.showTextUI(text, options); lib.showTextUI(text, options);
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -42,59 +38,69 @@ lib.showTextUI(text, options);
- iconColor?: `string` - iconColor?: `string`
- style?: React.CSSProperties - style?: React.CSSProperties
### lib.hideTextUI ## lib.hideTextUI
Hides the currently visible TextUI window Hides the currently visible TextUI window
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.hideTextUI() lib.hideTextUI()
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.hideTextUI(); lib.hideTextUI();
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### Usage Example ## lib.isTextUIOpen
#### Basic Returns whether Text UI is opened or not
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua
lib.isTextUIOpen()
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client';
lib.isTextUIOpen();
```
</Tab>
</Tabs>
## Usage Example
### Basic
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua ```lua
lib.showTextUI('[E] - Fuel vehicle') lib.showTextUI('[E] - Fuel vehicle')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
lib.showTextUI('[E] - Fuel vehicle'); lib.showTextUI('[E] - Fuel vehicle');
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
![basic_example](https://i.imgur.com/uZS40fD.png) ![basic_example](https://i.imgur.com/uZS40fD.png)
#### Custom styling ### Custom styling
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.showTextUI('[E] - Pick apple', { lib.showTextUI('[E] - Pick apple', {
position = "top-center", position = "top-center",
@@ -106,10 +112,8 @@ lib.showTextUI('[E] - Pick apple', {
} }
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client'; import lib from '@overextended/ox_lib/client';
@@ -123,32 +127,7 @@ lib.showTextUI('[E] - Pick apple', {
}, },
}); });
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### lib.isTextUIOpen
Returns whether Text UI is opened or not
<Tabs items={["Lua", "JS"]}>
<Tab>
```lua
lib.isTextUIOpen()
```
</Tab>
<Tab>
```ts
import lib from '@overextended/ox_lib/client';
lib.isTextUIOpen();
```
</Tab>
</Tabs>
![custom_example](https://i.imgur.com/sy9lPC0.png) ![custom_example](https://i.imgur.com/sy9lPC0.png)
+2
View File
@@ -1,3 +1,5 @@
# Shared
Allows servers to set a preferred language and attempt to load locale files in any resources using the module. 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` Locale files should use the [ISO Language Code](http://www.lingoes.net/en/translator/langcode.htm) and be saved as `./locales/langcode.json`
+2 -8
View File
@@ -1,5 +1,7 @@
import { Steps, Tabs, Tab } from 'nextra-theme-docs'; import { Steps, Tabs, Tab } from 'nextra-theme-docs';
# Server
## lib.logger ## lib.logger
```lua ```lua
@@ -41,7 +43,6 @@ Set your API key and [Datadog site](https://docs.datadoghq.com/getting_started/s
set datadog:key "yourapikey" set datadog:key "yourapikey"
set datadog:site "datadoghq.com" set datadog:site "datadoghq.com"
``` ```
</Steps> </Steps>
## Grafana Loki ## Grafana Loki
@@ -51,7 +52,6 @@ It is designed to be very cost effective and easy to operate.
<Tabs items={["Cloud", "Self-hosted"]}> <Tabs items={["Cloud", "Self-hosted"]}>
<Tab> <Tab>
- Has free tier with some restrictions - Has free tier with some restrictions
- Easy to manage - Easy to manage
- Easier to setup - Easier to setup
@@ -63,9 +63,7 @@ It is designed to be very cost effective and easy to operate.
### Setup Loki ### Setup Loki
Find the Loki section in your account panel, and click "Details". Find the Loki section in your account panel, and click "Details".
Generate a password and save the API key, as well as your `user` and `url`. Generate a password and save the API key, as well as your `user` and `url`.
</Steps> </Steps>
</Tab> </Tab>
<Tab> <Tab>
To setup a grafana instance you'll need docker, and knowledge on containers or kubernetes. To setup a grafana instance you'll need docker, and knowledge on containers or kubernetes.
@@ -74,11 +72,9 @@ It is designed to be very cost effective and easy to operate.
Once done, setup authentication and use the username and password securing your endpoint. Once done, setup authentication and use the username and password securing your endpoint.
- By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access. - By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
</Tab> </Tab>
</Tabs> </Tabs>
<Steps>
### Config ### Config
Use the following convars to set your logging service, endpoint, and authentication details. Use the following convars to set your logging service, endpoint, and authentication details.
@@ -88,5 +84,3 @@ It is designed to be very cost effective and easy to operate.
set loki:password "<insert the api key or password>" set loki:password "<insert the api key or password>"
set loki:endpoint "<insert loki url without http:// or https://>" set loki:endpoint "<insert loki url without http:// or https://>"
``` ```
</Steps>
+2
View File
@@ -1,3 +1,5 @@
# Shared
## lib.math ## lib.math
Extends the standard Lua math table with extra functions. Extends the standard Lua math table with extra functions.
@@ -1,4 +1,6 @@
# Points # Client
## Points
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates. Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
+7 -7
View File
@@ -1,8 +1,8 @@
# Points # Client
Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates. Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.
### CPoint ## CPoint Class
A table representing a point with the following properties. A table representing a point with the following properties.
@@ -22,7 +22,7 @@ A table representing a point with the following properties.
- nearby?: `function(self: CPoint)` - nearby?: `function(self: CPoint)`
- Function triggered on frame when within `distance` of the point - Function triggered on frame when within `distance` of the point
### lib.points.new ## lib.points.new
```lua ```lua
lib.points.new(data) lib.points.new(data)
@@ -36,7 +36,7 @@ Returns:
- point: `CPoint` - point: `CPoint`
#### Example ### Example
```lua ```lua
local point = lib.points.new({ local point = lib.points.new({
coords = GetEntityCoords(cache.ped), coords = GetEntityCoords(cache.ped),
@@ -61,7 +61,7 @@ function point:nearby()
end end
``` ```
### lib.points.getAllPoints ## lib.points.getAllPoints
Get a table of all points created in the resource. Get a table of all points created in the resource.
@@ -73,7 +73,7 @@ Return:
- points: `CPoint[]` - points: `CPoint[]`
### lib.points.getNearbyPoints ## lib.points.getNearbyPoints
Get an array of all points in range of the player. Get an array of all points in range of the player.
@@ -85,7 +85,7 @@ Return:
- nearbyPoints: `CPoint[]` - nearbyPoints: `CPoint[]`
### lib.points.getClosestPoint ## lib.points.getClosestPoint
Get the data for the closest point to the player. Get the data for the closest point to the player.
+3 -1
View File
@@ -1,4 +1,6 @@
### lib.raycast.cam # Client
## lib.raycast.cam
Starts a shapetest originating from the camera, extending to ~10m by default. Starts a shapetest originating from the camera, extending to ~10m by default.
+13 -39
View File
@@ -1,26 +1,24 @@
import { Tabs, Tab } from 'nextra-theme-docs';
# Client
Check if assets exist, such as models, and loads them into memory. Check if assets exist, such as models, and loads them into memory.
Throws errors for invalid assets and returns true if the asset is loaded. Throws errors for invalid assets and returns true if the asset is loaded.
import { Tabs, Tab } from 'nextra-theme-docs'; ## lib.requestAnimDict
### lib.requestAnimDict
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestAnimDict(dict, timeout) lib.requestAnimDict(dict, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestAnimDict(dict, timeout) lib.requestAnimDict(dict, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -29,24 +27,20 @@ lib.requestAnimDict(dict, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestAnimSet ## lib.requestAnimSet
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestAnimSet(set, timeout) lib.requestAnimSet(set, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestAnimSet(set, timeout) lib.requestAnimSet(set, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -55,24 +49,20 @@ lib.requestAnimSet(set, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestModel ## lib.requestModel
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestModel(model, timeout) lib.requestModel(model, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestModel(model, timeout) lib.requestModel(model, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -81,24 +71,20 @@ lib.requestModel(model, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestStreamedTextureDict ## lib.requestStreamedTextureDict
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestStreamedTextureDict(dict, timeout) lib.requestStreamedTextureDict(dict, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestStreamedTextureDict(dict, timeout) lib.requestStreamedTextureDict(dict, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -107,24 +93,20 @@ lib.requestStreamedTextureDict(dict, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestNamedPtfxAsset ## lib.requestNamedPtfxAsset
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestNamedPtfxAsset(ptFxName, timeout) lib.requestNamedPtfxAsset(ptFxName, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestNamedPtfxAsset(ptFxName, timeout) lib.requestNamedPtfxAsset(ptFxName, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -133,24 +115,20 @@ lib.requestNamedPtfxAsset(ptFxName, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestScaleformMovie ## lib.requestScaleformMovie
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestScaleformMovie(scaleformName, timeout) lib.requestScaleformMovie(scaleformName, timeout)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestScaleformMovie(scaleformName, timeout) lib.requestScaleformMovie(scaleformName, timeout)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -159,24 +137,20 @@ lib.requestScaleformMovie(scaleformName, timeout)
- Number of ticks to wait for the asset to load. - Number of ticks to wait for the asset to load.
- Default: `500` - Default: `500`
### lib.requestWeaponAsset ## lib.requestWeaponAsset
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags) lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags) lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComponentFlags)
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
@@ -189,7 +163,7 @@ lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComp
- extraWeaponComponentFlags?: `ExtraWeaponComponentFlags` - extraWeaponComponentFlags?: `ExtraWeaponComponentFlags`
- Default: `0` - Default: `0`
#### WeaponResourceFlags ### WeaponResourceFlags
``` ```
1 WRF_REQUEST_BASE_ANIMS 1 WRF_REQUEST_BASE_ANIMS
@@ -201,7 +175,7 @@ lib.requestWeaponAsset(weaponType, timeout, weaponResourceFlags, extraWeaponComp
31 WRF_REQUEST_ALL_ANIMS 31 WRF_REQUEST_ALL_ANIMS
``` ```
#### ExtraWeaponComponentFlags ### ExtraWeaponComponentFlags
``` ```
0 WEAPON_COMPONENT_NONE 0 WEAPON_COMPONENT_NONE
+7 -5
View File
@@ -1,13 +1,15 @@
Adds additional functions alongside the standard table library # Shared
Adds additional functions alongside the standard table library.
## lib.table.contains ## lib.table.contains
Checks if `table` contains the given `value`. Only intended for simple values and unnested tables.
```lua ```lua
lib.table.contains(tbl, value) lib.table.contains(tbl, value)
``` ```
Checks if `table` contains the given `value`. Only intended for simple values and unnested tables.
- tbl: `table` - tbl: `table`
- value: `any` - value: `any`
@@ -16,12 +18,12 @@ Return:
## lib.table.matches ## lib.table.matches
Compares if two values are equal, iterating over tables and matching both keys and values.
```lua ```lua
lib.table.matches(tableOne, tableTwo) lib.table.matches(tableOne, tableTwo)
``` ```
Compares if two values are equal, iterating over tables and matching both keys and values.
- tableOne: `table` - tableOne: `table`
- tableTwo: `table` - tableTwo: `table`
@@ -1,9 +1,11 @@
# Client
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props. Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5 https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L3
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
### lib.getVehicleProperties ## lib.getVehicleProperties
```ts ```ts
lib.getVehicleProperties(vehicle) lib.getVehicleProperties(vehicle)
@@ -15,24 +17,20 @@ lib.getVehicleProperties(vehicle)
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId())) lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId())) lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
### lib.setVehicleProperties ## lib.setVehicleProperties
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_. Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
@@ -45,16 +43,13 @@ lib.setVehicleProperties(vehicle, props)
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data) RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
lib.setVehicleProperties(NetToVeh(netid), data) lib.setVehicleProperties(NetToVeh(netid), data)
end) end)
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/client' import lib from '@overextended/ox_lib/client'
@@ -62,11 +57,10 @@ onNet('ox_lib:setVehicleProperties', (netid, data) => {
lib.setVehicleProperties(NetToVeh(netid), data) lib.setVehicleProperties(NetToVeh(netid), data)
}) })
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
#### Recommended Usage ### Recommended Usage
The server should tell the owner of the entity to set properties, using the following trigger. The server should tell the owner of the entity to set properties, using the following trigger.
@@ -74,7 +68,7 @@ The server should tell the owner of the entity to set properties, using the foll
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data) TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
``` ```
### Vehicle Properties ## Vehicle Properties
- model?: `number` - model?: `number`
- plate?: `string` - plate?: `string`
+6 -9
View File
@@ -1,8 +1,11 @@
### lib.versionCheck import { Tabs, Tab } from 'nextra-theme-docs';
# Server
## lib.versionCheck
Compares the resource version to the latest published release on GitHub. Compares the resource version to the latest published release on GitHub.
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
import { Tabs, Tab } from 'nextra-theme-docs';
```lua ```lua
lib.versionCheck(repository) lib.versionCheck(repository)
@@ -12,21 +15,15 @@ lib.versionCheck(repository)
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
lib.versionCheck('overextended/ox_lib') lib.versionCheck('overextended/ox_lib')
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/server' import lib from '@overextended/ox_lib/server'
lib.versionCheck('overextended/ox_lib') lib.versionCheck('overextended/ox_lib')
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
[Utilises GitHub's release API](https://docs.github.com/en/rest/reference/releases)
+5 -7
View File
@@ -1,9 +1,11 @@
### lib.checkDependency import { Tabs, Tab } from 'nextra-theme-docs';
# Shared
## lib.checkDependency
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors. Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
import { Tabs, Tab } from 'nextra-theme-docs';
```lua ```lua
lib.checkDependency(resource, version) lib.checkDependency(resource, version)
``` ```
@@ -13,20 +15,16 @@ lib.checkDependency(resource, version)
<Tabs items={["Lua", "JS"]}> <Tabs items={["Lua", "JS"]}>
<Tab> <Tab>
```lua ```lua
if not lib.checkDependency('ox_lib', '1.5.0') then error() end if not lib.checkDependency('ox_lib', '1.5.0') then error() end
``` ```
</Tab> </Tab>
<Tab> <Tab>
```ts ```ts
import lib from '@overextended/ox_lib/shared' import lib from '@overextended/ox_lib/shared'
// import { checkDependency } from '@overextended/ox_lib/shared' // import { checkDependency } from '@overextended/ox_lib/shared'
if (!lib.checkDependency('ox_lib', '1.5.0')) error() if (!lib.checkDependency('ox_lib', '1.5.0')) error()
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
+2 -7
View File
@@ -1,12 +1,12 @@
import { Tabs, Tab } from 'nextra-theme-docs'; import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Shared
Faster alternative to PolyZone utilising [glm.polygon](https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/EXTENDED.md). Faster alternative to PolyZone utilising [glm.polygon](https://github.com/citizenfx/lua/blob/luaglm-dev/cfx/EXTENDED.md).
<Callout> <Callout>
Currently zones only have basic support on the server side. Some features will not work such as `onEnter`, `onExit`, and `inside`. Currently zones only have basic support on the server side. Some features will not work such as `onEnter`, `onExit`, and `inside`.
</Callout> </Callout>
## lib.zones.poly ## lib.zones.poly
@@ -147,7 +147,6 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
<Tabs items={["function", "array", "ox_target"]}> <Tabs items={["function", "array", "ox_target"]}>
<Tab> <Tab>
```lua ```lua
local poly = lib.zones.poly({ local poly = lib.zones.poly({
name = poly, name = poly,
@@ -161,10 +160,8 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
thickness = 2, thickness = 2,
}) })
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
{ {
name = poly, name = poly,
@@ -180,7 +177,6 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
``` ```
</Tab> </Tab>
<Tab> <Tab>
```lua ```lua
exports.ox_target:addPolyZone({ exports.ox_target:addPolyZone({
name = poly, name = poly,
@@ -194,6 +190,5 @@ Zones will be saved to `ox_lib/created_zones.lua` with your chosen format.
thickness = 2, thickness = 2,
}) })
``` ```
</Tab> </Tab>
</Tabs> </Tabs>
+2
View File
@@ -2,6 +2,8 @@ import ResourceLinks from '@components/resource-links';
import { Steps, Tabs, Tab } from 'nextra-theme-docs'; import { Steps, Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Ox Target
<ResourceLinks repo="https://github.com/overextended/ox_target" /> <ResourceLinks repo="https://github.com/overextended/ox_target" />
A performant and flexible standalone targeting resource or "third-eye", with additional functionality for ox_inventory, ox_core, qb-core, and es_extended. A performant and flexible standalone targeting resource or "third-eye", with additional functionality for ox_inventory, ox_core, qb-core, and es_extended.
+2
View File
@@ -1,3 +1,5 @@
# Client
All exports with the `options` argument expect a table with the targeting properties [here](../Options). All exports with the `options` argument expect a table with the targeting properties [here](../Options).
## disableTargeting ## disableTargeting
+4 -2
View File
@@ -1,6 +1,8 @@
# Options
When creating a targetable option you must send an array of options with the following properties. When creating a targetable option you must send an array of options with the following properties.
## Options ## Option Parameters
- label: `string` - label: `string`
- name?: `string` - name?: `string`
@@ -27,7 +29,7 @@ When creating a targetable option you must send an array of options with the fol
- serverEvent?: `string` - serverEvent?: `string`
- command?: `string` - command?: `string`
## Option effect ## Option Effects
When selecting an option it will trigger a single action, in order of priority: When selecting an option it will trigger a single action, in order of priority:
+2
View File
@@ -2,6 +2,8 @@
title: OxMySQL title: OxMySQL
--- ---
# OxMySQL
import { Steps } from 'nextra-theme-docs'; import { Steps } from 'nextra-theme-docs';
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
import ResourceLinks from '@components/resource-links'; import ResourceLinks from '@components/resource-links';
+2
View File
@@ -4,6 +4,8 @@ title: insert
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Insert
Inserts a new entry into the database and returns the insert id for the row, if valid. Inserts a new entry into the database and returns the insert id for the row, if valid.
## Promise ## Promise
+2
View File
@@ -4,6 +4,8 @@ title: prepare
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Prepare
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query. Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
- Date will not return the datestring commonly used in FiveM - Date will not return the datestring commonly used in FiveM
+2
View File
@@ -4,6 +4,8 @@ title: query
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Query
When selecting data, returns all matching rows and columns; otherwise, returns data like insertId, affectedRows, etc. When selecting data, returns all matching rows and columns; otherwise, returns data like insertId, affectedRows, etc.
## Promise ## Promise
+2
View File
@@ -4,6 +4,8 @@ title: rawExecute
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# RawExecute
rawExecute can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query. rawExecute can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
- Date will not return the datestring commonly used in FiveM - Date will not return the datestring commonly used in FiveM
+2
View File
@@ -4,6 +4,8 @@ title: scalar
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Scalar
Returns the first column for a single row. Returns the first column for a single row.
## Promise ## Promise
+2
View File
@@ -4,6 +4,8 @@ title: single
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Single
Returns all selected columns for a single row. Returns all selected columns for a single row.
## Promise ## Promise
+2
View File
@@ -4,6 +4,8 @@ title: transaction
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Transaction
A transaction executes multiple queries and commits them only if all succeed. A transaction executes multiple queries and commits them only if all succeed.
If one fails, none of the queries are committed. If one fails, none of the queries are committed.
+2
View File
@@ -4,6 +4,8 @@ title: update
import { Tab, Tabs } from 'nextra-theme-docs'; import { Tab, Tabs } from 'nextra-theme-docs';
# Update
Returns the number of rows affected by the query. Returns the number of rows affected by the query.
## Promise ## Promise
+2
View File
@@ -1,3 +1,5 @@
# Benchmark
```lua ```lua
-- Internal benchmark -- Internal benchmark
Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries) Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)
+2
View File
@@ -4,6 +4,8 @@ title: Common Issues
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# Common Issues
## Unable to establish a connection ## Unable to establish a connection
This is usually the result of incorrect database settings or your password containing reserved characters. This is usually the result of incorrect database settings or your password containing reserved characters.
+2
View File
@@ -1,3 +1,5 @@
# Placeholders
Placeholders allow for query parameters to be safely executed, preventing [common SQL injection methods](https://bobby-tables.com/). Placeholders allow for query parameters to be safely executed, preventing [common SQL injection methods](https://bobby-tables.com/).
Parameters can be passed an an array or map (referred to as named named parameters). Parameters can be passed an an array or map (referred to as named named parameters).
+2
View File
@@ -2,6 +2,8 @@
title: Using the Debug UI title: Using the Debug UI
--- ---
# Using the Debug UI
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
The debug UI lets you easily see all the queries that have been executed by resources, query response times, and per-resource statistics. The debug UI lets you easily see all the queries that have been executed by resources, query response times, and per-resource statistics.