mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 22:22:46 +00:00
formatting and typos
This commit is contained in:
1 parent
75698216e0
commit
724c7e356d
99 files changed
+515
-305
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ and click the "Edit this page" at the bottom and submit a Pull Request.
|
|||||||
|
|
||||||
## Support our team
|
## Support our team
|
||||||
|
|
||||||
Our projects will always remain free and open-source, with our core developers working voluntarily.
|
Our projects will always remain free and open-source, with our core developers working voluntarily.
|
||||||
If you love what we do and want to help us continue, why not show your appreciation with a donation?
|
If you love what we do and want to help us continue, why not show your appreciation with a donation?
|
||||||
|
|
||||||
<div style={{paddingLeft:"50px", lineHeight:"20px", background:"url('https://avatars.githubusercontent.com/u/65407488?s=70&v=4') no-repeat left", backgroundSize:"40px"}}>
|
<div style={{paddingLeft:"50px", lineHeight:"20px", background:"url('https://avatars.githubusercontent.com/u/65407488?s=70&v=4') no-repeat left", backgroundSize:"40px"}}>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ We'll try to explain some technical but core concepts used in ox_core here.
|
|||||||
|
|
||||||
## Classes
|
## Classes
|
||||||
|
|
||||||
Lua doesn't have support for true clases, but rather prototype-based inheritance.
|
Lua doesn't have support for true classes, but rather prototype-based inheritance.
|
||||||
A prototype can hold its own variables and methods, which another object (an instance) can reference or call.
|
A prototype can hold its own variables and methods, which another object (an instance) can reference or call.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Config
|
# Config
|
||||||
|
|
||||||
Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/).
|
Resource configuration is handled using [convars](https://docs.fivem.net/docs/scripting-reference/convars/).
|
||||||
|
|
||||||
```yml
|
```yaml
|
||||||
# Players must have a valid identifier to join the server. Used to fetch userid from the database.
|
# Players must have a valid identifier to join the server. Used to fetch userid from the database.
|
||||||
set ox:primaryIdentifier "fivem"
|
set ox:primaryIdentifier "fivem"
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ Lua imports can be defined as part of fxmanifest, or loaded with the load functi
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
client_scripts {
|
client_scripts {
|
||||||
'@ox_core/imports/client.lua',
|
'@ox_core/imports/client.lua',
|
||||||
'client/main.lua',
|
'client/main.lua',
|
||||||
}
|
}
|
||||||
|
|
||||||
server_scripts {
|
server_scripts {
|
||||||
'@oxmysql/lib/MySQL.lua',
|
'@oxmysql/lib/MySQL.lua',
|
||||||
'@ox_core/imports/server.lua',
|
'@ox_core/imports/server.lua',
|
||||||
'server/main.lua',
|
'server/main.lua',
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
||||||
This resource is **not production ready**. Breaking changes are guaranteed, and support is limited.
|
This resource is **not production ready**. Breaking changes are guaranteed, and support is limited.
|
||||||
Documentation may fall behind and be rendered obsolete.
|
Documentation may fall behind and be rendered obsolete.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
We **strongly** recommend using Git to help with version control and separating your own changes from the original source code.
|
We **strongly** recommend using Git to help with version control and separating your own changes from the original source code.
|
||||||
Refer to [GitHub's guide to setting up Git](https://docs.github.com/en/get-started/quickstart/set-up-git#setting-up-git).
|
Refer to [GitHub's guide to setting up Git](https://docs.github.com/en/get-started/quickstart/set-up-git#setting-up-git).
|
||||||
|
|
||||||
You can also download a Git GUI client, such as [GitKraken](https://www.gitkraken.com/), to improve your workflow and more easily maintain changes.
|
You can also download a Git GUI client, such as [GitKraken](https://www.gitkraken.com/), to improve your workflow and more easily maintain changes.
|
||||||
@@ -38,7 +38,7 @@ These resources are required for ox_core to function, and must start before it.
|
|||||||
- Open a terminal, command prompt, etc. and navigate to your resources folder.
|
- Open a terminal, command prompt, etc. and navigate to your resources folder.
|
||||||
- Execute the following commands
|
- Execute the following commands
|
||||||
|
|
||||||
```
|
```bash
|
||||||
npm install --location=global pnpm
|
npm install --location=global pnpm
|
||||||
git clone https://github.com/overextended/ox_core.git
|
git clone https://github.com/overextended/ox_core.git
|
||||||
cd web
|
cd web
|
||||||
@@ -72,7 +72,7 @@ Phone with many built-in apps such as Twitter, Marketplace, and Notes; with supp
|
|||||||
|
|
||||||
### pefcl
|
### pefcl
|
||||||
|
|
||||||
Banking and financing, with support for multiple, unique, and shared accounts.
|
Banking and financing, with support for multiple, unique, and shared accounts.
|
||||||
If using it with [ox_inventory](https://github.com/overextended/ox_inventory), open `pefcl/config.json` and enable framework integration.
|
If using it with [ox_inventory](https://github.com/overextended/ox_inventory), open `pefcl/config.json` and enable framework integration.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ Triggered when the player's grade in a group is modified on the server with `pla
|
|||||||
RegisterNetEvent('ox:setGroup', function(source, group, grade) end)
|
RegisterNetEvent('ox:setGroup', function(source, group, grade) end)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### ox:licenseAdded
|
### ox:licenseAdded
|
||||||
|
|
||||||
Triggered when the player has been granted a license.
|
Triggered when the player has been granted a license.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Triggered when a player has been granted a license.
|
|||||||
AddEventHandler('ox:licenseAdded', function(source, name) end)
|
AddEventHandler('ox:licenseAdded', function(source, name) end)
|
||||||
```
|
```
|
||||||
|
|
||||||
### ox:licenseAdded
|
### ox:licenseRemoved
|
||||||
|
|
||||||
Triggered when a player's license is revoked.
|
Triggered when a player's license is revoked.
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ player.set(key, value, replicated)
|
|||||||
|
|
||||||
## player.setdb
|
## player.setdb
|
||||||
|
|
||||||
Update the player's metadata and store in the DB, optionally syncing it with the client.
|
Update the player's metadata and store in the DB, optionally syncing it with the client.
|
||||||
Note: These values are not synced to the client on login; you will need to use `player.set`.
|
Note: These values are not synced to the client on login; you will need to use `player.set`.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -77,7 +77,7 @@ Returns the player's current grade for a given group.
|
|||||||
player.getGroup()
|
player.getGroup()
|
||||||
```
|
```
|
||||||
|
|
||||||
## player.getGroup
|
## player.getGroups
|
||||||
|
|
||||||
Returns an object of all groups the player is in, with the current grade as the value.
|
Returns an object of all groups the player is in, with the current grade as the value.
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ player.getGroups()
|
|||||||
|
|
||||||
## player.hasGroup
|
## player.hasGroup
|
||||||
|
|
||||||
Check if the player is a member of a given group, and returns the matching group name and grade.
|
Check if the player is a member of a given group, and returns the matching group name and grade.
|
||||||
The filter can be a string, array, or object where key is the group, and value is the minimum grade.
|
The filter can be a string, array, or object where key is the group, and value is the minimum grade.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -12,4 +12,3 @@ lib.callback.await('ox:getNearbyVehicles', playerId, radius)
|
|||||||
|
|
||||||
- playerId: `number`
|
- playerId: `number`
|
||||||
- radius?: `number`
|
- radius?: `number`
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ end
|
|||||||
|
|
||||||
## Ox.CreateVehicle
|
## Ox.CreateVehicle
|
||||||
|
|
||||||
Spawns a vehicle and returns the instance of CVehicle.
|
Spawns a vehicle and returns the instance of CVehicle.
|
||||||
If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id.
|
If the first argument is a number, it will attempt to spawn a vehicle from the database with a matching id.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -43,8 +43,9 @@ if vehicleId then
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database.
|
If the first argument is a table and the owner property is a number, or nil, the vehicle will be added to the database.
|
||||||
Setting the owner as false creates a non-persistent vehicle.
|
Setting the owner as false creates a non-persistent vehicle.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local vehicle = Ox.CreateVehicle({
|
local vehicle = Ox.CreateVehicle({
|
||||||
model = 'sultanrs',
|
model = 'sultanrs',
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ vehicle.setGroup(group)
|
|||||||
|
|
||||||
## vehicle.setPlate
|
## vehicle.setPlate
|
||||||
|
|
||||||
Sets the vehicle's plate, used in the database to ensure uniqueness. Does not necessarily match the plate property (i.e. fake plates).
|
Sets the vehicle's plate, used in the database to ensure uniqueness. Does not necessarily match the plate property (i.e. fake plates).
|
||||||
Plate is always formatted to 8 characters.
|
Plate is always formatted to 8 characters.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Searches the inventory for an item, or list of items, with the result varying ba
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:Search(search, item, metadata)
|
exports.ox_inventory:Search(search, item, metadata)
|
||||||
```
|
```
|
||||||
|
|
||||||
* search: `'slots'` or `'count'`
|
* search: `'slots'` or `'count'`
|
||||||
* `'slots'` returns a table of slots where the item was found at.
|
* `'slots'` returns a table of slots where the item was found at.
|
||||||
* `'count'` returns the count of the specified item in player's inventory. If searching for multiple items
|
* `'count'` returns the count of the specified item in player's inventory. If searching for multiple items
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ The following snippet can be used in crafting resources such as okokCrafting or
|
|||||||
```lua
|
```lua
|
||||||
local itemNames = {}
|
local itemNames = {}
|
||||||
|
|
||||||
for item, data in pairs(exports.ox_inventory:Items()) do
|
for item, data in pairs(exports.ox_inventory:Items()) do
|
||||||
itemNames[item] = data.label
|
itemNames[item] = data.label
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@@ -10,8 +10,8 @@ Returns whether the player's inventory is currently running an action (i.e. usin
|
|||||||
local isInventoryBusy = LocalPlayer.state.invBusy
|
local isInventoryBusy = LocalPlayer.state.invBusy
|
||||||
|
|
||||||
if isInventoryBusy then
|
if isInventoryBusy then
|
||||||
-- Do stuff when busy
|
-- Do stuff when busy
|
||||||
else
|
else
|
||||||
-- Do stuff when not busy
|
-- Do stuff when not busy
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@@ -10,7 +10,7 @@ Returns whether the player's inventory is currently open or not.
|
|||||||
local isInventoryOpen = LocalPlayer.state.invOpen
|
local isInventoryOpen = LocalPlayer.state.invOpen
|
||||||
|
|
||||||
if isInventoryOpen then
|
if isInventoryOpen then
|
||||||
-- Do stuff when open
|
-- Do stuff when open
|
||||||
else
|
else
|
||||||
-- Do stuff when closed
|
-- Do stuff when closed
|
||||||
end
|
end
|
||||||
@@ -5,4 +5,5 @@ Mostly used for weaponised vehicles, though could be called for "minigames"
|
|||||||
```lua
|
```lua
|
||||||
local exports.ox_inventory:weaponWheel(state)
|
local exports.ox_inventory:weaponWheel(state)
|
||||||
```
|
```
|
||||||
|
|
||||||
* state: `boolean`
|
* state: `boolean`
|
||||||
@@ -3,6 +3,7 @@ Sets a metadata property to display in the tooltip.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:displayMetadata(metadata, value)
|
exports.ox_inventory:displayMetadata(metadata, value)
|
||||||
```
|
```
|
||||||
|
|
||||||
* metadata: `table` or `string`
|
* metadata: `table` or `string`
|
||||||
* If metadata is a string then it's the metadata property you want to display, value is **not** optional then.
|
* If metadata is a string then it's the metadata property you want to display, value is **not** optional then.
|
||||||
* Can be a table of key-value pairs, key being the metadata property and value being the label for that property.
|
* Can be a table of key-value pairs, key being the metadata property and value being the label for that property.
|
||||||
@@ -10,6 +11,7 @@ exports.ox_inventory:displayMetadata(metadata, value)
|
|||||||
* 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')
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Opens an inventory using the passed data.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:openInventory(invType, data)
|
exports.ox_inventory:openInventory(invType, data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* invType: `string`
|
* invType: `string`
|
||||||
* `'player'`
|
* `'player'`
|
||||||
* `'shop'`
|
* `'shop'`
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Forces the secondary-inventory key to open the passed inventory. Can be useful t
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:setStashTarget(id, owner)
|
exports.ox_inventory:setStashTarget(id, owner)
|
||||||
```
|
```
|
||||||
|
|
||||||
* id: `string` or `number`
|
* id: `string` or `number`
|
||||||
* Stash id.
|
* Stash id.
|
||||||
* owner?: `string` or `number`
|
* owner?: `string` or `number`
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
Uses the passed item, then triggers the callback function.
|
Uses the passed item, then triggers the callback function.
|
||||||
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
|
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:useItem(data, cb)
|
exports.ox_inventory:useItem(data, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
* data: `table`
|
* data: `table`
|
||||||
* cb?: `function`
|
* cb?: `function`
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ Uses the item in the given inventory slot.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:useSlot(slot)
|
exports.ox_inventory:useSlot(slot)
|
||||||
```
|
```
|
||||||
|
|
||||||
* slot: `number`
|
* slot: `number`
|
||||||
@@ -24,7 +24,7 @@ By returning `false`, you can cancel the action and revert the inventory state.
|
|||||||
- source: `number`
|
- source: `number`
|
||||||
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
|
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
|
||||||
- fromInventory: `number` or `string`
|
- fromInventory: `number` or `string`
|
||||||
- toInventory:` number` or `string`
|
- toInventory: `number` or `string`
|
||||||
- fromType: `string`
|
- fromType: `string`
|
||||||
- toType: `string`
|
- toType: `string`
|
||||||
- fromSlot: `table`
|
- fromSlot: `table`
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximu
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
- inv: `table` or `string` or `number`
|
- inv: `table` or `string` or `number`
|
||||||
- The inventory's unique id, or a table with the id and owner.
|
- The inventory's unique id, or a table with the id and owner.
|
||||||
- playerId: `1`
|
- playerId: `1`
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Returns the amount a player can hold based on available weight.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CanCarryAmount(inv, item)
|
exports.ox_inventory:CanCarryAmount(inv, item)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* item: `table` or `string`
|
* item: `table` or `string`
|
||||||
* Can be array to check multiple items.
|
* Can be array to check multiple items.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ The function checks for inventory weight and available slots.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* item `table` or `string`
|
* item `table` or `string`
|
||||||
* Can be array of items.
|
* Can be array of items.
|
||||||
@@ -13,6 +14,7 @@ exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
|||||||
* 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
|
||||||
if exports.ox_inventory:CanCarryItem(source, 'water', 3) then
|
if exports.ox_inventory:CanCarryItem(source, 'water', 3) then
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Returns if inventory can carry specified weight and free inventory weight.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CanCarryWeight(inv, weight)
|
exports.ox_inventory:CanCarryWeight(inv, weight)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* weight: `number`
|
* weight: `number`
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Returns true if the item swap is possible based on inventory weight.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
|
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* firstItem: `string`
|
* firstItem: `string`
|
||||||
* firstItemCount: `number`
|
* firstItemCount: `number`
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ Clears the specified inventory. The `keep` argument is either a string or an arr
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:ClearInventory(inv, keep)
|
exports.ox_inventory:ClearInventory(inv, keep)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* keep?: `string` or `string[]`
|
* keep?: `string` or `string[]`
|
||||||
@@ -6,4 +6,5 @@ the player.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:ConfiscateInventory(source)
|
exports.ox_inventory:ConfiscateInventory(source)
|
||||||
```
|
```
|
||||||
|
|
||||||
* source: `number`
|
* source: `number`
|
||||||
@@ -3,11 +3,14 @@ Takes traditional item data and updates it to support ox_inventory.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:ConvertItems(playerId, items)
|
exports.ox_inventory:ConvertItems(playerId, items)
|
||||||
```
|
```
|
||||||
|
|
||||||
* playerId: `number`
|
* playerId: `number`
|
||||||
* items: `table`
|
* items: `table`
|
||||||
|
|
||||||
Data conversion example:
|
Data conversion example:
|
||||||
```
|
|
||||||
Old: [{"cola":1, "bread":3}]
|
```lua
|
||||||
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
|
Old: [{"cola":1, "bread":3}]
|
||||||
|
New: [{"slot":1,"name":"cola","count":1},
|
||||||
|
{"slot":2,"name":"bread","count":3}]
|
||||||
```
|
```
|
||||||
@@ -3,6 +3,7 @@ Drops can be created from other resources, containing a variety of items and uti
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
||||||
```
|
```
|
||||||
|
|
||||||
* prefix: `string`
|
* prefix: `string`
|
||||||
* items: `table`
|
* items: `table`
|
||||||
* name: `string`
|
* name: `string`
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ Returns the player's currently equipped weapon as a table.
|
|||||||
-- inv: string or number
|
-- inv: string or number
|
||||||
exports.ox_inventory:GetCurrentWeapon(inv)
|
exports.ox_inventory:GetCurrentWeapon(inv)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
@@ -3,23 +3,25 @@ Returns the inventory associated with the ID (and owner if defined). Otherwise r
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:GetInventory(inv, owner)
|
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)
|
||||||
print(json.encode(inventory, {indent = true}))
|
print(json.encode(inventory, {indent = true}))
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
"id": "example_stash,
|
"id": "example_stash,
|
||||||
"label": "Police Stash",
|
"label": "Police Stash",
|
||||||
"type": "stash,
|
"type": "stash,
|
||||||
"slots": 50,
|
"slots": 50,
|
||||||
"weight": 0,
|
"weight": 0,
|
||||||
"maxWeight": 100000,
|
"maxWeight": 100000,
|
||||||
"owner": false,
|
"owner": false,
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
```
|
```
|
||||||
@@ -3,10 +3,12 @@ Returns all slots with items in a inventory.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:GetInventoryItems(inv, owner)
|
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)
|
||||||
```
|
```
|
||||||
@@ -3,6 +3,7 @@ Returns the item from the specified inventory.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
|
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* item: `table` or `string`
|
* item: `table` or `string`
|
||||||
* Can be items array.
|
* Can be items array.
|
||||||
@@ -15,6 +16,7 @@ how many times the item was found.
|
|||||||
Otherwise returns the data related to the item _and_ it's total count found in the inventory.
|
Otherwise returns the data related to the item _and_ it's 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)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Returns the number of slots the specified item is in, the item's total count and
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:GetItemSlots(inv, item, metadata)
|
exports.ox_inventory:GetItemSlots(inv, item, metadata)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* item: `table` or `string`
|
* item: `table` or `string`
|
||||||
* metadata?: `table`
|
* metadata?: `table`
|
||||||
@@ -4,24 +4,26 @@ Returns the specified slot data as a table.
|
|||||||
|
|
||||||
exports.ox_inventory:GetSlot(inv, slot)
|
exports.ox_inventory:GetSlot(inv, slot)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `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)
|
||||||
|
|
||||||
print(json.encode(slot, {indent=true}))
|
print(json.encode(slot, {indent=true}))
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
"weight": 2000,
|
"weight": 2000,
|
||||||
"name": "water",
|
"name": "water",
|
||||||
"metadata": [],
|
"metadata": [],
|
||||||
"slot": 1,
|
"slot": 1,
|
||||||
"label": "Water",
|
"label": "Water",
|
||||||
"close": true,
|
"close": true,
|
||||||
"stack": true,
|
"stack": true,
|
||||||
"count: 4
|
"count: 4
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
```
|
```
|
||||||
@@ -3,6 +3,7 @@ Creates a new custom stash.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
|
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
|
||||||
```
|
```
|
||||||
|
|
||||||
* id: `string` or `number`
|
* id: `string` or `number`
|
||||||
* Stash identifier when loading from the database.
|
* Stash identifier when loading from the database.
|
||||||
* label: `string`
|
* label: `string`
|
||||||
@@ -14,9 +15,9 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c
|
|||||||
* `true`: Each player has a unique stash but can request other player's stashes.
|
* `true`: Each player has a unique stash but can request other player's stashes.
|
||||||
* `nil`: Always shared.
|
* `nil`: Always shared.
|
||||||
* groups: `table`
|
* groups: `table`
|
||||||
* Table of player groups (jobs) able to access the stash.
|
* Table of player groups (jobs) able to access the stash.
|
||||||
* Table of group names where the numeric value is the minimum grade required.
|
* Table of group names where the numeric value is the minimum grade required.
|
||||||
* `{['police'] = 0, ['ambulance'] = 2}`
|
* `{['police'] = 0, ['ambulance'] = 2}`
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ Use it alongside [ConfiscateInventory](./ConfiscateInventory.md).
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:ReturnInventory(source)
|
exports.ox_inventory:ReturnInventory(source)
|
||||||
```
|
```
|
||||||
|
|
||||||
* source: `number`
|
* source: `number`
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
Searches an inventory for a specified item.
|
Searches an inventory for a specified item.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|
||||||
exports.ox_inventory:Search(inv, search, item, metadata)
|
exports.ox_inventory:Search(inv, search, item, metadata)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* search: `string`
|
* search: `string`
|
||||||
* item: `table` or `string`
|
* item: `table` or `string`
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ Can be used for repairing weapons.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:SetDurability(inv, slot, durability)
|
exports.ox_inventory:SetDurability(inv, slot, durability)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* slot: `number`
|
* slot: `number`
|
||||||
* durability: `number`
|
* durability: `number`
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local ox_inventory = exports.ox_inventory
|
local ox_inventory = exports.ox_inventory
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ Sets metadata on the specified slot.
|
|||||||
```lua
|
```lua
|
||||||
ox_inventory:SetMetadata(inv, slot, metadata)
|
ox_inventory:SetMetadata(inv, slot, metadata)
|
||||||
```
|
```
|
||||||
|
|
||||||
* inv: `string` or `number`
|
* inv: `string` or `number`
|
||||||
* slot: `number`
|
* slot: `number`
|
||||||
* metadata: `table`
|
* metadata: `table`
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local ox_inventory = exports.ox_inventory
|
local ox_inventory = exports.ox_inventory
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ for k, v in pairs(water) do
|
|||||||
water = v
|
water = v
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
water.metadata.type = 'clean'
|
water.metadata.type = 'clean'
|
||||||
ox_inventory:SetMetadata(source, water.slot, water.metadata)
|
ox_inventory:SetMetadata(source, water.slot, water.metadata)
|
||||||
print(('modified %sx water in slot %s with new metadata'):format(water.count, water.slot))
|
print(('modified %sx water in slot %s with new metadata'):format(water.count, water.slot))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Swaps slots in specified inventories.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
|
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
|
||||||
```
|
```
|
||||||
|
|
||||||
* fromInventory: `any`
|
* fromInventory: `any`
|
||||||
* toInventory: `any`
|
* toInventory: `any`
|
||||||
* slot1: `number`
|
* slot1: `number`
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ 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 = {}
|
||||||
for item, data in pairs(exports.ox_inventory:Items()) do
|
for item, data in pairs(exports.ox_inventory:Items()) do
|
||||||
itemNames[item] = data.label
|
itemNames[item] = data.label
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cb(itemNames)
|
cb(itemNames)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
@@ -3,6 +3,7 @@ Creates and sets the player's inventory.
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:setPlayerInventory(player, data)
|
exports.ox_inventory:setPlayerInventory(player, data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* player: `table`
|
* player: `table`
|
||||||
* source: `number`
|
* source: `number`
|
||||||
* identifier: `string`
|
* identifier: `string`
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Convars **must** be set before starting ox_inventory.
|
|||||||
|
|
||||||
The values below are _defaults_ and should not be explicitly set unless changing the value.
|
The values below are _defaults_ and should not be explicitly set unless changing the value.
|
||||||
|
|
||||||
```yml
|
```yaml
|
||||||
# Activate specific event handlers and functions (supported: ox, esx, qb, nd)
|
# Activate specific event handlers and functions (supported: ox, esx, qb, nd)
|
||||||
setr inventory:framework "esx"
|
setr inventory:framework "esx"
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ The resources listed under here **aren't** necessary for the inventory to work b
|
|||||||
|
|
||||||
### ox_target
|
### ox_target
|
||||||
|
|
||||||
A performant and flexible standalone "third-eye" targeting resource.
|
A performant and flexible standalone "third-eye" targeting resource.
|
||||||
Stashes, shops, and crafting benches will be accessible via zone targets instead of using markers.
|
Stashes, shops, and crafting benches will be accessible via zone targets instead of using markers.
|
||||||
|
|
||||||
<ResourceLinks repo="https://www.github.com/overextended/ox_target" docs="../ox_target"></ResourceLinks>
|
<ResourceLinks repo="https://www.github.com/overextended/ox_target" docs="../ox_target"></ResourceLinks>
|
||||||
@@ -60,8 +60,8 @@ The inventory will handle disabling the phone when the player has no item, and s
|
|||||||
|
|
||||||
### Production Build
|
### Production Build
|
||||||
|
|
||||||
The user interface included with the source code must be compiled.
|
The user interface included with the source code must be compiled.
|
||||||
You can compile it youself by following the [build guide](./Guides/inventory_ui), otherwise download a production build below.
|
You can compile it yourself by following the [build guide](./Guides/inventory_ui), otherwise download a production build below.
|
||||||
|
|
||||||
<ResourceLinks repo="https://github.com/overextended/ox_inventory/releases/latest"></ResourceLinks>
|
<ResourceLinks repo="https://github.com/overextended/ox_inventory/releases/latest"></ResourceLinks>
|
||||||
|
|
||||||
@@ -76,12 +76,12 @@ Integration between your framework and ox_inventory should be relatively simple
|
|||||||
You should first reference the [mysql](https://github.com/overextended/ox_inventory/blob/main/modules/mysql/server.lua) module and setup appropriate table and column names.
|
You should first reference the [mysql](https://github.com/overextended/ox_inventory/blob/main/modules/mysql/server.lua) module and setup appropriate table and column names.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
elseif shared.framework == 'myframework' then
|
elseif shared.framework == 'myframework' then
|
||||||
playerTable = 'characters' -- table storing player / character data
|
playerTable = 'characters' -- table storing player / character data
|
||||||
playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id)
|
playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id)
|
||||||
vehicleTable = 'vehicles' -- table storing owned vehicle data
|
vehicleTable = 'vehicles' -- table storing owned vehicle data
|
||||||
vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id)
|
vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
You will need events and functions to handle licenses, owned vehicles, and job systems; these should be handled in the "bridge" module.
|
You will need events and functions to handle licenses, owned vehicles, and job systems; these should be handled in the "bridge" module.
|
||||||
|
|||||||
@@ -8,16 +8,16 @@ sidebar_position: 1
|
|||||||
|
|
||||||
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.
|
||||||
|
|
||||||
We provide an easy way for you to do this by downloading a pre-bundled release, which you can get from [here](https://github.com/overextended/ox_inventory/releases/latest).
|
We provide an easy way for you to do this by downloading a pre-bundled release, which you can get from [here](https://github.com/overextended/ox_inventory/releases/latest).
|
||||||
Make sure you download the `ox_inventory.zip` file as that one contains the bundled files and others are raw source code.
|
Make sure you download the `ox_inventory.zip` file as that one contains the bundled files and others are raw source code.
|
||||||
|
|
||||||
If in case you wanted to edit the inventory UI you would have to build these files yourself.
|
If in case you wanted to edit the inventory UI you would have to build these files yourself.
|
||||||
To do so please read our [_Building inventory UI_](../Guides/inventory_ui.md) guide.
|
To do so please read our [_Building inventory UI_](../Guides/inventory_ui.md) guide.
|
||||||
|
|
||||||
## Stashes / trunks are not saved at server restart
|
## Stashes / trunks are not saved at server restart
|
||||||
|
|
||||||
The only supported way of doing a restart is **txAdmin scheduled restart**.
|
The only supported way of doing a restart is **txAdmin scheduled restart**.
|
||||||
txAdmin scheduled restart should be your only way of restarting a server in production.
|
txAdmin scheduled restart should be your only way of restarting a server in production.
|
||||||
|
|
||||||
If you need to do a manual restart, you must use `/saveinv` before restarting the server.
|
If you need to do a manual restart, you must use `/saveinv` before restarting the server.
|
||||||
If you don't do this, all inventory except players inventory will not be saved.
|
If you don't do this, all inventory except players inventory will not be saved.
|
||||||
@@ -8,37 +8,37 @@ Crafting locations, items and their ingredients are defined in [data/crafting.lu
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
items = {
|
items = {
|
||||||
{
|
{
|
||||||
name = 'lockpick',
|
name = 'lockpick',
|
||||||
ingredients = {
|
ingredients = {
|
||||||
garbage = 3,
|
garbage = 3,
|
||||||
WEAPON_HAMMER = 0.1
|
WEAPON_HAMMER = 0.1
|
||||||
},
|
},
|
||||||
duration = 5000,
|
duration = 5000,
|
||||||
count = 3,
|
count = 3,
|
||||||
metadata = { durability = 20 }
|
metadata = { durability = 20 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'garbage',
|
||||||
|
ingredients = {
|
||||||
|
cola = 1
|
||||||
|
},
|
||||||
|
metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' }
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
points = {
|
||||||
name = 'garbage',
|
vec3(-1147.083008, -2002.662109, 13.180260),
|
||||||
ingredients = {
|
},
|
||||||
cola = 1
|
zones = {
|
||||||
},
|
{
|
||||||
metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' }
|
coords = vec3(-1146.2, -2002.05, 13.2),
|
||||||
|
size = vec3(3.8, 1.05, 0.15),
|
||||||
|
distance = 1.5,
|
||||||
|
rotation = 315.0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
blip = { id = 566, colour = 31, scale = 0.8 },
|
||||||
points = {
|
|
||||||
vec3(-1147.083008, -2002.662109, 13.180260),
|
|
||||||
},
|
|
||||||
zones = {
|
|
||||||
{
|
|
||||||
coords = vec3(-1146.2, -2002.05, 13.2),
|
|
||||||
size = vec3(3.8, 1.05, 0.15),
|
|
||||||
distance = 1.5,
|
|
||||||
rotation = 315.0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
blip = { id = 566, colour = 31, scale = 0.8 },
|
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -51,9 +51,9 @@ Crafting locations, items and their ingredients are defined in [data/crafting.lu
|
|||||||
* value - If 1 or above it's the consume count, if below 1 and above 0 it's the durability consume amount, if
|
* value - If 1 or above it's the consume count, if below 1 and above 0 it's the durability consume amount, if
|
||||||
set to 0 then the item is required but not consumed.
|
set to 0 then the item is required but not consumed.
|
||||||
* duration: `number`
|
* duration: `number`
|
||||||
* Crafting duration in miliseconds.
|
* Crafting duration in milliseconds.
|
||||||
* count: `number`
|
* count: `number`
|
||||||
* Item amount recieved upon crafting.
|
* Item amount received upon crafting.
|
||||||
* metadata: `table`
|
* metadata: `table`
|
||||||
* Metadata applied to the item being crafted.
|
* Metadata applied to the item being crafted.
|
||||||
* points: `vector3[]`
|
* points: `vector3[]`
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ options for the item.
|
|||||||
* status?: `table`
|
* status?: `table`
|
||||||
* Adjust esx_status values after use.
|
* Adjust esx_status values after use.
|
||||||
* anim?: `table`
|
* anim?: `table`
|
||||||
* Animation that will be played during the progress bar.
|
* Animation that will be played during the progress bar.
|
||||||
* dict: `string`
|
* dict: `string`
|
||||||
* clip: `string`
|
* clip: `string`
|
||||||
* prop?: `table`
|
* prop?: `table`
|
||||||
* Attached prop that will be displayed during the progress bar.
|
* Attached prop that will be displayed during the progress bar.
|
||||||
* model: `string` or `hash`
|
* model: `string` or `hash`
|
||||||
* pos: `table` (x, y, z)
|
* pos: `table` (x, y, z)
|
||||||
* rot: `table` (x, y, z)
|
* rot: `table` (x, y, z)
|
||||||
* disable?: `table`
|
* disable?: `table`
|
||||||
* Actions to be disabled during the progress bar
|
* Actions to be disabled during the progress bar
|
||||||
* move?: `boolean`
|
* move?: `boolean`
|
||||||
@@ -57,11 +57,11 @@ options for the item.
|
|||||||
* cancel?: `boolean`
|
* cancel?: `boolean`
|
||||||
* If set to true the player canc cancel item use.
|
* If set to true the player canc cancel item use.
|
||||||
* add?: `function`(total: `number`)
|
* add?: `function`(total: `number`)
|
||||||
* Function that triggers when recieving an item
|
* Function that triggers when receiving an item
|
||||||
* Returns total item count as `total`
|
* Returns total item count as `total`
|
||||||
* remove?: `function`(total: `number`)
|
* remove?: `function`(total: `number`)
|
||||||
* Function that triggers when removing an item
|
* Function that triggers when removing an item
|
||||||
* Returns total item count as `total`
|
* Returns total item count as `total`
|
||||||
* buttons?: `table`
|
* buttons?: `table`
|
||||||
* label: `string`
|
* label: `string`
|
||||||
* action: `function`(slot: `number`)
|
* action: `function`(slot: `number`)
|
||||||
@@ -147,8 +147,8 @@ A modified burger item, which gives you notifications on add and remove argument
|
|||||||
|
|
||||||
## Making the item usable
|
## Making the item usable
|
||||||
|
|
||||||
- If you are using ESX, you can continue using `ESX.RegisterUsableItem`.
|
* If you are using ESX, you can continue using `ESX.RegisterUsableItem`.
|
||||||
- If you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`.
|
* If you are using QBCore, you can continue using `QBCore.Functions.CreateUseableItem`.
|
||||||
|
|
||||||
Using the built-in system is more secure and provides much more functionality.
|
Using the built-in system is more secure and provides much more functionality.
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
title: Guides
|
title: Guides
|
||||||
---
|
---
|
||||||
|
|
||||||
Providing examples and explaining certain inventory API into more detail.
|
Providing examples and explaining certain inventory API into more detail.
|
||||||
If you have trouble understanding how some of the API works check out our [**_example resource_**](https://github.com/overextended/ox_inventory_examples).
|
If you have trouble understanding how some of the API works check out our [**_example resource_**](https://github.com/overextended/ox_inventory_examples).
|
||||||
@@ -72,10 +72,12 @@ Targets and model are only available when using a targeting resource like ox_tar
|
|||||||
## Register during runtime
|
## Register during runtime
|
||||||
|
|
||||||
Shops can be added using `exports.ox_inventory:RegisterShop` on the server, however they cannot utilise any client-only features.
|
Shops can be added using `exports.ox_inventory:RegisterShop` on the server, however they cannot utilise any client-only features.
|
||||||
|
|
||||||
- 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', {
|
||||||
name = 'Test shop',
|
name = 'Test shop',
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ Firstly, we need to define the stashes properties.
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
Below the value is hardset, but it could be loaded from the database (especially if there are unknown fields, i.e. owner)
|
Below the value is hardset, but it could be loaded from the database (especially if there are unknown fields, i.e. owner)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Server
|
-- Server
|
||||||
local stash = {
|
local stash = {
|
||||||
@@ -55,6 +56,7 @@ exports.ox_inventory:openInventory('stash', {id='42wallabyway', owner=property.o
|
|||||||
```
|
```
|
||||||
|
|
||||||
The following sample is based on esx_property's db data.
|
The following sample is based on esx_property's db data.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Server
|
-- Server
|
||||||
local properties
|
local properties
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
|
Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
|
||||||
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
|
Refer to [Basic Aces & Principals overview/guide](https://forum.cfx.re/t/basic-aces-principals-overview-guide/90917) for more information.
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
|
||||||
### lib.addAce
|
### lib.addAce
|
||||||
|
|
||||||
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -16,6 +16,7 @@ lib.addAce(principal, ace, allow)
|
|||||||
|
|
||||||
lib.addAce('group.admin', 'command.say')
|
lib.addAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -26,25 +27,27 @@ lib.addAce(principal, ace, allow)
|
|||||||
|
|
||||||
lib.addAce('group.admin', 'command.say')
|
lib.addAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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 false sets the permission to 'deny'.
|
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.removeAce(principal, ace, allow)
|
lib.removeAce(principal, ace, allow)
|
||||||
|
|
||||||
lib.removeAce('group.admin', 'command.say')
|
lib.removeAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -55,14 +58,16 @@ lib.removeAce(principal, ace, allow)
|
|||||||
|
|
||||||
lib.removeAce('group.admin', 'command.say')
|
lib.removeAce('group.admin', 'command.say')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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>
|
<Tabs>
|
||||||
@@ -73,6 +78,7 @@ lib.addPrincipal(child, parent)
|
|||||||
|
|
||||||
lib.addPrincipal('player.1', 'group.moderator')
|
lib.addPrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -83,14 +89,15 @@ lib.addPrincipal(child, parent)
|
|||||||
|
|
||||||
lib.addPrincipal('player.1', 'group.moderator')
|
lib.addPrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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>
|
<Tabs>
|
||||||
@@ -101,6 +108,7 @@ lib.removePrincipal(child, parent)
|
|||||||
|
|
||||||
lib.removePrincipal('player.1', 'group.moderator')
|
lib.removePrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -111,9 +119,9 @@ lib.removePrincipal(child, parent)
|
|||||||
|
|
||||||
lib.removePrincipal('player.1', 'group.moderator')
|
lib.removePrincipal('player.1', 'group.moderator')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* child: `string`
|
* child: `string`
|
||||||
* parent: `string`
|
* parent: `string`
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
```lua
|
```lua
|
||||||
lib.addCommand(principal, command, callback, parameters, help)
|
lib.addCommand(principal, command, callback, parameters, help)
|
||||||
```
|
```
|
||||||
|
|
||||||
* principal: `string` or `string[]` or `false`
|
* principal: `string` or `string[]` or `false`
|
||||||
* command: `string`
|
* command: `string`
|
||||||
* callback: `function`
|
* callback: `function`
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
```lua
|
```lua
|
||||||
lib.addKeybind(data)
|
lib.addKeybind(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* data: `table`
|
* data: `table`
|
||||||
* name: `string`
|
* name: `string`
|
||||||
* description: `string`
|
* description: `string`
|
||||||
@@ -27,7 +28,8 @@ local keybind = lib.addKeybind({
|
|||||||
```
|
```
|
||||||
|
|
||||||
Keybinds can be enabled/disabled by using the disable method.
|
Keybinds can be enabled/disabled by using the disable method.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
keybind:disable(true) -- disable
|
keybind:disable(true) -- disable
|
||||||
keybind:disable(false) -- enable
|
keybind:disable(false) -- enable
|
||||||
```
|
```
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Caches data related to the player and handling some events or statebags.
|
Caches data related to the player and handling some events or statebags.
|
||||||
An interval runs every 100ms to update data that cannot be checked via handlers.
|
An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||||
|
|
||||||
## States
|
## States
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ lib.callback.register(name, cb)
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
||||||
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
||||||
return nearbyVehicles
|
return nearbyVehicles
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
### lib.disableControls
|
### lib.disableControls
|
||||||
|
|
||||||
Call on frame to disable all stored keys.
|
Call on frame to disable all stored keys.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.disableControls()
|
lib.disableControls()
|
||||||
```
|
```
|
||||||
|
|
||||||
### lib.disableControls:Add
|
### lib.disableControls:Add
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.disableControls:Add(...)
|
lib.disableControls:Add(...)
|
||||||
```
|
```
|
||||||
|
|
||||||
* vararg: `number`
|
* vararg: `number`
|
||||||
|
|
||||||
### lib.disableControls:Remove
|
### lib.disableControls:Remove
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.disableControls:Remove(...)
|
lib.disableControls:Remove(...)
|
||||||
```
|
```
|
||||||
|
|
||||||
* vararg: `number`
|
* vararg: `number`
|
||||||
|
|
||||||
### lib.disableControls:Clear
|
### lib.disableControls:Clear
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.disableControls:Clear(...)
|
lib.disableControls:Clear(...)
|
||||||
```
|
```
|
||||||
|
|
||||||
* vararg: `number`
|
* vararg: `number`
|
||||||
@@ -5,6 +5,7 @@ Get the id, ped, and coords of the closest player to a set of coordinates.
|
|||||||
```lua
|
```lua
|
||||||
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
||||||
```
|
```
|
||||||
|
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* The coords to check from.
|
* The coords to check from.
|
||||||
* maxDistance: `number`
|
* maxDistance: `number`
|
||||||
@@ -13,6 +14,7 @@ function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
|||||||
* Whether or not to include the current player.
|
* Whether or not to include the current player.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
|
|
||||||
* playerId?: `number`
|
* playerId?: `number`
|
||||||
* playerPed?: `number`
|
* playerPed?: `number`
|
||||||
* playerCoords?: `vector3`
|
* playerCoords?: `vector3`
|
||||||
@@ -14,5 +14,6 @@ function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end
|
|||||||
* Whether or not to include the player's current vehicle.
|
* Whether or not to include the player's current vehicle.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
|
|
||||||
* vehicle?: `number`
|
* vehicle?: `number`
|
||||||
* vehicleCoords?: `vector3`
|
* vehicleCoords?: `vector3`
|
||||||
@@ -5,6 +5,7 @@ Get the id, ped, and coords of all players within range of a set of coordinates.
|
|||||||
```lua
|
```lua
|
||||||
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
||||||
```
|
```
|
||||||
|
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* The coords to check from.
|
* The coords to check from.
|
||||||
* maxDistance: `number`
|
* maxDistance: `number`
|
||||||
@@ -13,4 +14,5 @@ function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
|||||||
* Whether or not to include the current player.
|
* Whether or not to include the current player.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
|
|
||||||
* `number[]`
|
* `number[]`
|
||||||
@@ -5,6 +5,7 @@ Get the id and coords of all vehicles within range of a set of coordinates.
|
|||||||
```lua
|
```lua
|
||||||
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
||||||
```
|
```
|
||||||
|
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* The coords to check from.
|
* The coords to check from.
|
||||||
* maxDistance: `number`
|
* maxDistance: `number`
|
||||||
@@ -13,4 +14,5 @@ function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
|||||||
* Whether or not to include the player's current vehicle.
|
* Whether or not to include the player's current vehicle.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
|
|
||||||
* `number[]`
|
* `number[]`
|
||||||
@@ -5,7 +5,7 @@ title: Alert Dialog
|
|||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Simple alert dialog that can display a message to the player.
|
Simple alert dialog that can display a message to the player.
|
||||||
Returns whether the player pressed the confirm button or canceled the dialog.
|
Returns whether the player pressed the confirm button or canceled the dialog.
|
||||||
|
|
||||||
### lib.alertDialog
|
### lib.alertDialog
|
||||||
@@ -16,6 +16,7 @@ Returns whether the player pressed the confirm button or canceled the dialog.
|
|||||||
```lua
|
```lua
|
||||||
lib.alertDialog(data)
|
lib.alertDialog(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.alertDialog(data)
|
lib.alertDialog(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ Force closes the active alert dialog and sets its return data as `nil`
|
|||||||
```lua
|
```lua
|
||||||
lib.closeAlertDialog()
|
lib.closeAlertDialog()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -62,6 +65,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.closeAlertDialog()
|
lib.closeAlertDialog()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -80,6 +84,7 @@ local alert = lib.alertDialog({
|
|||||||
|
|
||||||
print(alert)
|
print(alert)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -95,9 +100,8 @@ const alert = await lib.alertDialog({
|
|||||||
|
|
||||||
console.log(alert)
|
console.log(alert)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
@@ -15,6 +15,7 @@ Sets the player's clipboard to the specified string value.
|
|||||||
```lua
|
```lua
|
||||||
lib.setClipboard(value)
|
lib.setClipboard(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.setClipboard(value)
|
lib.setClipboard(value)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
|
|||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
### lib.registerContext
|
### lib.registerContext
|
||||||
|
|
||||||
Used for registering a context menu.
|
Used for registering a context menu.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -14,6 +15,7 @@ Used for registering a context menu.
|
|||||||
```lua
|
```lua
|
||||||
lib.registerContext(context)
|
lib.registerContext(context)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.registerContext(context)
|
lib.registerContext(context)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ lib.registerContext(context)
|
|||||||
* progress?: `number`
|
* progress?: `number`
|
||||||
* Adds a progress bar filled to this percentage
|
* Adds a progress bar filled to this percentage
|
||||||
* colorScheme?: `string`
|
* colorScheme?: `string`
|
||||||
* Sets the color scheme of the progress bar. Current options available are:
|
* Sets the color scheme of the progress bar. Current options available are:
|
||||||
* `whiteAlpha`, `blackAlpha`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `cyan`, `purple`, `pink`
|
* `whiteAlpha`, `blackAlpha`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `cyan`, `purple`, `pink`
|
||||||
* arrow?: `boolean`
|
* arrow?: `boolean`
|
||||||
* Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it.
|
* Shows an arrow on the right side like `menu` does, useful when you are opening a menu from an event. Can be set to false to hide it.
|
||||||
@@ -74,12 +77,13 @@ lib.registerContext(context)
|
|||||||
You can register as many context menus in one `lib.registerContext` function
|
You can register as many context menus in one `lib.registerContext` function
|
||||||
as you'd like.
|
as you'd like.
|
||||||
|
|
||||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
The menu can be either in the order you write it in, or sorted alphabetically.
|
||||||
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys,
|
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys,
|
||||||
otherwise not using keys and instead using tables will make the menu be in the order you
|
otherwise not using keys and instead using tables will make the menu be in the order you
|
||||||
define it as.
|
define it as.
|
||||||
|
|
||||||
### lib.showContext
|
### lib.showContext
|
||||||
|
|
||||||
Opens a registered context menu by it's id.
|
Opens a registered context menu by it's id.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -88,6 +92,7 @@ Opens a registered context menu by it's id.
|
|||||||
```lua
|
```lua
|
||||||
lib.showContext(id)
|
lib.showContext(id)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -96,12 +101,14 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.showContext(id)
|
lib.showContext(id)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* id: `string`
|
* id: `string`
|
||||||
|
|
||||||
### lib.hideContext
|
### lib.hideContext
|
||||||
|
|
||||||
Hides any currently visible context menu.
|
Hides any currently visible context menu.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -110,6 +117,7 @@ Hides any currently visible context menu.
|
|||||||
```lua
|
```lua
|
||||||
lib.hideContext(onExit)
|
lib.hideContext(onExit)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -118,6 +126,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.hideContext(onExit)
|
lib.hideContext(onExit)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -136,6 +145,7 @@ If no context menu is open returns `nil`.
|
|||||||
```lua
|
```lua
|
||||||
lib.getOpenContextMenu()
|
lib.getOpenContextMenu()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -144,10 +154,12 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.getOpenContextMenu()
|
lib.getOpenContextMenu()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
@@ -204,9 +216,10 @@ lib.registerContext({
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
RegisterCommand('testcontext', function()
|
RegisterCommand('testcontext', function()
|
||||||
lib.showContext('example_menu')
|
lib.showContext('example_menu')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -266,10 +279,10 @@ RegisterCommand('testcontext', () => {
|
|||||||
lib.showContext('example_menu')
|
lib.showContext('example_menu')
|
||||||
}, false)
|
}, false)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
To trigger the event from the `Event button` and get it's data we first
|
To trigger the event from the `Event button` and get it's data we first
|
||||||
need to register the event properly:
|
need to register the event properly:
|
||||||
|
|
||||||
@@ -296,6 +309,7 @@ RegisterNetEvent('some_event', function(data)
|
|||||||
lib.showContext('another_context_menu')
|
lib.showContext('another_context_menu')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -319,6 +333,7 @@ onNet('some_event', () => {
|
|||||||
lib.showContext('another_context_menu');
|
lib.showContext('another_context_menu');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -327,8 +342,7 @@ the event you register, in this case that argument is called `data`.
|
|||||||
|
|
||||||
Using this event we also register a new context menu with it's own options.
|
Using this event we also register a new context menu with it's own options.
|
||||||
|
|
||||||
|
By defining a `menu` param to be the id of the first menu we can get the
|
||||||
By defining a `menu` param to be the id of the first menu we can get the
|
|
||||||
neat back arrow button next to the menu title that will take us back.
|
neat back arrow button next to the menu title that will take us back.
|
||||||
|
|
||||||
If we have a button that does not define either event, serverEvent or menu
|
If we have a button that does not define either event, serverEvent or menu
|
||||||
@@ -337,7 +351,7 @@ the button will do nothing upon being clicked.
|
|||||||
Of course just registering the event won't do much so we need to display it
|
Of course just registering the event won't do much so we need to display it
|
||||||
with the `lib.showContext` function, passing in the menu's id.
|
with the `lib.showContext` function, passing in the menu's id.
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
@@ -16,6 +16,7 @@ by setting input fields.
|
|||||||
```lua
|
```lua
|
||||||
lib.inputDialog(heading, rows)
|
lib.inputDialog(heading, rows)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.inputDialog(heading, rows)
|
lib.inputDialog(heading, rows)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ number data type, you can use set the `type` to `number`.
|
|||||||
|
|
||||||
If a user left an input field empty it will return `nil`.
|
If a user left an input field empty it will return `nil`.
|
||||||
|
|
||||||
You can also add checkboxes that will return `true` if checked and `nil` if unchecked.
|
You can also add checkboxes that will return `true` if checked and `nil` if unchecked.
|
||||||
Look at the *Advanced* example for it's usage.
|
Look at the *Advanced* example for it's usage.
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
@@ -78,7 +80,6 @@ Look at the *Advanced* example for it's usage.
|
|||||||
When using the advanced method you can define `icon` and `password` **ONLY** with type `'input'` and `'number'` and
|
When using the advanced method you can define `icon` and `password` **ONLY** with type `'input'` and `'number'` and
|
||||||
you can define `options` **ONLY** with type `'select'`.
|
you can define `options` **ONLY** with type `'select'`.
|
||||||
|
|
||||||
|
|
||||||
Doing so otherwise ***will*** result in errors.
|
Doing so otherwise ***will*** result in errors.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@@ -92,6 +93,7 @@ Force closes the active input dialog and sets its return data as `nil`
|
|||||||
```lua
|
```lua
|
||||||
lib.closeInputDialog()
|
lib.closeInputDialog()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -100,6 +102,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.closeInputDialog()
|
lib.closeInputDialog()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -119,6 +122,7 @@ local lockerPasscode = input[2]
|
|||||||
|
|
||||||
print(lockerNumber, lockerPasscode)
|
print(lockerNumber, lockerPasscode)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -127,7 +131,6 @@ print(lockerNumber, lockerPasscode)
|
|||||||
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`.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
const input = await lib.inputDialog('Police locker', ['Locker number', 'Locker passcode'])
|
const input = await lib.inputDialog('Police locker', ['Locker number', 'Locker passcode'])
|
||||||
|
|
||||||
@@ -137,6 +140,7 @@ const lockerPasscode = input[1] as number
|
|||||||
|
|
||||||
console.log(lockerNumber, lockerPasscode)
|
console.log(lockerNumber, lockerPasscode)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -149,19 +153,21 @@ console.log(lockerNumber, lockerPasscode)
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
local input = lib.inputDialog('Police locker', {
|
local input = lib.inputDialog('Police locker', {
|
||||||
{ type = "input", label = "Locker number", placeholder = "123" },
|
{ type = "input", label = "Locker number", placeholder = "123" },
|
||||||
{ type = "checkbox", label = "Some checkbox" },
|
{ type = "checkbox", label = "Some checkbox" },
|
||||||
{ type = "input", label = "Locker PIN", password = true, icon = 'lock' },
|
{ type = "input", label = "Locker PIN", password = true, icon = 'lock' },
|
||||||
{ type = "checkbox", label = "Some other checkbox", checked = true },
|
{ type = "checkbox", label = "Some other checkbox", checked = true },
|
||||||
{ type = 'select', label = 'Value select', options = {
|
{ type = 'select', label = 'Value select', options = {
|
||||||
{ value = 'option1', label = 'Option 1' },
|
{ value = 'option1', label = 'Option 1' },
|
||||||
{ value = 'option2', label = 'Option 2' },
|
{ value = 'option2', label = 'Option 2' },
|
||||||
{ value = 'option3', label = 'Option 3'},
|
{ value = 'option3', label = 'Option 3'},
|
||||||
}},
|
}},
|
||||||
{ type = "number", label = "Number counter", default = 12 }
|
{ type = "number", label = "Number counter", default = 12 }
|
||||||
})
|
})
|
||||||
|
|
||||||
print(json.encode(input, {indent=true}))
|
print(json.encode(input, {indent=true}))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="JS/TS">
|
<TabItem value="JS/TS">
|
||||||
|
|
||||||
@@ -185,7 +191,8 @@ const input = await lib.inputDialog('Police locker', [
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
console.log(JSON.stringify(input, null, 2));
|
console.log(JSON.stringify(input, null, 2));
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
Keyboard navigation menu with specific event functions.
|
Keyboard navigation menu with specific event functions.
|
||||||
|
|
||||||
### lib.registerMenu
|
### lib.registerMenu
|
||||||
|
|
||||||
Registers and caches a menu under the specified id.
|
Registers and caches a menu under the specified id.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -16,6 +17,7 @@ Registers and caches a menu under the specified id.
|
|||||||
```lua
|
```lua
|
||||||
lib.registerMenu(data, cb)
|
lib.registerMenu(data, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.registerMenu(data, cb)
|
lib.registerMenu(data, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -37,7 +40,7 @@ lib.registerMenu(data, cb)
|
|||||||
* icon?: `string`
|
* icon?: `string`
|
||||||
* iconColor?: `string`
|
* iconColor?: `string`
|
||||||
* values?: `table` (`Array<string | {label: string; description: string}>`)
|
* values?: `table` (`Array<string | {label: string; description: string}>`)
|
||||||
* If provided creates a side scrollabel list.
|
* If provided creates a side scrollable list.
|
||||||
* When using object and setting description, the set description will be displayed in the menu tooltip.
|
* When using object and setting description, the set description will be displayed in the menu tooltip.
|
||||||
* checked?: `boolean`
|
* checked?: `boolean`
|
||||||
* Setting either true or false will make the button a checkbox, if `values` is also provided the button will be a
|
* Setting either true or false will make the button a checkbox, if `values` is also provided the button will be a
|
||||||
@@ -61,7 +64,7 @@ lib.registerMenu(data, cb)
|
|||||||
* onClose: `function`(keyPressed?: `'Escape' | 'Backspace'`)
|
* onClose: `function`(keyPressed?: `'Escape' | 'Backspace'`)
|
||||||
* Function that runs when the menu is exited via ESC/Backspace.
|
* Function that runs when the menu is exited via ESC/Backspace.
|
||||||
* onSelected: `function`(selected: `number`, secondary: `number` | `boolean`, args: {[key: `string`]: `any`})
|
* onSelected: `function`(selected: `number`, secondary: `number` | `boolean`, args: {[key: `string`]: `any`})
|
||||||
* Function being ran when the selected button in the menu changes.
|
* Function being ran when the selected button in the menu changes.
|
||||||
* onSideScroll: `function`(selected: `number`, scrollIndex: `number`, args: {[key: `string`]: `any`})
|
* onSideScroll: `function`(selected: `number`, scrollIndex: `number`, args: {[key: `string`]: `any`})
|
||||||
* Function ran whenever a scroll list item is changed.
|
* Function ran whenever a scroll list item is changed.
|
||||||
* onCheck: `function`(selected: `number`, checked: `boolean`, args: {[key: `string`]: `any`})
|
* onCheck: `function`(selected: `number`, checked: `boolean`, args: {[key: `string`]: `any`})
|
||||||
@@ -69,8 +72,8 @@ lib.registerMenu(data, cb)
|
|||||||
* 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>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
@@ -78,6 +81,7 @@ Displays the menu with the provided id.
|
|||||||
```lua
|
```lua
|
||||||
lib.showMenu(id)
|
lib.showMenu(id)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -86,13 +90,12 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.showMenu(id)
|
lib.showMenu(id)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* id: `string`
|
* id: `string`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### lib.hideMenu
|
### lib.hideMenu
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -101,6 +104,7 @@ lib.showMenu(id)
|
|||||||
```lua
|
```lua
|
||||||
lib.hideMenu(onExit)
|
lib.hideMenu(onExit)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -109,6 +113,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.hideMenu(onExit)
|
lib.hideMenu(onExit)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -116,6 +121,7 @@ lib.hideMenu(onExit)
|
|||||||
* 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>
|
<Tabs>
|
||||||
@@ -124,6 +130,7 @@ Returns the id of the currently open menu.
|
|||||||
```lua
|
```lua
|
||||||
lib.getOpenMenu()
|
lib.getOpenMenu()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -132,10 +139,10 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.getOpenMenu()
|
lib.getOpenMenu()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
### lib.setMenuOptions
|
### lib.setMenuOptions
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -144,6 +151,7 @@ lib.getOpenMenu()
|
|||||||
```lua
|
```lua
|
||||||
lib.setMenuOptions(id, options, index)
|
lib.setMenuOptions(id, options, index)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -152,6 +160,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.setMenuOptions(id, options, index)
|
lib.setMenuOptions(id, options, index)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -170,6 +179,7 @@ Replaces the 3rd index option of the specified menu
|
|||||||
```lua
|
```lua
|
||||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -178,17 +188,18 @@ 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)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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.
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
|
|
||||||
@@ -240,6 +251,7 @@ RegisterCommand('testmenu', function()
|
|||||||
lib.showMenu('some_menu_id')
|
lib.showMenu('some_menu_id')
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -293,6 +305,7 @@ RegisterCommand('testmenu', () => {
|
|||||||
lib.showMenu('some_menu_id')
|
lib.showMenu('some_menu_id')
|
||||||
}, false)
|
}, false)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
|
|||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
## lib.notify
|
## lib.notify
|
||||||
|
|
||||||
Custom notifications with a lot of styling options.
|
Custom notifications with a lot of styling options.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -14,6 +15,7 @@ Custom notifications with a lot of styling options.
|
|||||||
```lua
|
```lua
|
||||||
lib.notify(data)
|
lib.notify(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.notify(data)
|
lib.notify(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -44,7 +47,7 @@ lib.notify(data)
|
|||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
|
|
||||||
### Standard
|
#### Standard
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
@@ -56,6 +59,7 @@ lib.notify({
|
|||||||
type = 'success'
|
type = 'success'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -68,12 +72,13 @@ lib.notify({
|
|||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Custom
|
#### Custom
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
@@ -92,6 +97,7 @@ lib.notify({
|
|||||||
iconColor = '#C53030'
|
iconColor = '#C53030'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -111,13 +117,14 @@ lib.notify({
|
|||||||
iconColor: '#C53030'
|
iconColor: '#C53030'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## lib.defaultNotify
|
## lib.defaultNotify
|
||||||
|
|
||||||
Default notifications provided by Chakra UI.
|
Default notifications provided by Chakra UI.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -126,6 +133,7 @@ Default notifications provided by Chakra UI.
|
|||||||
```lua
|
```lua
|
||||||
lib.defaultNotify(data)
|
lib.defaultNotify(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -134,17 +142,17 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.defaultNotify(data)
|
lib.defaultNotify(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* id?: `number`
|
* id?: `number`
|
||||||
* Same as id in `lib.notify`
|
* Same as id in `lib.notify`
|
||||||
* title?: `string`
|
* title?: `string`
|
||||||
* description?: `string`
|
* description?: `string`
|
||||||
* duration?: `number`
|
* duration?: `number`
|
||||||
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
|
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
|
||||||
* status?: `'info'` or `'warning'` or `'success'` or `'error'`
|
* status?: `'info'` or `'warning'` or `'success'` or `'error'`
|
||||||
|
|
||||||
|
|
||||||
### Usage Example
|
### Usage Example
|
||||||
|
|
||||||
@@ -158,6 +166,7 @@ lib.defaultNotify({
|
|||||||
status = 'success'
|
status = 'success'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -170,6 +179,7 @@ lib.defaultNotify({
|
|||||||
status: 'success'
|
status: 'success'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
|
|||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
## lib.progressBar
|
## lib.progressBar
|
||||||
|
|
||||||
Displays a running progress bar.
|
Displays a running progress bar.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -14,6 +15,7 @@ Displays a running progress bar.
|
|||||||
```lua
|
```lua
|
||||||
lib.progressBar(data)
|
lib.progressBar(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.progressBar(data)
|
lib.progressBar(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -88,15 +91,16 @@ if lib.progressBar({
|
|||||||
},
|
},
|
||||||
anim = {
|
anim = {
|
||||||
dict = 'mp_player_intdrink',
|
dict = 'mp_player_intdrink',
|
||||||
clip = 'loop_bottle'
|
clip = 'loop_bottle'
|
||||||
},
|
},
|
||||||
prop = {
|
prop = {
|
||||||
model = `prop_ld_flow_bottle`,
|
model = `prop_ld_flow_bottle`,
|
||||||
pos = vec3(0.03, 0.03, 0.02),
|
pos = vec3(0.03, 0.03, 0.02),
|
||||||
rot = vec3(0.0, 0.0, -1.5)
|
rot = vec3(0.0, 0.0, -1.5)
|
||||||
},
|
},
|
||||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -117,22 +121,24 @@ if (await lib.progressBar({
|
|||||||
},
|
},
|
||||||
anim: {
|
anim: {
|
||||||
dict: 'mp_player_intdrink',
|
dict: 'mp_player_intdrink',
|
||||||
clip: 'loop_bottle'
|
clip: 'loop_bottle'
|
||||||
},
|
},
|
||||||
prop: {
|
prop: {
|
||||||
model: `prop_ld_flow_bottle`,
|
model: `prop_ld_flow_bottle`,
|
||||||
pos: {x: 0.03, y: 0.03, z: 0.02},
|
pos: {x: 0.03, y: 0.03, z: 0.02},
|
||||||
rot: {x: 0.0, y: 0.0, z: -1.5}
|
rot: {x: 0.0, y: 0.0, z: -1.5}
|
||||||
},
|
},
|
||||||
})) 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')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## lib.progressCircle
|
## lib.progressCircle
|
||||||
|
|
||||||
Similar to `lib.progressBar` except it displays a circle and you can define a position.
|
Similar to `lib.progressBar` except it displays a circle and you can define a position.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -141,6 +147,7 @@ Similar to `lib.progressBar` except it displays a circle and you can define a po
|
|||||||
```lua
|
```lua
|
||||||
lib.progressCircle(data)
|
lib.progressCircle(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -149,6 +156,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.progressCircle(data)
|
lib.progressCircle(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -217,15 +225,16 @@ if lib.progressCircle({
|
|||||||
},
|
},
|
||||||
anim = {
|
anim = {
|
||||||
dict = 'mp_player_intdrink',
|
dict = 'mp_player_intdrink',
|
||||||
clip = 'loop_bottle'
|
clip = 'loop_bottle'
|
||||||
},
|
},
|
||||||
prop = {
|
prop = {
|
||||||
model = `prop_ld_flow_bottle`,
|
model = `prop_ld_flow_bottle`,
|
||||||
pos = vec3(0.03, 0.03, 0.02),
|
pos = vec3(0.03, 0.03, 0.02),
|
||||||
rot = vec3(0.0, 0.0, -1.5)
|
rot = vec3(0.0, 0.0, -1.5)
|
||||||
},
|
},
|
||||||
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -246,7 +255,7 @@ if (await lib.progressCircle({
|
|||||||
},
|
},
|
||||||
anim: {
|
anim: {
|
||||||
dict: 'mp_player_intdrink',
|
dict: 'mp_player_intdrink',
|
||||||
clip: 'loop_bottle'
|
clip: 'loop_bottle'
|
||||||
},
|
},
|
||||||
prop: {
|
prop: {
|
||||||
model: `prop_ld_flow_bottle`,
|
model: `prop_ld_flow_bottle`,
|
||||||
@@ -256,12 +265,14 @@ 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')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## lib.progressActive
|
## lib.progressActive
|
||||||
|
|
||||||
Returns true if a progress bar is currently active.
|
Returns true if a progress bar is currently active.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -270,6 +281,7 @@ Returns true if a progress bar is currently active.
|
|||||||
```lua
|
```lua
|
||||||
lib.progressActive()
|
lib.progressActive()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -278,11 +290,12 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.progressActive()
|
lib.progressActive()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
## lib.cancelProgress
|
## lib.cancelProgress
|
||||||
|
|
||||||
If there is a progress bar active and the
|
If there is a progress bar active and the
|
||||||
progress bar can be cancelled then it cancels it.
|
progress bar can be cancelled then it cancels it.
|
||||||
|
|
||||||
@@ -292,6 +305,7 @@ progress bar can be cancelled then it cancels it.
|
|||||||
```lua
|
```lua
|
||||||
lib.cancelProgress()
|
lib.cancelProgress()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -300,6 +314,6 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.cancelProgress()
|
lib.cancelProgress()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ Runs a skill check with the defined difficulty.
|
|||||||
```lua
|
```lua
|
||||||
lib.skillCheck(difficulty)
|
lib.skillCheck(difficulty)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -23,10 +24,11 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.skillCheck(difficulty)
|
lib.skillCheck(difficulty)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* difficulty: `easy` or `medium` or `hard` or `object`
|
* difficulty: `easy` or `medium` or `hard` or `object`
|
||||||
* Can set custom difficulty by sending a object instead of string
|
* Can set custom difficulty by sending a object instead of string
|
||||||
* { areaSize: `number`, speedMultiplier: `number` }
|
* { areaSize: `number`, speedMultiplier: `number` }
|
||||||
* easy: { areaSize: 50, speedMultiplier: 1 }
|
* easy: { areaSize: 50, speedMultiplier: 1 }
|
||||||
@@ -43,6 +45,7 @@ lib.skillCheck(difficulty)
|
|||||||
```lua
|
```lua
|
||||||
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'})
|
local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -51,7 +54,8 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard'])
|
const success = await lib.skillCheck(['easy', 'easy', {areaSize: 60, speedMultiplier: 2}, 'hard'])
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
@@ -6,9 +6,10 @@ import Tabs from '@theme/Tabs';
|
|||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
## lib.showTextUI
|
## lib.showTextUI
|
||||||
|
|
||||||
Show the TextUI window.
|
Show the TextUI window.
|
||||||
|
|
||||||
**DO NOT** run this every tick, it's intented to be used as a toggle.
|
**DO NOT** run this every tick, it's intended to be used as a toggle.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value='Lua'>
|
<TabItem value='Lua'>
|
||||||
@@ -16,6 +17,7 @@ Show the TextUI window.
|
|||||||
```lua
|
```lua
|
||||||
lib.showTextUI(text, options)
|
lib.showTextUI(text, options)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -24,11 +26,12 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.showTextUI(text, options)
|
lib.showTextUI(text, options)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* text: `string`
|
* text: `string`
|
||||||
* options?: `table`
|
* options?: `table`
|
||||||
* position?: `'right-center'` or `'left-center'` or `'top-center'`
|
* position?: `'right-center'` or `'left-center'` or `'top-center'`
|
||||||
* Default: `'right-center'`
|
* Default: `'right-center'`
|
||||||
* icon?: `string` or `table` (`array`)
|
* icon?: `string` or `table` (`array`)
|
||||||
@@ -45,6 +48,7 @@ lib.showTextUI(text, options)
|
|||||||
```lua
|
```lua
|
||||||
lib.showTextUI('[E] - Fuel vehicle')
|
lib.showTextUI('[E] - Fuel vehicle')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -53,10 +57,11 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.showTextUI('[E] - Fuel vehicle')
|
lib.showTextUI('[E] - Fuel vehicle')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Custom styling
|
### Custom styling
|
||||||
|
|
||||||
@@ -74,6 +79,7 @@ lib.showTextUI('[E] - Pick apple', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -90,13 +96,14 @@ lib.showTextUI('[E] - Pick apple', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
### lib.hideTextUI
|
### lib.hideTextUI
|
||||||
|
|
||||||
Hides the currently visible TextUI window
|
Hides the currently visible TextUI window
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -105,6 +112,7 @@ Hides the currently visible TextUI window
|
|||||||
```lua
|
```lua
|
||||||
lib.hideTextUI()
|
lib.hideTextUI()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -113,7 +121,6 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.hideTextUI()
|
lib.hideTextUI()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
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`
|
||||||
|
|
||||||
To change the preferred language from English, add the convar to your server.cfg
|
To change the preferred language from English, add the convar to your server.cfg
|
||||||
```cfg
|
|
||||||
|
```yaml
|
||||||
setr ox:locale en
|
setr ox:locale en
|
||||||
```
|
```
|
||||||
|
|
||||||
Initialise the locale module in your resource (once).
|
Initialise the locale module in your resource (once).
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.locale()
|
lib.locale()
|
||||||
```
|
```
|
||||||
|
|
||||||
Format your strings with the new locale global.
|
Format your strings with the new locale global.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
locale(str, ...)
|
locale(str, ...)
|
||||||
```
|
```
|
||||||
@@ -26,8 +29,8 @@ Additional arguments can be sent to format the locale output.
|
|||||||
lib.locale()
|
lib.locale()
|
||||||
|
|
||||||
SetInterval(function()
|
SetInterval(function()
|
||||||
print(locale('grand_theft_auto'))
|
print(locale('grand_theft_auto'))
|
||||||
print(locale('suspect_sex', locale('male')))
|
print(locale('suspect_sex', locale('male')))
|
||||||
end, 5000)
|
end, 5000)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -51,6 +54,6 @@ end, 5000)
|
|||||||
|
|
||||||
```lua title="fxmanifest.lua"
|
```lua title="fxmanifest.lua"
|
||||||
files {
|
files {
|
||||||
'locales/*.json'
|
'locales/*.json'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
## Submit logs to Datadog
|
## Submit logs to Datadog
|
||||||
|
|
||||||
Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys).
|
Register an account with [datadog](https://www.datadoghq.com/). Once registered you need to create an [API key](https://app.datadoghq.com/organization-settings/api-keys).
|
||||||
Modify your `server.cfg` with the newly generated API key and [intake server](https://docs.datadoghq.com/api/latest/logs/#send-logs).
|
Modify your `server.cfg` with the newly generated API key and [intake server](https://docs.datadoghq.com/api/latest/logs/#send-logs).
|
||||||
|
|
||||||
- datadoghq.com
|
- datadoghq.com
|
||||||
- us3.datadoghq.com
|
- us3.datadoghq.com
|
||||||
- us5.datadoghq.com
|
- us5.datadoghq.com
|
||||||
- datadoghq.eu
|
- datadoghq.eu
|
||||||
```
|
|
||||||
|
```yaml
|
||||||
set datadog:key "yourapikey"
|
set datadog:key "yourapikey"
|
||||||
set datadog:site "datadoghq.com"
|
set datadog:site "datadoghq.com"
|
||||||
```
|
```
|
||||||
@@ -14,14 +16,14 @@ set datadog:site "datadoghq.com"
|
|||||||
```lua
|
```lua
|
||||||
lib.logger(source, event, message, ...)
|
lib.logger(source, event, message, ...)
|
||||||
```
|
```
|
||||||
* source: `string` or `number`
|
|
||||||
* event: `string`
|
|
||||||
* message: `string`
|
|
||||||
* ...: `string`
|
|
||||||
|
|
||||||
|
- source: `string` or `number`
|
||||||
|
- event: `string`
|
||||||
|
- message: `string`
|
||||||
|
- ...: `string`
|
||||||
|
|
||||||
Source is passed to ddsource and creates a tag. Could be playerId, identifier, -1, or server.
|
Source is passed to `ddsource` and creates a tag. Could be playerId, identifier, -1, or server.
|
||||||
Event is passed to ddservice and displays in the logs list.
|
Event is passed to `ddservice` and displays in the logs list.
|
||||||
Additional arguments are converted into tags for additional filtering and search options.
|
Additional arguments are converted into tags for additional filtering and search options.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -61,13 +63,13 @@ Once registered with Grafana Cloud, head to [My Account](https://grafana.com/aut
|
|||||||
|
|
||||||
To setup a grafana instance you'll require docker, and knowledge on containers or kubernetes. Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that. Once done, setup authentication and use the username and password securing your endpoint.
|
To setup a grafana instance you'll require docker, and knowledge on containers or kubernetes. Please find a guide to setup a grafana stack (min requirement grafana and grafana loki) and follow that. Once done, setup authentication and use the username and password securing your endpoint.
|
||||||
|
|
||||||
[*] Please note: By default self-hosted loki instances do not provide any authenication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
|
[*] Please note: By default self-hosted loki instances do not provide any authentication layers and will require an external authentication layer such as NGINX basic auth or Cloudflare Access.
|
||||||
|
|
||||||
#### Setting up Server Config
|
#### Setting up Server Config
|
||||||
|
|
||||||
Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg.
|
Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg.
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
set ox:logger "loki"
|
set ox:logger "loki"
|
||||||
set loki:user "<insert your user>"
|
set loki:user "<insert your user>"
|
||||||
set loki:key "<insert the api key or password>"
|
set loki:key "<insert the api key or password>"
|
||||||
@@ -76,7 +78,7 @@ set loki:endpoint "<insert loki url without http:// or https://>"
|
|||||||
|
|
||||||
Here is an example
|
Here is an example
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
set ox:logger "loki"
|
set ox:logger "loki"
|
||||||
set loki:user "1337"
|
set loki:user "1337"
|
||||||
set loki:key "alongcomplicatedsecurepassword"
|
set loki:key "alongcomplicatedsecurepassword"
|
||||||
@@ -89,4 +91,4 @@ The data can be inserted into Loki the same way as datadog so you can follow the
|
|||||||
|
|
||||||
#### Browsing Data
|
#### Browsing Data
|
||||||
|
|
||||||
If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite indepth with what you can do, you can even track metrics and economic health all from logs.
|
If you're unfamiliar with how to use Loki please follow an online guide or a youtube video. You can get quite in-depth with what you can do, you can even track metrics and economic health all from logs.
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
# Points
|
# 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.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.points.new(coords, distance, data)
|
lib.points.new(coords, distance, data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* distance: `number`
|
* distance: `number`
|
||||||
* data: `table`
|
* data: `table`
|
||||||
@@ -33,6 +34,7 @@ end
|
|||||||
```
|
```
|
||||||
|
|
||||||
Points can be deleted by using the remove method.
|
Points can be deleted by using the remove method.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
point:remove()
|
point:remove()
|
||||||
```
|
```
|
||||||
@@ -5,12 +5,14 @@ Starts a shapetest originating from the camera, extending to ~10m.
|
|||||||
```lua
|
```lua
|
||||||
function lib.raycast.cam(flags, p8) end
|
function lib.raycast.cam(flags, p8) end
|
||||||
```
|
```
|
||||||
|
|
||||||
* flags?: `number`
|
* flags?: `number`
|
||||||
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
||||||
* p8?: `number`
|
* p8?: `number`
|
||||||
* A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
* A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
|
|
||||||
* hit: `boolean`
|
* hit: `boolean`
|
||||||
* entityHit: `number`
|
* entityHit: `number`
|
||||||
* endCoords: `vector3`
|
* endCoords: `vector3`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Check if assets exist, such as models, and loads them into memory.
|
Check if assets exist, such as models, and loads them into memory.
|
||||||
Throws errors for invalid assets and returns true if the asset is loaded.
|
Throws errors for invalid assets and returns true if the asset is loaded.
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
@@ -12,6 +12,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
```lua
|
```lua
|
||||||
lib.requestAnimDict(dict, timeout)
|
lib.requestAnimDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.requestAnimDict(dict, timeout)
|
lib.requestAnimDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -27,7 +29,6 @@ lib.requestAnimDict(dict, timeout)
|
|||||||
* timeout: `number`
|
* timeout: `number`
|
||||||
* Default: `100`
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestAnimSet
|
### lib.requestAnimSet
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -36,6 +37,7 @@ lib.requestAnimDict(dict, timeout)
|
|||||||
```lua
|
```lua
|
||||||
lib.requestAnimSet(set, timeout)
|
lib.requestAnimSet(set, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -44,6 +46,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.requestAnimSet(set, timeout)
|
lib.requestAnimSet(set, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ lib.requestAnimSet(set, timeout)
|
|||||||
```lua
|
```lua
|
||||||
lib.requestModel(model, timeout)
|
lib.requestModel(model, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -67,6 +71,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.requestModel(model, timeout)
|
lib.requestModel(model, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -74,7 +79,6 @@ lib.requestModel(model, timeout)
|
|||||||
* timeout: `number`
|
* timeout: `number`
|
||||||
* Default: `100`
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestStreamedTextureDict
|
### lib.requestStreamedTextureDict
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -83,6 +87,7 @@ lib.requestModel(model, timeout)
|
|||||||
```lua
|
```lua
|
||||||
lib.requestStreamedTextureDict(dict, timeout)
|
lib.requestStreamedTextureDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -91,6 +96,7 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.requestStreamedTextureDict(dict, timeout)
|
lib.requestStreamedTextureDict(dict, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
@@ -98,7 +104,6 @@ lib.requestStreamedTextureDict(dict, timeout)
|
|||||||
* timeout: `number`
|
* timeout: `number`
|
||||||
* Default: `100`
|
* Default: `100`
|
||||||
|
|
||||||
|
|
||||||
### lib.requestNamedPtfxAsset
|
### lib.requestNamedPtfxAsset
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -106,8 +111,8 @@ lib.requestStreamedTextureDict(dict, timeout)
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -116,10 +121,10 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
* fxName: `string`
|
* fxName: `string`
|
||||||
* timeout: `number`
|
* timeout: `number`
|
||||||
* Default: `100`
|
* Default: `100`
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
|
Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
|
||||||
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5
|
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
@@ -6,10 +6,10 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
### lib.getVehicleProperties
|
### lib.getVehicleProperties
|
||||||
|
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
lib.getVehicleProperties(vehicle)
|
lib.getVehicleProperties(vehicle)
|
||||||
```
|
```
|
||||||
|
|
||||||
* vehicle: `entity`
|
* vehicle: `entity`
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -18,6 +18,7 @@ lib.getVehicleProperties(vehicle)
|
|||||||
```lua
|
```lua
|
||||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -26,16 +27,18 @@ import lib from '@overextended/ox_lib/client'
|
|||||||
|
|
||||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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_.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
lib.setVehicleProperties(vehicle, props)
|
lib.setVehicleProperties(vehicle, props)
|
||||||
```
|
```
|
||||||
|
|
||||||
* vehicle: `entity`
|
* vehicle: `entity`
|
||||||
* props: `table` (`object`)
|
* props: `table` (`object`)
|
||||||
|
|
||||||
@@ -47,6 +50,7 @@ RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
|||||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -57,13 +61,14 @@ onNet('ox_lib:setVehicleProperties', (netid, data) => {
|
|||||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</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.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
|
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
|
||||||
```
|
```
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
### lib.versionCheck
|
### lib.versionCheck
|
||||||
Compares the resource version to the latest published release on GitHub.
|
|
||||||
|
Compares the resource version to the latest published release on GitHub.
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
@@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
```lua
|
```lua
|
||||||
lib.versionCheck(repository)
|
lib.versionCheck(repository)
|
||||||
```
|
```
|
||||||
|
|
||||||
* repository: `string`
|
* repository: `string`
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -15,6 +17,7 @@ lib.versionCheck(repository)
|
|||||||
```lua
|
```lua
|
||||||
lib.versionCheck('overextended/ox_lib')
|
lib.versionCheck('overextended/ox_lib')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -23,6 +26,7 @@ import lib from '@overextended/ox_lib/server'
|
|||||||
|
|
||||||
lib.versionCheck('overextended/ox_lib')
|
lib.versionCheck('overextended/ox_lib')
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
### lib.checkDependency
|
### lib.checkDependency
|
||||||
|
|
||||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
@@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
```lua
|
```lua
|
||||||
lib.checkDependency(resource, version)
|
lib.checkDependency(resource, version)
|
||||||
```
|
```
|
||||||
|
|
||||||
* resource: `string`
|
* resource: `string`
|
||||||
* version: `string`
|
* version: `string`
|
||||||
|
|
||||||
@@ -16,6 +18,7 @@ lib.checkDependency(resource, version)
|
|||||||
```lua
|
```lua
|
||||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -25,7 +28,6 @@ import lib from '@overextended/ox_lib/shared'
|
|||||||
|
|
||||||
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
|
|
||||||
+18
-14
@@ -5,6 +5,7 @@ Faster alternative to PolyZone utilising [glm.polygon](https://github.com/gottfr
|
|||||||
```lua
|
```lua
|
||||||
lib.zones.poly(data)
|
lib.zones.poly(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* data: `table`
|
* data: `table`
|
||||||
* points: `vector3[]`
|
* points: `vector3[]`
|
||||||
* All z values must match
|
* All z values must match
|
||||||
@@ -20,6 +21,7 @@ lib.zones.poly(data)
|
|||||||
```lua
|
```lua
|
||||||
lib.zones.box(data)
|
lib.zones.box(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* data: `table`
|
* data: `table`
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* size?: `vector3`
|
* size?: `vector3`
|
||||||
@@ -36,6 +38,7 @@ lib.zones.box(data)
|
|||||||
```lua
|
```lua
|
||||||
lib.zones.sphere(data)
|
lib.zones.sphere(data)
|
||||||
```
|
```
|
||||||
|
|
||||||
* data: `table`
|
* data: `table`
|
||||||
* coords: `vector3`
|
* coords: `vector3`
|
||||||
* radius?: `number`
|
* radius?: `number`
|
||||||
@@ -75,11 +78,11 @@ local poly = lib.zones.poly({
|
|||||||
vec(420.0, -1030.2, 29),
|
vec(420.0, -1030.2, 29),
|
||||||
vec(409.8, -1028.4, 29),
|
vec(409.8, -1028.4, 29),
|
||||||
},
|
},
|
||||||
thickness = 2,
|
thickness = 2,
|
||||||
debug = true,
|
debug = true,
|
||||||
inside = inside,
|
inside = inside,
|
||||||
onEnter = onEnter,
|
onEnter = onEnter,
|
||||||
onExit = onExit
|
onExit = onExit
|
||||||
})
|
})
|
||||||
|
|
||||||
local sphere = lib.zones.sphere({
|
local sphere = lib.zones.sphere({
|
||||||
@@ -92,17 +95,18 @@ local sphere = lib.zones.sphere({
|
|||||||
})
|
})
|
||||||
|
|
||||||
local box = lib.zones.box({
|
local box = lib.zones.box({
|
||||||
coords = vec3(442.5363, -1017.666, 28.65637),
|
coords = vec3(442.5363, -1017.666, 28.65637),
|
||||||
size = vec3(1, 1, 1),
|
size = vec3(1, 1, 1),
|
||||||
rotation = 45,
|
rotation = 45,
|
||||||
debug = true,
|
debug = true,
|
||||||
inside = insideZone,
|
inside = insideZone,
|
||||||
onEnter = onEnter,
|
onEnter = onEnter,
|
||||||
onExit = onExit
|
onExit = onExit
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Zones can be deleted by using the remove method.
|
Zones can be deleted by using the remove method.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
poly:remove()
|
poly:remove()
|
||||||
sphere:remove()
|
sphere:remove()
|
||||||
@@ -110,11 +114,11 @@ box:remove()
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Zone creation script
|
## Zone creation script
|
||||||
|
|
||||||
Similarly to PolyZone, there is a zone creation script included.
|
Similarly to PolyZone, there is a zone creation script included.
|
||||||
|
|
||||||
To use it use the `/zone` with `poly`, `box` or `sphere` as args.
|
To use it use the `/zone` with `poly`, `box` or `sphere` as args.
|
||||||
|
|
||||||
Available controls will be displayed on the right side.
|
Available controls will be displayed on the right side.
|
||||||
|
|
||||||
Once saved you will find the created zone details in created_zones.lua withn ox_lib
|
Once saved you will find the created zone details in created_zones.lua within ox_lib
|
||||||
|
|
||||||
+13
-8
@@ -8,7 +8,7 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
ox_lib is a collection of Lua and UI functions to utilise in other resources.
|
ox_lib is a collection of Lua and UI functions to utilise in other resources.
|
||||||
|
|
||||||
The UI is built in React so the code needs to be compiled into standard JS.
|
The UI is built in React so the code needs to be compiled into standard JS.
|
||||||
If you don't know how to do this then please download the [release](https://github.com/overextended/ox_lib/releases/latest) (ox_lib.zip) which is *already* compiled into a working resource.
|
If you don't know how to do this then please download the [release](https://github.com/overextended/ox_lib/releases/latest) (ox_lib.zip) which is *already* compiled into a working resource.
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
@@ -28,6 +28,7 @@ Or if the library is the only shared script you use you can do:
|
|||||||
```lua
|
```lua
|
||||||
shared_script '@ox_lib/init.lua'
|
shared_script '@ox_lib/init.lua'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ All supported functions are located inside the `resource` folder in the lib.
|
|||||||
|
|
||||||
You can get the npm package [here](https://npmjs.com/package/@overextended/ox_lib).
|
You can get the npm package [here](https://npmjs.com/package/@overextended/ox_lib).
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
You can either import the whole library object which contains all the functions for that scope (client/server/shared) or
|
You can either import the whole library object which contains all the functions for that scope (client/server/shared) or
|
||||||
you can deconstruct it and import the functions you find needed at the time.
|
you can deconstruct it and import the functions you find needed at the time.
|
||||||
|
|
||||||
@@ -50,25 +51,27 @@ import lib from '@overextended/ox_lib/server'
|
|||||||
```ts
|
```ts
|
||||||
import { versionCheck } from '@overextended/ox_lib/server'
|
import { versionCheck } from '@overextended/ox_lib/server'
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
**ACE Permissions:**
|
**ACE Permissions:**
|
||||||
```
|
|
||||||
|
```yaml
|
||||||
add_ace resource.ox_lib command.add_ace allow
|
add_ace resource.ox_lib command.add_ace allow
|
||||||
add_ace resource.ox_lib command.remove_ace allow
|
add_ace resource.ox_lib command.remove_ace allow
|
||||||
add_ace resource.ox_lib command.add_principal allow
|
add_ace resource.ox_lib command.add_principal allow
|
||||||
add_ace resource.ox_lib command.remove_principal allow
|
add_ace resource.ox_lib command.remove_principal allow
|
||||||
```
|
```
|
||||||
|
|
||||||
That's it!
|
That's it!
|
||||||
You can now use the library functions inside of your resource, check the rest of the
|
You can now use the library functions inside of your resource, check the rest of the
|
||||||
documentation to see how to utilise them.
|
documentation to see how to utilise them.
|
||||||
|
|
||||||
# Using icons for interface functions
|
## Using icons for interface functions
|
||||||
|
|
||||||
The icon library used is Font Awesome 6.0, if for the icon you define only a string
|
The icon library used is Font Awesome 6.0, if for the icon you define only a string
|
||||||
the default icon type will be `solid`.
|
the default icon type will be `solid`.
|
||||||
If you want to use a different icon type, i.e
|
If you want to use a different icon type, i.e
|
||||||
apple as a brand, you need to define icon as a table (`array`) with the first value being
|
apple as a brand, you need to define icon as a table (`array`) with the first value being
|
||||||
the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name.
|
the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name.
|
||||||
@@ -79,23 +82,25 @@ the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon n
|
|||||||
```lua
|
```lua
|
||||||
icon = {'fab', 'apple'}
|
icon = {'fab', 'apple'}
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='JS/TS'>
|
<TabItem value='JS/TS'>
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
icon: ['fab', 'apple']
|
icon: ['fab', 'apple']
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
# Building the UI
|
## Building the UI
|
||||||
|
|
||||||
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then
|
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then
|
||||||
compile it.
|
compile it.
|
||||||
|
|
||||||
:::danger
|
:::danger
|
||||||
|
|
||||||
**DO NOT** debundle and unminify the release CSS and JS files to edit them.
|
**DO NOT** de-bundle and un-minify the release CSS and JS files to edit them.
|
||||||
:::
|
:::
|
||||||
**Requirements:**
|
**Requirements:**
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ slug: ./../
|
|||||||
|
|
||||||
We always recommend using Git so you can track changes and update easily.
|
We always recommend using Git so you can track changes and update easily.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/overextended/ox_target.git
|
git clone https://github.com/overextended/ox_target.git
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Registers options that will apply to all entities of that type (object, ped, pla
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
local options = {
|
local options = {
|
||||||
{
|
{
|
||||||
name = 'ox:option1',
|
name = 'ox:option1',
|
||||||
event = 'ox_target:debug',
|
event = 'ox_target:debug',
|
||||||
icon = 'fa-solid fa-road',
|
icon = 'fa-solid fa-road',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
```lua
|
```lua
|
||||||
local options = {
|
local options = {
|
||||||
{
|
{
|
||||||
name = 'ox:option1',
|
name = 'ox:option1',
|
||||||
event = 'ox_target:debug',
|
event = 'ox_target:debug',
|
||||||
icon = 'fa-solid fa-road',
|
icon = 'fa-solid fa-road',
|
||||||
@@ -42,7 +42,7 @@ exports.ox_target:removeModel(models, optionNames)
|
|||||||
|
|
||||||
## addEntity
|
## addEntity
|
||||||
|
|
||||||
Add new options when targeting a networked entity matching the given netid or list of netids.
|
Add new options when targeting a networked entity matching the given netid or list of netIds.
|
||||||
Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id.
|
Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -51,14 +51,13 @@ exports.ox_target:addEntity(netIds, options)
|
|||||||
|
|
||||||
## removeEntity
|
## removeEntity
|
||||||
|
|
||||||
Remove options from a networked entity matching the given netid or list of netids.
|
Remove options from a networked entity matching the given netid or list of netIds.
|
||||||
Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id.
|
Requires the use of [NetworkGetNetworkIdFromEntity](https://docs.fivem.net/natives/?_0x9E35DAB6) on an entity id.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
exports.ox_target:removeEntity(netIds, optionNames)
|
exports.ox_target:removeEntity(netIds, optionNames)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## addLocalEntity
|
## addLocalEntity
|
||||||
|
|
||||||
Add new options when targeting a local entity or list of entities.
|
Add new options when targeting a local entity or list of entities.
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ exports.ox_target:addSphereZone(parameters)
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
coords = vector3,
|
coords = vector3,
|
||||||
radius = number,
|
radius = number,
|
||||||
debug? = boolean,
|
debug? = boolean,
|
||||||
drawSprite? = boolean,
|
drawSprite? = boolean,
|
||||||
options = options,
|
options = options,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -49,12 +49,12 @@ exports.ox_target:addBoxZone(parameters)
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
coords = vector3,
|
coords = vector3,
|
||||||
size = vector3,
|
size = vector3,
|
||||||
rotation = number,
|
rotation = number,
|
||||||
debug? = boolean,
|
debug? = boolean,
|
||||||
drawSprite? = boolean,
|
drawSprite? = boolean,
|
||||||
options = options,
|
options = options,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -4,27 +4,27 @@ When calling exports to add options, the input is an array of tables with the fo
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
-- an identifier used when removing options
|
-- an identifier used when removing options
|
||||||
name? = string,
|
name? = string,
|
||||||
-- an icon from font-awesome
|
-- an icon from font-awesome
|
||||||
icon? = string,
|
icon? = string,
|
||||||
-- display text
|
-- display text
|
||||||
label = string,
|
label = string,
|
||||||
-- range to display (default: 2, max: 7)
|
-- range to display (default: 2, max: 7)
|
||||||
distance? = number,
|
distance? = number,
|
||||||
-- a group, array of groups, or groups and grades needed to display
|
-- a group, array of groups, or groups and grades needed to display
|
||||||
groups? = string | string[] | { [string]: number }
|
groups? = string | string[] | { [string]: number }
|
||||||
-- an item, array of items, or items and counts needed to display
|
-- an item, array of items, or items and counts needed to display
|
||||||
items? = string | string[] | { [string]: number }
|
items? = string | string[] | { [string]: number }
|
||||||
-- a bone, bones table to select specific parts
|
-- a bone, bones table to select specific parts
|
||||||
bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' }
|
bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' }
|
||||||
-- custom check to hide or display the option
|
-- custom check to hide or display the option
|
||||||
canInteract? = function(entity, distance, coords, name, bone),
|
canInteract? = function(entity, distance, coords, name, bone),
|
||||||
-- triggered on option selection (one only)
|
-- triggered on option selection (one only)
|
||||||
onSelect? = function(data),
|
onSelect? = function(data),
|
||||||
export? = string,
|
export? = string,
|
||||||
event? = string,
|
event? = string,
|
||||||
serverEvent? = string,
|
serverEvent? = string,
|
||||||
command? = string
|
command? = string
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -1,16 +1,19 @@
|
|||||||
# Benchmark
|
# Benchmark
|
||||||
|
|
||||||
Internal benchmark
|
Internal benchmark
|
||||||
```
|
|
||||||
|
```md
|
||||||
Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)
|
Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)
|
||||||
```
|
```
|
||||||
|
|
||||||
Round-trip-time for exports
|
Round-trip-time for exports
|
||||||
```
|
|
||||||
|
```md
|
||||||
Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries)
|
Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Lua (5.4)
|
## Lua (5.4)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local val = 10000
|
local val = 10000
|
||||||
RegisterCommand('luasync', function()
|
RegisterCommand('luasync', function()
|
||||||
@@ -38,7 +41,8 @@ RegisterCommand('luasync', function()
|
|||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### JavaScript
|
## JavaScript
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const val = 10000
|
const val = 10000
|
||||||
RegisterCommand('jssync', async() => {
|
RegisterCommand('jssync', async() => {
|
||||||
@@ -60,4 +64,4 @@ RegisterCommand('jssync', async() => {
|
|||||||
console.log(result)
|
console.log(result)
|
||||||
console.log('Low: '+ queryMsLow +'ms | Avg: '+averageQueryTime+'ms | Total: '+queryMsSum+'ms ('+queryTimesLocal.length+' queries)')
|
console.log('Low: '+ queryMsLow +'ms | Avg: '+averageQueryTime+'ms | Total: '+queryMsSum+'ms ('+queryTimesLocal.length+' queries)')
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -31,23 +31,21 @@ Reference the following for an idea of how to set your connection options.
|
|||||||
You must include one of the following lines, adjusted for your connection and database settings.
|
You must include one of the following lines, adjusted for your connection and database settings.
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
When using convars do not replicate sensitive information to the client.
|
||||||
When using convars do not replicate sensitive information to the client.
|
|
||||||
**set** will only be set on the server, while **setr** is replicated.
|
**set** will only be set on the server, while **setr** is replicated.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
set mysql_connection_string "mysql://root:12345@localhost:3306/es_extended?charset=utf8mb4"
|
set mysql_connection_string "mysql://root:12345@localhost:3306/es_extended?charset=utf8mb4"
|
||||||
set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=es_extended;charset=utf8mb4"
|
set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=es_extended;charset=utf8mb4"
|
||||||
```
|
```
|
||||||
|
|
||||||
Certain special characters are reserved or blocked and may cause issues when used in your password.
|
Certain special characters are reserved or blocked and may cause issues when used in your password.
|
||||||
For more optional settings (such as multiple statements) you can reference [pool.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Pool.d.ts#L10) and [connection.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L8).
|
For more optional settings (such as multiple statements) you can reference [pool.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Pool.d.ts#L10) and [connection.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L8).
|
||||||
|
|
||||||
You can also add the following convars if you require extra information when testing queries.
|
You can also add the following convars if you require extra information when testing queries.
|
||||||
|
|
||||||
```json
|
```yaml
|
||||||
set mysql_slow_query_warning 150
|
set mysql_slow_query_warning 150
|
||||||
set mysql_debug true
|
set mysql_debug true
|
||||||
```
|
```
|
||||||
@@ -56,7 +54,7 @@ set mysql_debug true
|
|||||||
|
|
||||||
When using the `mysql_debug` convar, rather than setting the value as true, you can send an array and enable debug prints for a set list of resources instead.
|
When using the `mysql_debug` convar, rather than setting the value as true, you can send an array and enable debug prints for a set list of resources instead.
|
||||||
|
|
||||||
```json
|
```yaml
|
||||||
set mysql_debug [
|
set mysql_debug [
|
||||||
"ox_core",
|
"ox_core",
|
||||||
"ox_inventory"
|
"ox_inventory"
|
||||||
@@ -65,7 +63,7 @@ set mysql_debug [
|
|||||||
|
|
||||||
This list can be adjusted during runtime with commands, temporarily adding or removing resources until the resource is restarted.
|
This list can be adjusted during runtime with commands, temporarily adding or removing resources until the resource is restarted.
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
oxmysql_debug remove ox_core
|
oxmysql_debug remove ox_core
|
||||||
oxmysql_debug add ox_core
|
oxmysql_debug add ox_core
|
||||||
```
|
```
|
||||||
@@ -74,7 +72,7 @@ oxmysql_debug add ox_core
|
|||||||
|
|
||||||
Before using the UI first you have to make sure you have the `mysql_ui` convar set to true:
|
Before using the UI first you have to make sure you have the `mysql_ui` convar set to true:
|
||||||
|
|
||||||
```json
|
```yaml
|
||||||
set mysql_ui true
|
set mysql_ui true
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -83,14 +81,14 @@ Also make sure that you have `command` ace permission access, then you should be
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
You shouldn't run multiple mysql resources to ensure the best experience.
|
You shouldn't run multiple mysql resources to ensure the best experience.
|
||||||
The resources listed below can be deleted to allow oxmysql to handle the events, without any changes.
|
The resources listed below can be deleted to allow oxmysql to handle the events, without any changes.
|
||||||
|
|
||||||
### mysql-async
|
### mysql-async
|
||||||
|
|
||||||
Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`.
|
Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`.
|
||||||
Raw exports, mostly used in resources written in JavaScript or C#, are _not supported_.
|
Raw exports, mostly used in resources written in JavaScript or C#, are _not supported_.
|
||||||
|
|
||||||
### ghmattimysql
|
### ghmattimysql
|
||||||
|
|
||||||
As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`.
|
As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`.
|
||||||
@@ -1,21 +1,24 @@
|
|||||||
# Common Issues
|
# 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 (`; , / ? : @ & = + $ #`).
|
||||||
:::tip Solution
|
:::tip Solution
|
||||||
Ensure you have entered the correct database settings in the mysql_connection_string convar.
|
Ensure you have entered the correct database settings in the mysql_connection_string convar.
|
||||||
You can try using the semicolon-separated format if your password contains reserved characters.
|
You can try using the semicolon-separated format if your password contains reserved characters.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### No such export ... in resource oxmysql
|
### No such export ... in resource oxmysql
|
||||||
|
|
||||||
Typically the result of failing to follow instructions.
|
Typically the result of failing to follow instructions.
|
||||||
:::tip Solution
|
:::tip Solution
|
||||||
Download the latest release _build_ (not source) of oxmysql, and ensure it is starting before any resources that require it.
|
Download the latest release _build_ (not source) of oxmysql, and ensure it is starting before any resources that require it.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### Numbers treated as string
|
### Numbers treated as string
|
||||||
|
|
||||||
This is an incompatibility between mysqljs (used by mysql-async) and mysql2 (used by oxmysql) (See [Known incompatibilities with node-mysql](https://github.com/sidorares/node-mysql2/tree/master/documentation#known-incompatibilities-with-node-mysql))
|
This is an incompatibility between mysqljs (used by mysql-async) and mysql2 (used by oxmysql) (See [Known incompatibilities with node-mysql](https://github.com/sidorares/node-mysql2/tree/master/documentation#known-incompatibilities-with-node-mysql))
|
||||||
|
|
||||||
To resolve this issue simply add `&decimalNumbers=true` to the connection string, ie. `mysql://root@localhost/essentialmode?charset=utf8mb4_general_ci&decimalNumbers=true` to revert to the behavior of mysqljs.
|
To resolve this issue simply add `&decimalNumbers=true` to the connection string, ie. `mysql://root@localhost/essentialmode?charset=utf8mb4_general_ci&decimalNumbers=true` to revert to the behavior of mysqljs.
|
||||||
|
|
||||||
Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way.
|
Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way.
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This allows queries to be properly prepared and escaped; the following lines are equivalent.
|
This allows queries to be properly prepared and escaped; the following lines are equivalent.
|
||||||
|
|
||||||
```
|
```lua
|
||||||
"SELECT group FROM users WHERE identifier = ?", {identifier}
|
"SELECT group FROM users WHERE identifier = ?", {identifier}
|
||||||
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
|
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
|
||||||
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}
|
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ If you are using VSCode with [sumneko Lua](https://marketplace.visualstudio.com/
|
|||||||
|
|
||||||
Use your favourite package manager to install our [node package](https://www.npmjs.com/package/@overextended/oxmysql).
|
Use your favourite package manager to install our [node package](https://www.npmjs.com/package/@overextended/oxmysql).
|
||||||
|
|
||||||
```yaml
|
```bash
|
||||||
# With pnpm
|
# With pnpm
|
||||||
pnpm add @overextended/oxmysql
|
pnpm add @overextended/oxmysql
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ import { oxmysql as MySQL } from '@overextended/oxmysql';
|
|||||||
|
|
||||||
## Placeholders
|
## Placeholders
|
||||||
|
|
||||||
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
|
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
|
||||||
Named placeholders are not recommended, and unsupported when using MySQL.prepare.
|
Named placeholders are not recommended, and unsupported when using MySQL.prepare.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@@ -59,5 +59,5 @@ When uncertain if a row should be inserted into the database, or an existing row
|
|||||||
MySQL.prepare('INSERT INTO ox_inventory (owner, name, data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)', { owner, dbId, inventory })
|
MySQL.prepare('INSERT INTO ox_inventory (owner, name, data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)', { owner, dbId, inventory })
|
||||||
```
|
```
|
||||||
|
|
||||||
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
|
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
|
||||||
Furthermore, unlike using 'REPLACE INTO', the row is not deleted and re-inserted.
|
Furthermore, unlike using 'REPLACE INTO', the row is not deleted and re-inserted.
|
||||||
@@ -5,6 +5,7 @@ Inserts a new entry into the database and returns the insert id for the row, if
|
|||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:insert
|
-- alias: exports.oxmysql:insert
|
||||||
-- alias: MySQL.Async.insert
|
-- alias: MySQL.Async.insert
|
||||||
@@ -15,6 +16,7 @@ end)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:insert_async
|
-- alias: exports.oxmysql:insert_async
|
||||||
-- alias: MySQL.Sync.insert
|
-- alias: MySQL.Sync.insert
|
||||||
@@ -26,6 +28,7 @@ print(id)
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.insert
|
// alias: exports.oxmysql.insert
|
||||||
|
|
||||||
@@ -35,6 +38,7 @@ MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?,
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.insert_async
|
// alias: exports.oxmysql.insert_async
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
# Prepare
|
# Prepare
|
||||||
|
|
||||||
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
|
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
|
||||||
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
|
||||||
- TINYINT 1 and BIT will not return a boolean
|
- TINYINT 1 and BIT will not return a boolean
|
||||||
- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error
|
- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error
|
||||||
|
|
||||||
When using SELECT, the return value will match `query, single, or scalar` depending on the number of columns and rows selected.
|
When using SELECT, the return value will match `query, single, or scalar` depending on the number of columns and rows selected.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:prepare
|
-- alias: exports.oxmysql:prepare
|
||||||
-- alias: MySQL.Async.prepare
|
-- alias: MySQL.Async.prepare
|
||||||
@@ -24,6 +25,7 @@ end)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:prepare_async
|
-- alias: exports.oxmysql:prepare_async
|
||||||
-- alias: MySQL.Sync.prepare
|
-- alias: MySQL.Sync.prepare
|
||||||
@@ -37,6 +39,7 @@ end
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.prepare
|
// alias: exports.oxmysql.prepare
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ MySQL.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (r
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.prepare_async
|
// alias: exports.oxmysql.prepare_async
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
# Query
|
# Query
|
||||||
Generic function that can be utilised for any query.
|
|
||||||
|
Generic function that can be utilised for any query.
|
||||||
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
|
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:query
|
-- alias: exports.oxmysql:query
|
||||||
-- alias: MySQL.Async.query
|
-- alias: MySQL.Async.query
|
||||||
@@ -18,7 +20,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, func
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:query_async
|
-- alias: exports.oxmysql:query_async
|
||||||
-- alias: MySQL.Sync.query
|
-- alias: MySQL.Sync.query
|
||||||
@@ -35,6 +39,7 @@ end
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.query
|
// alias: exports.oxmysql.query
|
||||||
|
|
||||||
@@ -46,7 +51,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (res
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.query_async
|
// alias: exports.oxmysql.query_async
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
# Scalar
|
# Scalar
|
||||||
|
|
||||||
Returns the first column for a single row.
|
Returns the first column for a single row.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:scalar
|
-- alias: exports.oxmysql:scalar
|
||||||
-- alias: MySQL.Async.fetchScalar
|
-- alias: MySQL.Async.fetchScalar
|
||||||
@@ -14,6 +16,7 @@ end)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:scalar_async
|
-- alias: exports.oxmysql:scalar_async
|
||||||
-- alias: MySQL.Sync.fetchScalar
|
-- alias: MySQL.Sync.fetchScalar
|
||||||
@@ -25,6 +28,7 @@ print(firstname)
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.scalar
|
// alias: exports.oxmysql.scalar
|
||||||
|
|
||||||
@@ -34,6 +38,7 @@ MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifi
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.scalar_async
|
// alias: exports.oxmysql.scalar_async
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
# Single
|
# Single
|
||||||
|
|
||||||
Returns the columns for a single row.
|
Returns the columns for a single row.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:single
|
-- alias: exports.oxmysql:single
|
||||||
-- alias: MySQL.Async.fetchSingle
|
-- alias: MySQL.Async.fetchSingle
|
||||||
@@ -16,6 +18,7 @@ end)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:single_async
|
-- alias: exports.oxmysql:single_async
|
||||||
-- alias: MySQL.Sync.fetchSingle
|
-- alias: MySQL.Sync.fetchSingle
|
||||||
@@ -29,6 +32,7 @@ end
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.single
|
// alias: exports.oxmysql.single
|
||||||
|
|
||||||
@@ -40,6 +44,7 @@ MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.single_async
|
// alias: exports.oxmysql.single_async
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ console.log(success);
|
|||||||
|
|
||||||
## Shared Format
|
## Shared Format
|
||||||
|
|
||||||
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
|
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
|
||||||
This is useful if your queries use the same SQL variables.
|
This is useful if your queries use the same SQL variables.
|
||||||
|
|
||||||
### Lua
|
### Lua
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
# Update
|
# Update
|
||||||
|
|
||||||
Returns the number of affected rows by the query.
|
Returns the number of affected rows by the query.
|
||||||
|
|
||||||
## Lua
|
## Lua
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:update
|
-- alias: exports.oxmysql:update
|
||||||
-- alias: MySQL.Async.execute
|
-- alias: MySQL.Async.execute
|
||||||
@@ -16,6 +18,7 @@ end)
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- alias: exports.oxmysql:update_async
|
-- alias: exports.oxmysql:update_async
|
||||||
-- alias: MySQL.Sync.execute
|
-- alias: MySQL.Sync.execute
|
||||||
@@ -29,6 +32,7 @@ end
|
|||||||
## JavaScript
|
## JavaScript
|
||||||
|
|
||||||
### Callback
|
### Callback
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.update
|
// alias: exports.oxmysql.update
|
||||||
|
|
||||||
@@ -40,6 +44,7 @@ MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, p
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Promise
|
### Promise
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// alias: exports.oxmysql.update_async
|
// alias: exports.oxmysql.update_async
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user