mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +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
|
||||
|
||||
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?
|
||||
|
||||
<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
|
||||
|
||||
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.
|
||||
|
||||
```lua
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# 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.
|
||||
set ox:primaryIdentifier "fivem"
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ Lua imports can be defined as part of fxmanifest, or loaded with the load functi
|
||||
|
||||
```lua
|
||||
client_scripts {
|
||||
'@ox_core/imports/client.lua',
|
||||
'client/main.lua',
|
||||
'@ox_core/imports/client.lua',
|
||||
'client/main.lua',
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'@ox_core/imports/server.lua',
|
||||
'server/main.lua',
|
||||
'@oxmysql/lib/MySQL.lua',
|
||||
'@ox_core/imports/server.lua',
|
||||
'server/main.lua',
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ import TabItem from '@theme/TabItem';
|
||||
|
||||
:::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.
|
||||
|
||||
:::
|
||||
|
||||
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).
|
||||
|
||||
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.
|
||||
- Execute the following commands
|
||||
|
||||
```
|
||||
```bash
|
||||
npm install --location=global pnpm
|
||||
git clone https://github.com/overextended/ox_core.git
|
||||
cd web
|
||||
@@ -72,7 +72,7 @@ Phone with many built-in apps such as Twitter, Marketplace, and Notes; with supp
|
||||
|
||||
### 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.
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### ox:licenseAdded
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
### ox:licenseAdded
|
||||
### ox:licenseRemoved
|
||||
|
||||
Triggered when a player's license is revoked.
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ player.set(key, value, replicated)
|
||||
|
||||
## 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`.
|
||||
|
||||
```lua
|
||||
@@ -77,7 +77,7 @@ Returns the player's current grade for a given group.
|
||||
player.getGroup()
|
||||
```
|
||||
|
||||
## player.getGroup
|
||||
## player.getGroups
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
```lua
|
||||
|
||||
@@ -12,4 +12,3 @@ lib.callback.await('ox:getNearbyVehicles', playerId, radius)
|
||||
|
||||
- playerId: `number`
|
||||
- radius?: `number`
|
||||
|
||||
@@ -27,7 +27,7 @@ end
|
||||
|
||||
## 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.
|
||||
|
||||
```lua
|
||||
@@ -43,8 +43,9 @@ if vehicleId then
|
||||
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.
|
||||
|
||||
```lua
|
||||
local vehicle = Ox.CreateVehicle({
|
||||
model = 'sultanrs',
|
||||
|
||||
@@ -86,7 +86,7 @@ vehicle.setGroup(group)
|
||||
|
||||
## 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.
|
||||
|
||||
```lua
|
||||
|
||||
@@ -6,6 +6,7 @@ Searches the inventory for an item, or list of items, with the result varying ba
|
||||
```lua
|
||||
exports.ox_inventory:Search(search, item, metadata)
|
||||
```
|
||||
|
||||
* search: `'slots'` or `'count'`
|
||||
* `'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
|
||||
|
||||
@@ -9,7 +9,7 @@ The following snippet can be used in crafting resources such as okokCrafting or
|
||||
```lua
|
||||
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
|
||||
end
|
||||
```
|
||||
```
|
||||
@@ -10,8 +10,8 @@ Returns whether the player's inventory is currently running an action (i.e. usin
|
||||
local isInventoryBusy = LocalPlayer.state.invBusy
|
||||
|
||||
if isInventoryBusy then
|
||||
-- Do stuff when busy
|
||||
-- Do stuff when busy
|
||||
else
|
||||
-- Do stuff when not busy
|
||||
-- Do stuff when not busy
|
||||
end
|
||||
```
|
||||
@@ -10,7 +10,7 @@ Returns whether the player's inventory is currently open or not.
|
||||
local isInventoryOpen = LocalPlayer.state.invOpen
|
||||
|
||||
if isInventoryOpen then
|
||||
-- Do stuff when open
|
||||
-- Do stuff when open
|
||||
else
|
||||
-- Do stuff when closed
|
||||
-- Do stuff when closed
|
||||
end
|
||||
@@ -5,4 +5,5 @@ Mostly used for weaponised vehicles, though could be called for "minigames"
|
||||
```lua
|
||||
local exports.ox_inventory:weaponWheel(state)
|
||||
```
|
||||
|
||||
* state: `boolean`
|
||||
@@ -3,6 +3,7 @@ Sets a metadata property to display in the tooltip.
|
||||
```lua
|
||||
exports.ox_inventory:displayMetadata(metadata, value)
|
||||
```
|
||||
|
||||
* metadata: `table` or `string`
|
||||
* 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.
|
||||
@@ -10,6 +11,7 @@ exports.ox_inventory:displayMetadata(metadata, value)
|
||||
* Label for the string metadata property to be displayed.
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
exports.ox_inventory:displayMetadata('mustard', 'Mustard')
|
||||
```
|
||||
|
||||
@@ -6,6 +6,7 @@ Opens an inventory using the passed data.
|
||||
```lua
|
||||
exports.ox_inventory:openInventory(invType, data)
|
||||
```
|
||||
|
||||
* invType: `string`
|
||||
* `'player'`
|
||||
* `'shop'`
|
||||
|
||||
@@ -3,6 +3,7 @@ Forces the secondary-inventory key to open the passed inventory. Can be useful t
|
||||
```lua
|
||||
exports.ox_inventory:setStashTarget(id, owner)
|
||||
```
|
||||
|
||||
* id: `string` or `number`
|
||||
* Stash id.
|
||||
* 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.).
|
||||
|
||||
```lua
|
||||
exports.ox_inventory:useItem(data, cb)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* cb?: `function`
|
||||
|
||||
|
||||
@@ -3,4 +3,5 @@ Uses the item in the given inventory slot.
|
||||
```lua
|
||||
exports.ox_inventory:useSlot(slot)
|
||||
```
|
||||
|
||||
* slot: `number`
|
||||
@@ -24,7 +24,7 @@ By returning `false`, you can cancel the action and revert the inventory state.
|
||||
- source: `number`
|
||||
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
|
||||
- fromInventory: `number` or `string`
|
||||
- toInventory:` number` or `string`
|
||||
- toInventory: `number` or `string`
|
||||
- fromType: `string`
|
||||
- toType: `string`
|
||||
- fromSlot: `table`
|
||||
|
||||
@@ -5,6 +5,7 @@ Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximu
|
||||
```lua
|
||||
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
||||
```
|
||||
|
||||
- inv: `table` or `string` or `number`
|
||||
- The inventory's unique id, or a table with the id and owner.
|
||||
- playerId: `1`
|
||||
|
||||
@@ -3,6 +3,7 @@ Returns the amount a player can hold based on available weight.
|
||||
```lua
|
||||
exports.ox_inventory:CanCarryAmount(inv, item)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* item: `table` or `string`
|
||||
* Can be array to check multiple items.
|
||||
|
||||
@@ -5,6 +5,7 @@ The function checks for inventory weight and available slots.
|
||||
```lua
|
||||
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* item `table` or `string`
|
||||
* 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.
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
-- Checks if the player calling the event can carry 3 water items
|
||||
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
|
||||
exports.ox_inventory:CanCarryWeight(inv, weight)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* weight: `number`
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Returns true if the item swap is possible based on inventory weight.
|
||||
```lua
|
||||
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* firstItem: `string`
|
||||
* firstItemCount: `number`
|
||||
|
||||
@@ -3,5 +3,6 @@ Clears the specified inventory. The `keep` argument is either a string or an arr
|
||||
```lua
|
||||
exports.ox_inventory:ClearInventory(inv, keep)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* keep?: `string` or `string[]`
|
||||
@@ -6,4 +6,5 @@ the player.
|
||||
```lua
|
||||
exports.ox_inventory:ConfiscateInventory(source)
|
||||
```
|
||||
|
||||
* source: `number`
|
||||
@@ -3,11 +3,14 @@ Takes traditional item data and updates it to support ox_inventory.
|
||||
```lua
|
||||
exports.ox_inventory:ConvertItems(playerId, items)
|
||||
```
|
||||
|
||||
* playerId: `number`
|
||||
* items: `table`
|
||||
|
||||
Data conversion example:
|
||||
```
|
||||
Old: [{"cola":1, "bread":3}]
|
||||
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
|
||||
|
||||
```lua
|
||||
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
|
||||
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
||||
```
|
||||
|
||||
* prefix: `string`
|
||||
* items: `table`
|
||||
* name: `string`
|
||||
|
||||
@@ -4,4 +4,5 @@ Returns the player's currently equipped weapon as a table.
|
||||
-- inv: string or number
|
||||
exports.ox_inventory:GetCurrentWeapon(inv)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
@@ -3,23 +3,25 @@ Returns the inventory associated with the ID (and owner if defined). Otherwise r
|
||||
```lua
|
||||
exports.ox_inventory:GetInventory(inv, owner)
|
||||
```
|
||||
|
||||
* inv: `number` or `table`
|
||||
* owner?: `string` or `boolean`
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
local inventory = exports.ox_inventory:GetInventory('example_stash', false)
|
||||
print(json.encode(inventory, {indent = true}))
|
||||
--[[
|
||||
{
|
||||
"id": "example_stash,
|
||||
"label": "Police Stash",
|
||||
"type": "stash,
|
||||
"slots": 50,
|
||||
"weight": 0,
|
||||
"maxWeight": 100000,
|
||||
"owner": false,
|
||||
...
|
||||
"id": "example_stash,
|
||||
"label": "Police Stash",
|
||||
"type": "stash,
|
||||
"slots": 50,
|
||||
"weight": 0,
|
||||
"maxWeight": 100000,
|
||||
"owner": false,
|
||||
...
|
||||
}
|
||||
]]
|
||||
```
|
||||
@@ -3,10 +3,12 @@ Returns all slots with items in a inventory.
|
||||
```lua
|
||||
exports.ox_inventory:GetInventoryItems(inv, owner)
|
||||
```
|
||||
|
||||
* inv: `number` or `table`
|
||||
* owner?: `string` or `boolean`
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
local playerItems = exports.ox_inventory:GetInventoryItems(source)
|
||||
```
|
||||
@@ -3,6 +3,7 @@ Returns the item from the specified inventory.
|
||||
```lua
|
||||
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* item: `table` or `string`
|
||||
* 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.
|
||||
|
||||
**Example**:
|
||||
|
||||
```lua
|
||||
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
|
||||
exports.ox_inventory:GetItemSlots(inv, item, metadata)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* item: `table` or `string`
|
||||
* metadata?: `table`
|
||||
@@ -4,24 +4,26 @@ Returns the specified slot data as a table.
|
||||
|
||||
exports.ox_inventory:GetSlot(inv, slot)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* slot: `number`
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
local slot = exports.ox_inventory:GetSlot(source, 1)
|
||||
|
||||
print(json.encode(slot, {indent=true}))
|
||||
--[[
|
||||
{
|
||||
"weight": 2000,
|
||||
"name": "water",
|
||||
"metadata": [],
|
||||
"slot": 1,
|
||||
"label": "Water",
|
||||
"close": true,
|
||||
"stack": true,
|
||||
"count: 4
|
||||
"weight": 2000,
|
||||
"name": "water",
|
||||
"metadata": [],
|
||||
"slot": 1,
|
||||
"label": "Water",
|
||||
"close": true,
|
||||
"stack": true,
|
||||
"count: 4
|
||||
}
|
||||
]]
|
||||
```
|
||||
@@ -3,6 +3,7 @@ Creates a new custom stash.
|
||||
```lua
|
||||
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
|
||||
```
|
||||
|
||||
* id: `string` or `number`
|
||||
* Stash identifier when loading from the database.
|
||||
* 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.
|
||||
* `nil`: Always shared.
|
||||
* groups: `table`
|
||||
* Table of player groups (jobs) able to access the stash.
|
||||
* Table of group names where the numeric value is the minimum grade required.
|
||||
* `{['police'] = 0, ['ambulance'] = 2}`
|
||||
* Table of player groups (jobs) able to access the stash.
|
||||
* Table of group names where the numeric value is the minimum grade required.
|
||||
* `{['police'] = 0, ['ambulance'] = 2}`
|
||||
* coords: `vector3`
|
||||
|
||||
:::caution
|
||||
|
||||
@@ -5,4 +5,5 @@ Use it alongside [ConfiscateInventory](./ConfiscateInventory.md).
|
||||
```lua
|
||||
exports.ox_inventory:ReturnInventory(source)
|
||||
```
|
||||
|
||||
* source: `number`
|
||||
@@ -1,9 +1,9 @@
|
||||
Searches an inventory for a specified item.
|
||||
|
||||
```lua
|
||||
|
||||
exports.ox_inventory:Search(inv, search, item, metadata)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* search: `string`
|
||||
* item: `table` or `string`
|
||||
|
||||
@@ -5,11 +5,13 @@ Can be used for repairing weapons.
|
||||
```lua
|
||||
exports.ox_inventory:SetDurability(inv, slot, durability)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* slot: `number`
|
||||
* durability: `number`
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
local ox_inventory = exports.ox_inventory
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ Sets metadata on the specified slot.
|
||||
```lua
|
||||
ox_inventory:SetMetadata(inv, slot, metadata)
|
||||
```
|
||||
|
||||
* inv: `string` or `number`
|
||||
* slot: `number`
|
||||
* metadata: `table`
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
local ox_inventory = exports.ox_inventory
|
||||
|
||||
@@ -18,6 +20,7 @@ for k, v in pairs(water) do
|
||||
water = v
|
||||
break
|
||||
end
|
||||
|
||||
water.metadata.type = 'clean'
|
||||
ox_inventory:SetMetadata(source, water.slot, water.metadata)
|
||||
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
|
||||
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
|
||||
```
|
||||
|
||||
* fromInventory: `any`
|
||||
* toInventory: `any`
|
||||
* slot1: `number`
|
||||
|
||||
@@ -11,10 +11,10 @@ local itemNames
|
||||
ESX.RegisterServerCallback('crafting:itemNames', function(source, cb)
|
||||
if not itemNames then
|
||||
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
|
||||
end
|
||||
end
|
||||
cb(itemNames)
|
||||
end)
|
||||
```
|
||||
```
|
||||
@@ -3,6 +3,7 @@ Creates and sets the player's inventory.
|
||||
```lua
|
||||
exports.ox_inventory:setPlayerInventory(player, data)
|
||||
```
|
||||
|
||||
* player: `table`
|
||||
* source: `number`
|
||||
* 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.
|
||||
|
||||
```yml
|
||||
```yaml
|
||||
# Activate specific event handlers and functions (supported: ox, esx, qb, nd)
|
||||
setr inventory:framework "esx"
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ The resources listed under here **aren't** necessary for the inventory to work b
|
||||
|
||||
### 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.
|
||||
|
||||
<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
|
||||
|
||||
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.
|
||||
The user interface included with the source code must be compiled.
|
||||
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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
```lua
|
||||
elseif shared.framework == 'myframework' then
|
||||
playerTable = 'characters' -- table storing player / character data
|
||||
playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id)
|
||||
vehicleTable = 'vehicles' -- table storing owned vehicle data
|
||||
vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id)
|
||||
end
|
||||
elseif shared.framework == 'myframework' then
|
||||
playerTable = 'characters' -- table storing player / character data
|
||||
playerColumn = 'charid' -- primary key for identifying the character (i.e. identifier, citizenid, id)
|
||||
vehicleTable = 'vehicles' -- table storing owned vehicle data
|
||||
vehicleColumn = 'id' -- primary key for identifying the vehicle (i.e. plate, vin, id)
|
||||
end
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
@@ -8,37 +8,37 @@ Crafting locations, items and their ingredients are defined in [data/crafting.lu
|
||||
|
||||
```lua
|
||||
{
|
||||
items = {
|
||||
{
|
||||
name = 'lockpick',
|
||||
ingredients = {
|
||||
garbage = 3,
|
||||
WEAPON_HAMMER = 0.1
|
||||
},
|
||||
duration = 5000,
|
||||
count = 3,
|
||||
metadata = { durability = 20 }
|
||||
items = {
|
||||
{
|
||||
name = 'lockpick',
|
||||
ingredients = {
|
||||
garbage = 3,
|
||||
WEAPON_HAMMER = 0.1
|
||||
},
|
||||
duration = 5000,
|
||||
count = 3,
|
||||
metadata = { durability = 20 }
|
||||
},
|
||||
{
|
||||
name = 'garbage',
|
||||
ingredients = {
|
||||
cola = 1
|
||||
},
|
||||
metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' }
|
||||
},
|
||||
},
|
||||
{
|
||||
name = 'garbage',
|
||||
ingredients = {
|
||||
cola = 1
|
||||
},
|
||||
metadata = { description = 'An empty soda can.', weight = 20, image = 'trash_can' }
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
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 },
|
||||
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
|
||||
set to 0 then the item is required but not consumed.
|
||||
* duration: `number`
|
||||
* Crafting duration in miliseconds.
|
||||
* Crafting duration in milliseconds.
|
||||
* count: `number`
|
||||
* Item amount recieved upon crafting.
|
||||
* Item amount received upon crafting.
|
||||
* metadata: `table`
|
||||
* Metadata applied to the item being crafted.
|
||||
* points: `vector3[]`
|
||||
|
||||
@@ -39,14 +39,14 @@ options for the item.
|
||||
* status?: `table`
|
||||
* Adjust esx_status values after use.
|
||||
* anim?: `table`
|
||||
* Animation that will be played during the progress bar.
|
||||
* dict: `string`
|
||||
* clip: `string`
|
||||
* Animation that will be played during the progress bar.
|
||||
* dict: `string`
|
||||
* clip: `string`
|
||||
* prop?: `table`
|
||||
* Attached prop that will be displayed during the progress bar.
|
||||
* model: `string` or `hash`
|
||||
* pos: `table` (x, y, z)
|
||||
* rot: `table` (x, y, z)
|
||||
* Attached prop that will be displayed during the progress bar.
|
||||
* model: `string` or `hash`
|
||||
* pos: `table` (x, y, z)
|
||||
* rot: `table` (x, y, z)
|
||||
* disable?: `table`
|
||||
* Actions to be disabled during the progress bar
|
||||
* move?: `boolean`
|
||||
@@ -57,11 +57,11 @@ options for the item.
|
||||
* cancel?: `boolean`
|
||||
* If set to true the player canc cancel item use.
|
||||
* add?: `function`(total: `number`)
|
||||
* Function that triggers when recieving an item
|
||||
* Function that triggers when receiving an item
|
||||
* Returns total item count as `total`
|
||||
* remove?: `function`(total: `number`)
|
||||
* Function that triggers when removing an item
|
||||
* Returns total item count as `total`
|
||||
* Function that triggers when removing an item
|
||||
* Returns total item count as `total`
|
||||
* buttons?: `table`
|
||||
* label: `string`
|
||||
* 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
|
||||
|
||||
- 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 ESX, you can continue using `ESX.RegisterUsableItem`.
|
||||
* 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.
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
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).
|
||||
@@ -72,10 +72,12 @@ Targets and model are only available when using a targeting resource like ox_tar
|
||||
## Register during runtime
|
||||
|
||||
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.
|
||||
- Must use "locations" and not "targets" to define each shop using the archetype.
|
||||
|
||||
**Example:**
|
||||
|
||||
```lua
|
||||
exports.ox_inventory:RegisterShop('TestShop', {
|
||||
name = 'Test shop',
|
||||
|
||||
@@ -34,6 +34,7 @@ Firstly, we need to define the stashes properties.
|
||||
## Example
|
||||
|
||||
Below the value is hardset, but it could be loaded from the database (especially if there are unknown fields, i.e. owner)
|
||||
|
||||
```lua
|
||||
-- Server
|
||||
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.
|
||||
|
||||
```lua
|
||||
-- Server
|
||||
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.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
|
||||
### lib.addAce
|
||||
|
||||
Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||
|
||||
<Tabs>
|
||||
@@ -16,6 +16,7 @@ lib.addAce(principal, ace, allow)
|
||||
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -26,25 +27,27 @@ lib.addAce(principal, ace, allow)
|
||||
|
||||
lib.addAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* allow: `boolean`
|
||||
|
||||
### lib.removeAce
|
||||
|
||||
Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
|
||||
```lua
|
||||
lib.removeAce(principal, ace, allow)
|
||||
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -55,14 +58,16 @@ lib.removeAce(principal, ace, allow)
|
||||
|
||||
lib.removeAce('group.admin', 'command.say')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* principal: `string`
|
||||
* ace: `string`
|
||||
* allow: `boolean`
|
||||
|
||||
### lib.addPrincipal
|
||||
|
||||
Assigns a principal to a parent principal. Children inherit permissions from the parent.
|
||||
|
||||
<Tabs>
|
||||
@@ -73,6 +78,7 @@ lib.addPrincipal(child, parent)
|
||||
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -83,14 +89,15 @@ lib.addPrincipal(child, parent)
|
||||
|
||||
lib.addPrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* child: `string`
|
||||
* parent: `string`
|
||||
|
||||
|
||||
### lib.removePrincipal
|
||||
|
||||
Removes a principal from a parent principal.
|
||||
|
||||
<Tabs>
|
||||
@@ -101,6 +108,7 @@ lib.removePrincipal(child, parent)
|
||||
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -111,9 +119,9 @@ lib.removePrincipal(child, parent)
|
||||
|
||||
lib.removePrincipal('player.1', 'group.moderator')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* child: `string`
|
||||
* parent: `string`
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
```lua
|
||||
lib.addCommand(principal, command, callback, parameters, help)
|
||||
```
|
||||
|
||||
* principal: `string` or `string[]` or `false`
|
||||
* command: `string`
|
||||
* callback: `function`
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
```lua
|
||||
lib.addKeybind(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* name: `string`
|
||||
* description: `string`
|
||||
@@ -27,7 +28,8 @@ local keybind = lib.addKeybind({
|
||||
```
|
||||
|
||||
Keybinds can be enabled/disabled by using the disable method.
|
||||
|
||||
```lua
|
||||
keybind:disable(true) -- disable
|
||||
keybind:disable(false) -- enable
|
||||
```
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Caches data related to the player and handling some events or statebags.
|
||||
Caches data related to the player and handling some events or statebags.
|
||||
An interval runs every 100ms to update data that cannot be checked via handlers.
|
||||
|
||||
## States
|
||||
|
||||
@@ -51,7 +51,7 @@ lib.callback.register(name, cb)
|
||||
|
||||
```lua
|
||||
lib.callback.register('ox:getNearbyVehicles', function(radius)
|
||||
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
||||
return nearbyVehicles
|
||||
local nearbyVehicles = lib.getNearbyVehicles(GetEntityCoords(cache.ped), radius, true)
|
||||
return nearbyVehicles
|
||||
end)
|
||||
```
|
||||
@@ -1,23 +1,31 @@
|
||||
### lib.disableControls
|
||||
|
||||
Call on frame to disable all stored keys.
|
||||
|
||||
```lua
|
||||
lib.disableControls()
|
||||
```
|
||||
|
||||
### lib.disableControls:Add
|
||||
|
||||
```lua
|
||||
lib.disableControls:Add(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
|
||||
### lib.disableControls:Remove
|
||||
|
||||
```lua
|
||||
lib.disableControls:Remove(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
|
||||
### lib.disableControls:Clear
|
||||
|
||||
```lua
|
||||
lib.disableControls:Clear(...)
|
||||
```
|
||||
|
||||
* vararg: `number`
|
||||
@@ -5,6 +5,7 @@ Get the id, ped, and coords of the closest player to a set of coordinates.
|
||||
```lua
|
||||
function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
@@ -13,6 +14,7 @@ function lib.getClosestPlayer(coords, maxDistance, includePlayer) end
|
||||
* Whether or not to include the current player.
|
||||
|
||||
Return:
|
||||
|
||||
* playerId?: `number`
|
||||
* playerPed?: `number`
|
||||
* playerCoords?: `vector3`
|
||||
@@ -14,5 +14,6 @@ function lib.getClosestVehicle(coords, maxDistance, includePlayerVehicle) end
|
||||
* Whether or not to include the player's current vehicle.
|
||||
|
||||
Return:
|
||||
|
||||
* vehicle?: `number`
|
||||
* vehicleCoords?: `vector3`
|
||||
@@ -5,6 +5,7 @@ Get the id, ped, and coords of all players within range of a set of coordinates.
|
||||
```lua
|
||||
function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
@@ -13,4 +14,5 @@ function lib.getNearbyPlayers(coords, maxDistance, includePlayer) end
|
||||
* Whether or not to include the current player.
|
||||
|
||||
Return:
|
||||
|
||||
* `number[]`
|
||||
@@ -5,6 +5,7 @@ Get the id and coords of all vehicles within range of a set of coordinates.
|
||||
```lua
|
||||
function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* The coords to check from.
|
||||
* maxDistance: `number`
|
||||
@@ -13,4 +14,5 @@ function lib.getNearbyVehicles(coords, maxDistance, includePlayerVehicle) end
|
||||
* Whether or not to include the player's current vehicle.
|
||||
|
||||
Return:
|
||||
|
||||
* `number[]`
|
||||
@@ -5,7 +5,7 @@ title: Alert Dialog
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Simple alert dialog that can display a message to the player.
|
||||
Simple alert dialog that can display a message to the player.
|
||||
Returns whether the player pressed the confirm button or canceled the dialog.
|
||||
|
||||
### lib.alertDialog
|
||||
@@ -16,6 +16,7 @@ Returns whether the player pressed the confirm button or canceled the dialog.
|
||||
```lua
|
||||
lib.alertDialog(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -28,6 +29,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.alertDialog(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -54,6 +56,7 @@ Force closes the active alert dialog and sets its return data as `nil`
|
||||
```lua
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -62,6 +65,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.closeAlertDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -80,6 +84,7 @@ local alert = lib.alertDialog({
|
||||
|
||||
print(alert)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -95,9 +100,8 @@ const alert = await lib.alertDialog({
|
||||
|
||||
console.log(alert)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
|
||||

|
||||
@@ -15,6 +15,7 @@ Sets the player's clipboard to the specified string value.
|
||||
```lua
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -23,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.setClipboard(value)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.registerContext
|
||||
|
||||
Used for registering a context menu.
|
||||
|
||||
<Tabs>
|
||||
@@ -14,6 +15,7 @@ Used for registering a context menu.
|
||||
```lua
|
||||
lib.registerContext(context)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.registerContext(context)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -54,7 +57,7 @@ lib.registerContext(context)
|
||||
* progress?: `number`
|
||||
* Adds a progress bar filled to this percentage
|
||||
* 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`
|
||||
* 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.
|
||||
@@ -74,12 +77,13 @@ lib.registerContext(context)
|
||||
You can register as many context menus in one `lib.registerContext` function
|
||||
as you'd like.
|
||||
|
||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
||||
The menu can be either in the order you write it in, or sorted alphabetically.
|
||||
To sort the menu alphabetically the buttons (and/or metadata) need to be defined as keys,
|
||||
otherwise not using keys and instead using tables will make the menu be in the order you
|
||||
define it as.
|
||||
|
||||
### lib.showContext
|
||||
|
||||
Opens a registered context menu by it's id.
|
||||
|
||||
<Tabs>
|
||||
@@ -88,6 +92,7 @@ Opens a registered context menu by it's id.
|
||||
```lua
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -96,12 +101,14 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.showContext(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
|
||||
### lib.hideContext
|
||||
|
||||
Hides any currently visible context menu.
|
||||
|
||||
<Tabs>
|
||||
@@ -110,6 +117,7 @@ Hides any currently visible context menu.
|
||||
```lua
|
||||
lib.hideContext(onExit)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -118,6 +126,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideContext(onExit)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -136,6 +145,7 @@ If no context menu is open returns `nil`.
|
||||
```lua
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -144,10 +154,12 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.getOpenContextMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Usage Example
|
||||
|
||||
First we register the menu with our specified options then we call the show function in the command.
|
||||
|
||||
:::tip
|
||||
@@ -204,9 +216,10 @@ lib.registerContext({
|
||||
|
||||
```lua
|
||||
RegisterCommand('testcontext', function()
|
||||
lib.showContext('example_menu')
|
||||
lib.showContext('example_menu')
|
||||
end)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -266,10 +279,10 @@ RegisterCommand('testcontext', () => {
|
||||
lib.showContext('example_menu')
|
||||
}, false)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
To trigger the event from the `Event button` and get it's data we first
|
||||
need to register the event properly:
|
||||
|
||||
@@ -296,6 +309,7 @@ RegisterNetEvent('some_event', function(data)
|
||||
lib.showContext('another_context_menu')
|
||||
end)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -319,6 +333,7 @@ onNet('some_event', () => {
|
||||
lib.showContext('another_context_menu');
|
||||
});
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</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.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
with the `lib.showContext` function, passing in the menu's id.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
@@ -16,6 +16,7 @@ by setting input fields.
|
||||
```lua
|
||||
lib.inputDialog(heading, rows)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -24,6 +25,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.inputDialog(heading, rows)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</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`.
|
||||
|
||||
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.
|
||||
|
||||
:::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
|
||||
you can define `options` **ONLY** with type `'select'`.
|
||||
|
||||
|
||||
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
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -100,6 +102,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.closeInputDialog()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -119,6 +122,7 @@ local lockerPasscode = input[2]
|
||||
|
||||
print(lockerNumber, lockerPasscode)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<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`.
|
||||
:::
|
||||
|
||||
|
||||
```ts
|
||||
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)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -149,19 +153,21 @@ console.log(lockerNumber, lockerPasscode)
|
||||
|
||||
```lua
|
||||
local input = lib.inputDialog('Police locker', {
|
||||
{ type = "input", label = "Locker number", placeholder = "123" },
|
||||
{ type = "checkbox", label = "Some checkbox" },
|
||||
{ type = "input", label = "Locker PIN", password = true, icon = 'lock' },
|
||||
{ type = "checkbox", label = "Some other checkbox", checked = true },
|
||||
{ type = 'select', label = 'Value select', options = {
|
||||
{ value = 'option1', label = 'Option 1' },
|
||||
{ value = 'option2', label = 'Option 2' },
|
||||
{ value = 'option3', label = 'Option 3'},
|
||||
}},
|
||||
{ type = "number", label = "Number counter", default = 12 }
|
||||
{ type = "input", label = "Locker number", placeholder = "123" },
|
||||
{ type = "checkbox", label = "Some checkbox" },
|
||||
{ type = "input", label = "Locker PIN", password = true, icon = 'lock' },
|
||||
{ type = "checkbox", label = "Some other checkbox", checked = true },
|
||||
{ type = 'select', label = 'Value select', options = {
|
||||
{ value = 'option1', label = 'Option 1' },
|
||||
{ value = 'option2', label = 'Option 2' },
|
||||
{ value = 'option3', label = 'Option 3'},
|
||||
}},
|
||||
{ type = "number", label = "Number counter", default = 12 }
|
||||
})
|
||||
|
||||
print(json.encode(input, {indent=true}))
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="JS/TS">
|
||||
|
||||
@@ -185,7 +191,8 @@ const input = await lib.inputDialog('Police locker', [
|
||||
]);
|
||||
|
||||
console.log(JSON.stringify(input, null, 2));
|
||||
```
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
||||
Keyboard navigation menu with specific event functions.
|
||||
|
||||
### lib.registerMenu
|
||||
|
||||
Registers and caches a menu under the specified id.
|
||||
|
||||
<Tabs>
|
||||
@@ -16,6 +17,7 @@ Registers and caches a menu under the specified id.
|
||||
```lua
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -24,6 +26,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.registerMenu(data, cb)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -37,7 +40,7 @@ lib.registerMenu(data, cb)
|
||||
* icon?: `string`
|
||||
* iconColor?: `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.
|
||||
* checked?: `boolean`
|
||||
* 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'`)
|
||||
* Function that runs when the menu is exited via ESC/Backspace.
|
||||
* onSelected: `function`(selected: `number`, secondary: `number` | `boolean`, args: {[key: `string`]: `any`})
|
||||
* Function being ran when the selected button in the menu changes.
|
||||
* Function being ran when the selected button in the menu changes.
|
||||
* onSideScroll: `function`(selected: `number`, scrollIndex: `number`, args: {[key: `string`]: `any`})
|
||||
* Function ran whenever a scroll list item is changed.
|
||||
* onCheck: `function`(selected: `number`, checked: `boolean`, args: {[key: `string`]: `any`})
|
||||
@@ -69,8 +72,8 @@ lib.registerMenu(data, cb)
|
||||
* Callback function when the menu item is pressed.
|
||||
|
||||
### lib.showMenu
|
||||
Displays the menu with the provided id.
|
||||
|
||||
Displays the menu with the provided id.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
@@ -78,6 +81,7 @@ Displays the menu with the provided id.
|
||||
```lua
|
||||
lib.showMenu(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -86,13 +90,12 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.showMenu(id)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* id: `string`
|
||||
|
||||
|
||||
|
||||
### lib.hideMenu
|
||||
|
||||
<Tabs>
|
||||
@@ -101,6 +104,7 @@ lib.showMenu(id)
|
||||
```lua
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -109,6 +113,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideMenu(onExit)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -116,6 +121,7 @@ lib.hideMenu(onExit)
|
||||
* If true runs the menu's `onClose` function.
|
||||
|
||||
### lib.getOpenMenu
|
||||
|
||||
Returns the id of the currently open menu.
|
||||
|
||||
<Tabs>
|
||||
@@ -124,6 +130,7 @@ Returns the id of the currently open menu.
|
||||
```lua
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -132,10 +139,10 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.getOpenMenu()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
### lib.setMenuOptions
|
||||
|
||||
<Tabs>
|
||||
@@ -144,6 +151,7 @@ lib.getOpenMenu()
|
||||
```lua
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -152,6 +160,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.setMenuOptions(id, options, index)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -170,6 +179,7 @@ Replaces the 3rd index option of the specified menu
|
||||
```lua
|
||||
lib.setMenuOptions('some_menu_id', {label = 'New option', icon = 'plus'}, 3)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<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)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 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
|
||||
Avoid constantly re-registering a menu that does not depend on any outside values (A.K.A a static menu).
|
||||
:::
|
||||
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
|
||||
@@ -240,6 +251,7 @@ RegisterCommand('testmenu', function()
|
||||
lib.showMenu('some_menu_id')
|
||||
end)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -293,6 +305,7 @@ RegisterCommand('testmenu', () => {
|
||||
lib.showMenu('some_menu_id')
|
||||
}, false)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## lib.notify
|
||||
|
||||
Custom notifications with a lot of styling options.
|
||||
|
||||
<Tabs>
|
||||
@@ -14,6 +15,7 @@ Custom notifications with a lot of styling options.
|
||||
```lua
|
||||
lib.notify(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -22,6 +24,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.notify(data)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -44,7 +47,7 @@ lib.notify(data)
|
||||
|
||||
### Usage Example
|
||||
|
||||
### Standard
|
||||
#### Standard
|
||||
|
||||
<Tabs>
|
||||
<TabItem value='Lua'>
|
||||
@@ -56,6 +59,7 @@ lib.notify({
|
||||
type = 'success'
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -68,12 +72,13 @@ lib.notify({
|
||||
type: 'success'
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

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

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

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

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

|
||||

|
||||
@@ -6,9 +6,10 @@ import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
## lib.showTextUI
|
||||
|
||||
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>
|
||||
<TabItem value='Lua'>
|
||||
@@ -16,6 +17,7 @@ Show the TextUI window.
|
||||
```lua
|
||||
lib.showTextUI(text, options)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -24,11 +26,12 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.showTextUI(text, options)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* text: `string`
|
||||
* options?: `table`
|
||||
* options?: `table`
|
||||
* position?: `'right-center'` or `'left-center'` or `'top-center'`
|
||||
* Default: `'right-center'`
|
||||
* icon?: `string` or `table` (`array`)
|
||||
@@ -45,6 +48,7 @@ lib.showTextUI(text, options)
|
||||
```lua
|
||||
lib.showTextUI('[E] - Fuel vehicle')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -53,10 +57,11 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.showTextUI('[E] - Fuel vehicle')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||

|
||||

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

|
||||
|
||||

|
||||
|
||||
### lib.hideTextUI
|
||||
|
||||
Hides the currently visible TextUI window
|
||||
|
||||
<Tabs>
|
||||
@@ -105,6 +112,7 @@ Hides the currently visible TextUI window
|
||||
```lua
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -113,7 +121,6 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.hideTextUI()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</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`
|
||||
|
||||
To change the preferred language from English, add the convar to your server.cfg
|
||||
```cfg
|
||||
|
||||
```yaml
|
||||
setr ox:locale en
|
||||
```
|
||||
|
||||
Initialise the locale module in your resource (once).
|
||||
|
||||
```lua
|
||||
lib.locale()
|
||||
```
|
||||
|
||||
Format your strings with the new locale global.
|
||||
|
||||
```lua
|
||||
locale(str, ...)
|
||||
```
|
||||
@@ -26,8 +29,8 @@ Additional arguments can be sent to format the locale output.
|
||||
lib.locale()
|
||||
|
||||
SetInterval(function()
|
||||
print(locale('grand_theft_auto'))
|
||||
print(locale('suspect_sex', locale('male')))
|
||||
print(locale('grand_theft_auto'))
|
||||
print(locale('suspect_sex', locale('male')))
|
||||
end, 5000)
|
||||
```
|
||||
|
||||
@@ -51,6 +54,6 @@ end, 5000)
|
||||
|
||||
```lua title="fxmanifest.lua"
|
||||
files {
|
||||
'locales/*.json'
|
||||
'locales/*.json'
|
||||
}
|
||||
```
|
||||
@@ -1,12 +1,14 @@
|
||||
## 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).
|
||||
|
||||
- datadoghq.com
|
||||
- us3.datadoghq.com
|
||||
- us5.datadoghq.com
|
||||
- datadoghq.eu
|
||||
```
|
||||
|
||||
```yaml
|
||||
set datadog:key "yourapikey"
|
||||
set datadog:site "datadoghq.com"
|
||||
```
|
||||
@@ -14,14 +16,14 @@ set datadog:site "datadoghq.com"
|
||||
```lua
|
||||
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.
|
||||
Event is passed to ddservice and displays in the logs list.
|
||||
Source is passed to `ddsource` and creates a tag. Could be playerId, identifier, -1, or server.
|
||||
Event is passed to `ddservice` and displays in the logs list.
|
||||
Additional arguments are converted into tags for additional filtering and search options.
|
||||
|
||||
```lua
|
||||
@@ -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.
|
||||
|
||||
[*] 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
|
||||
|
||||
Open your server.cfg and if you have previously used datadog logging, change the `ox:logger` tag to be loki if not add the following tags to your cfg.
|
||||
|
||||
```
|
||||
```yaml
|
||||
set ox:logger "loki"
|
||||
set loki:user "<insert your user>"
|
||||
set loki: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
|
||||
|
||||
```
|
||||
```yaml
|
||||
set ox:logger "loki"
|
||||
set loki:user "1337"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
lib.points.new(coords, distance, data)
|
||||
```
|
||||
|
||||
* coords: `vector3`
|
||||
* distance: `number`
|
||||
* data: `table`
|
||||
@@ -33,6 +34,7 @@ end
|
||||
```
|
||||
|
||||
Points can be deleted by using the remove method.
|
||||
|
||||
```lua
|
||||
point:remove()
|
||||
```
|
||||
@@ -5,12 +5,14 @@ Starts a shapetest originating from the camera, extending to ~10m.
|
||||
```lua
|
||||
function lib.raycast.cam(flags, p8) end
|
||||
```
|
||||
|
||||
* flags?: `number`
|
||||
* Defaults to 1|2|8|16 (see: https://docs.fivem.net/natives/?_0x377906D8A31E5586)
|
||||
* p8?: `number`
|
||||
* A bit mask with bits 1, 2, 4, or 7 relating to collider types. 4 and 7 are usually used.
|
||||
|
||||
Return:
|
||||
|
||||
* hit: `boolean`
|
||||
* entityHit: `number`
|
||||
* endCoords: `vector3`
|
||||
|
||||
@@ -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.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
@@ -12,6 +12,7 @@ import TabItem from '@theme/TabItem';
|
||||
```lua
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -20,6 +21,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestAnimDict(dict, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -27,7 +29,6 @@ lib.requestAnimDict(dict, timeout)
|
||||
* timeout: `number`
|
||||
* Default: `100`
|
||||
|
||||
|
||||
### lib.requestAnimSet
|
||||
|
||||
<Tabs>
|
||||
@@ -36,6 +37,7 @@ lib.requestAnimDict(dict, timeout)
|
||||
```lua
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -44,6 +46,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestAnimSet(set, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -59,6 +62,7 @@ lib.requestAnimSet(set, timeout)
|
||||
```lua
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -67,6 +71,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestModel(model, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -74,7 +79,6 @@ lib.requestModel(model, timeout)
|
||||
* timeout: `number`
|
||||
* Default: `100`
|
||||
|
||||
|
||||
### lib.requestStreamedTextureDict
|
||||
|
||||
<Tabs>
|
||||
@@ -83,6 +87,7 @@ lib.requestModel(model, timeout)
|
||||
```lua
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -91,6 +96,7 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestStreamedTextureDict(dict, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
@@ -98,7 +104,6 @@ lib.requestStreamedTextureDict(dict, timeout)
|
||||
* timeout: `number`
|
||||
* Default: `100`
|
||||
|
||||
|
||||
### lib.requestNamedPtfxAsset
|
||||
|
||||
<Tabs>
|
||||
@@ -106,8 +111,8 @@ lib.requestStreamedTextureDict(dict, timeout)
|
||||
|
||||
```lua
|
||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -116,10 +121,10 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.requestNamedPtfxAsset(fxName, timeout)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
* fxName: `string`
|
||||
* timeout: `number`
|
||||
* 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
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
@@ -6,10 +6,10 @@ import TabItem from '@theme/TabItem';
|
||||
|
||||
### lib.getVehicleProperties
|
||||
|
||||
|
||||
```ts
|
||||
lib.getVehicleProperties(vehicle)
|
||||
```
|
||||
|
||||
* vehicle: `entity`
|
||||
|
||||
<Tabs>
|
||||
@@ -18,6 +18,7 @@ lib.getVehicleProperties(vehicle)
|
||||
```lua
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -26,16 +27,18 @@ import lib from '@overextended/ox_lib/client'
|
||||
|
||||
lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
### lib.setVehicleProperties
|
||||
|
||||
Requires the vehicle to belong to the client. _Do not use NetworkRequestControlOfEntity_.
|
||||
|
||||
```lua
|
||||
lib.setVehicleProperties(vehicle, props)
|
||||
```
|
||||
|
||||
* vehicle: `entity`
|
||||
* props: `table` (`object`)
|
||||
|
||||
@@ -47,6 +50,7 @@ RegisterNetEvent('ox_lib:setVehicleProperties', function(netid, data)
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
end)
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -57,13 +61,14 @@ onNet('ox_lib:setVehicleProperties', (netid, data) => {
|
||||
lib.setVehicleProperties(NetToVeh(netid), data)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
|
||||
#### Recommended usage
|
||||
|
||||
The server should tell the owner of the entity to set properties, using the following trigger.
|
||||
|
||||
```lua
|
||||
TriggerClientEvent('ox_lib:setVehicleProperties', entityOwner, vehNetId, data)
|
||||
```
|
||||
@@ -1,5 +1,6 @@
|
||||
### lib.versionCheck
|
||||
Compares the resource version to the latest published release on GitHub.
|
||||
|
||||
Compares the resource version to the latest published release on GitHub.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
@@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
||||
```lua
|
||||
lib.versionCheck(repository)
|
||||
```
|
||||
|
||||
* repository: `string`
|
||||
|
||||
<Tabs>
|
||||
@@ -15,6 +17,7 @@ lib.versionCheck(repository)
|
||||
```lua
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -23,6 +26,7 @@ import lib from '@overextended/ox_lib/server'
|
||||
|
||||
lib.versionCheck('overextended/ox_lib')
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
### lib.checkDependency
|
||||
|
||||
Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
@@ -7,6 +8,7 @@ import TabItem from '@theme/TabItem';
|
||||
```lua
|
||||
lib.checkDependency(resource, version)
|
||||
```
|
||||
|
||||
* resource: `string`
|
||||
* version: `string`
|
||||
|
||||
@@ -16,6 +18,7 @@ lib.checkDependency(resource, version)
|
||||
```lua
|
||||
if not lib.checkDependency('ox_lib', '1.5.0') then error() end
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
@@ -25,7 +28,6 @@ import lib from '@overextended/ox_lib/shared'
|
||||
|
||||
if (!lib.checkDependency('ox_lib', '1.5.0')) error()
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
+18
-14
@@ -5,6 +5,7 @@ Faster alternative to PolyZone utilising [glm.polygon](https://github.com/gottfr
|
||||
```lua
|
||||
lib.zones.poly(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* points: `vector3[]`
|
||||
* All z values must match
|
||||
@@ -20,6 +21,7 @@ lib.zones.poly(data)
|
||||
```lua
|
||||
lib.zones.box(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* coords: `vector3`
|
||||
* size?: `vector3`
|
||||
@@ -36,6 +38,7 @@ lib.zones.box(data)
|
||||
```lua
|
||||
lib.zones.sphere(data)
|
||||
```
|
||||
|
||||
* data: `table`
|
||||
* coords: `vector3`
|
||||
* radius?: `number`
|
||||
@@ -75,11 +78,11 @@ local poly = lib.zones.poly({
|
||||
vec(420.0, -1030.2, 29),
|
||||
vec(409.8, -1028.4, 29),
|
||||
},
|
||||
thickness = 2,
|
||||
debug = true,
|
||||
inside = inside,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
thickness = 2,
|
||||
debug = true,
|
||||
inside = inside,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
})
|
||||
|
||||
local sphere = lib.zones.sphere({
|
||||
@@ -92,17 +95,18 @@ local sphere = lib.zones.sphere({
|
||||
})
|
||||
|
||||
local box = lib.zones.box({
|
||||
coords = vec3(442.5363, -1017.666, 28.65637),
|
||||
size = vec3(1, 1, 1),
|
||||
rotation = 45,
|
||||
debug = true,
|
||||
inside = insideZone,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
coords = vec3(442.5363, -1017.666, 28.65637),
|
||||
size = vec3(1, 1, 1),
|
||||
rotation = 45,
|
||||
debug = true,
|
||||
inside = insideZone,
|
||||
onEnter = onEnter,
|
||||
onExit = onExit
|
||||
})
|
||||
```
|
||||
|
||||
Zones can be deleted by using the remove method.
|
||||
|
||||
```lua
|
||||
poly:remove()
|
||||
sphere:remove()
|
||||
@@ -110,11 +114,11 @@ box:remove()
|
||||
```
|
||||
|
||||
## Zone creation script
|
||||
|
||||
Similarly to PolyZone, there is a zone creation script included.
|
||||
|
||||
To use it use the `/zone` with `poly`, `box` or `sphere` as args.
|
||||
|
||||
Available controls will be displayed on the right side.
|
||||
|
||||
Once saved you will find the created zone details in created_zones.lua 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.
|
||||
|
||||
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.
|
||||
|
||||
<Tabs>
|
||||
@@ -28,6 +28,7 @@ Or if the library is the only shared script you use you can do:
|
||||
```lua
|
||||
shared_script '@ox_lib/init.lua'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<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).
|
||||
|
||||
**Usage:**
|
||||
**Usage:**
|
||||
You can either import the whole library object which contains all the functions for that scope (client/server/shared) or
|
||||
you can deconstruct it and import the functions you find needed at the time.
|
||||
|
||||
@@ -50,25 +51,27 @@ import lib from '@overextended/ox_lib/server'
|
||||
```ts
|
||||
import { versionCheck } from '@overextended/ox_lib/server'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
**ACE Permissions:**
|
||||
```
|
||||
|
||||
```yaml
|
||||
add_ace resource.ox_lib command.add_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.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
|
||||
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 default icon type will be `solid`.
|
||||
the default icon type will be `solid`.
|
||||
If you want to use a different icon type, i.e
|
||||
apple as a brand, you need to define icon as a table (`array`) with the first value being
|
||||
the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name.
|
||||
@@ -79,23 +82,25 @@ the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon n
|
||||
```lua
|
||||
icon = {'fab', 'apple'}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value='JS/TS'>
|
||||
|
||||
```ts
|
||||
icon: ['fab', 'apple']
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
# Building the UI
|
||||
## Building the UI
|
||||
|
||||
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then
|
||||
compile it.
|
||||
|
||||
:::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:**
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ slug: ./../
|
||||
|
||||
We always recommend using Git so you can track changes and update easily.
|
||||
|
||||
```
|
||||
```bash
|
||||
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
|
||||
local options = {
|
||||
{
|
||||
{
|
||||
name = 'ox:option1',
|
||||
event = 'ox_target:debug',
|
||||
icon = 'fa-solid fa-road',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
```lua
|
||||
local options = {
|
||||
{
|
||||
{
|
||||
name = 'ox:option1',
|
||||
event = 'ox_target:debug',
|
||||
icon = 'fa-solid fa-road',
|
||||
@@ -42,7 +42,7 @@ exports.ox_target:removeModel(models, optionNames)
|
||||
|
||||
## 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.
|
||||
|
||||
```lua
|
||||
@@ -51,14 +51,13 @@ exports.ox_target:addEntity(netIds, options)
|
||||
|
||||
## 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.
|
||||
|
||||
```lua
|
||||
exports.ox_target:removeEntity(netIds, optionNames)
|
||||
```
|
||||
|
||||
|
||||
## addLocalEntity
|
||||
|
||||
Add new options when targeting a local entity or list of entities.
|
||||
|
||||
@@ -10,11 +10,11 @@ exports.ox_target:addSphereZone(parameters)
|
||||
|
||||
```lua
|
||||
{
|
||||
coords = vector3,
|
||||
radius = number,
|
||||
debug? = boolean,
|
||||
drawSprite? = boolean,
|
||||
options = options,
|
||||
coords = vector3,
|
||||
radius = number,
|
||||
debug? = boolean,
|
||||
drawSprite? = boolean,
|
||||
options = options,
|
||||
}
|
||||
```
|
||||
|
||||
@@ -49,12 +49,12 @@ exports.ox_target:addBoxZone(parameters)
|
||||
|
||||
```lua
|
||||
{
|
||||
coords = vector3,
|
||||
size = vector3,
|
||||
rotation = number,
|
||||
debug? = boolean,
|
||||
drawSprite? = boolean,
|
||||
options = options,
|
||||
coords = vector3,
|
||||
size = vector3,
|
||||
rotation = number,
|
||||
debug? = boolean,
|
||||
drawSprite? = boolean,
|
||||
options = options,
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -4,27 +4,27 @@ When calling exports to add options, the input is an array of tables with the fo
|
||||
|
||||
```lua
|
||||
{
|
||||
-- an identifier used when removing options
|
||||
name? = string,
|
||||
-- an icon from font-awesome
|
||||
icon? = string,
|
||||
-- display text
|
||||
label = string,
|
||||
-- range to display (default: 2, max: 7)
|
||||
distance? = number,
|
||||
-- a group, array of groups, or groups and grades needed to display
|
||||
groups? = string | string[] | { [string]: number }
|
||||
-- an item, array of items, or items and counts needed to display
|
||||
items? = string | string[] | { [string]: number }
|
||||
-- a bone, bones table to select specific parts
|
||||
bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' }
|
||||
-- custom check to hide or display the option
|
||||
canInteract? = function(entity, distance, coords, name, bone),
|
||||
-- triggered on option selection (one only)
|
||||
onSelect? = function(data),
|
||||
export? = string,
|
||||
event? = string,
|
||||
serverEvent? = string,
|
||||
command? = string
|
||||
-- an identifier used when removing options
|
||||
name? = string,
|
||||
-- an icon from font-awesome
|
||||
icon? = string,
|
||||
-- display text
|
||||
label = string,
|
||||
-- range to display (default: 2, max: 7)
|
||||
distance? = number,
|
||||
-- a group, array of groups, or groups and grades needed to display
|
||||
groups? = string | string[] | { [string]: number }
|
||||
-- an item, array of items, or items and counts needed to display
|
||||
items? = string | string[] | { [string]: number }
|
||||
-- a bone, bones table to select specific parts
|
||||
bones? = string | string[] -> example : 'bonnet' || { 'bonnet', 'boot' }
|
||||
-- custom check to hide or display the option
|
||||
canInteract? = function(entity, distance, coords, name, bone),
|
||||
-- triggered on option selection (one only)
|
||||
onSelect? = function(data),
|
||||
export? = string,
|
||||
event? = string,
|
||||
serverEvent? = string,
|
||||
command? = string
|
||||
}
|
||||
```
|
||||
@@ -1,16 +1,19 @@
|
||||
# Benchmark
|
||||
|
||||
Internal benchmark
|
||||
```
|
||||
|
||||
```md
|
||||
Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)
|
||||
```
|
||||
|
||||
Round-trip-time for exports
|
||||
```
|
||||
|
||||
```md
|
||||
Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries)
|
||||
```
|
||||
|
||||
#### Lua (5.4)
|
||||
## Lua (5.4)
|
||||
|
||||
```lua
|
||||
local val = 10000
|
||||
RegisterCommand('luasync', function()
|
||||
@@ -38,7 +41,8 @@ RegisterCommand('luasync', function()
|
||||
end)
|
||||
```
|
||||
|
||||
#### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```js
|
||||
const val = 10000
|
||||
RegisterCommand('jssync', async() => {
|
||||
@@ -60,4 +64,4 @@ RegisterCommand('jssync', async() => {
|
||||
console.log(result)
|
||||
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.
|
||||
|
||||
:::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.
|
||||
|
||||
:::
|
||||
|
||||
```
|
||||
```yaml
|
||||
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"
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
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_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.
|
||||
|
||||
```json
|
||||
```yaml
|
||||
set mysql_debug [
|
||||
"ox_core",
|
||||
"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.
|
||||
|
||||
```
|
||||
```yaml
|
||||
oxmysql_debug remove 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:
|
||||
|
||||
```json
|
||||
```yaml
|
||||
set mysql_ui true
|
||||
```
|
||||
|
||||
@@ -83,14 +81,14 @@ Also make sure that you have `command` ace permission access, then you should be
|
||||
|
||||
## 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.
|
||||
|
||||
### 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_.
|
||||
|
||||
### 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
|
||||
|
||||
### Unable to establish a connection
|
||||
|
||||
This is usually the result of incorrect database settings or your password containing reserved characters (`; , / ? : @ & = + $ #`).
|
||||
:::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.
|
||||
:::
|
||||
|
||||
### No such export ... in resource oxmysql
|
||||
|
||||
Typically the result of failing to follow instructions.
|
||||
:::tip Solution
|
||||
Download the latest release _build_ (not source) of oxmysql, and ensure it is starting before any resources that require it.
|
||||
:::
|
||||
|
||||
### 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))
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
```lua
|
||||
"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}
|
||||
|
||||
@@ -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).
|
||||
|
||||
```yaml
|
||||
```bash
|
||||
# With pnpm
|
||||
pnpm add @overextended/oxmysql
|
||||
|
||||
@@ -43,7 +43,7 @@ import { oxmysql as MySQL } from '@overextended/oxmysql';
|
||||
|
||||
## 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.
|
||||
|
||||
```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 })
|
||||
```
|
||||
|
||||
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.
|
||||
@@ -5,6 +5,7 @@ Inserts a new entry into the database and returns the insert id for the row, if
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:insert
|
||||
-- alias: MySQL.Async.insert
|
||||
@@ -15,6 +16,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:insert_async
|
||||
-- alias: MySQL.Sync.insert
|
||||
@@ -26,6 +28,7 @@ print(id)
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.insert
|
||||
|
||||
@@ -35,6 +38,7 @@ MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?,
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.insert_async
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# 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.
|
||||
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
|
||||
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.
|
||||
|
||||
- Date will not return the datestring commonly used in FiveM
|
||||
- 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.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:prepare
|
||||
-- alias: MySQL.Async.prepare
|
||||
@@ -24,6 +25,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:prepare_async
|
||||
-- alias: MySQL.Sync.prepare
|
||||
@@ -37,6 +39,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.prepare
|
||||
|
||||
@@ -48,6 +51,7 @@ MySQL.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (r
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.prepare_async
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# 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.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:query
|
||||
-- alias: MySQL.Async.query
|
||||
@@ -18,7 +20,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, func
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:query_async
|
||||
-- alias: MySQL.Sync.query
|
||||
@@ -35,6 +39,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.query
|
||||
|
||||
@@ -46,7 +51,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (res
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.query_async
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Scalar
|
||||
|
||||
Returns the first column for a single row.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:scalar
|
||||
-- alias: MySQL.Async.fetchScalar
|
||||
@@ -14,6 +16,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:scalar_async
|
||||
-- alias: MySQL.Sync.fetchScalar
|
||||
@@ -25,6 +28,7 @@ print(firstname)
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.scalar
|
||||
|
||||
@@ -34,6 +38,7 @@ MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifi
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.scalar_async
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Single
|
||||
|
||||
Returns the columns for a single row.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:single
|
||||
-- alias: MySQL.Async.fetchSingle
|
||||
@@ -16,6 +18,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:single_async
|
||||
-- alias: MySQL.Sync.fetchSingle
|
||||
@@ -29,6 +32,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.single
|
||||
|
||||
@@ -40,6 +44,7 @@ MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.single_async
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ console.log(success);
|
||||
|
||||
## 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.
|
||||
|
||||
### Lua
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Update
|
||||
|
||||
Returns the number of affected rows by the query.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:update
|
||||
-- alias: MySQL.Async.execute
|
||||
@@ -16,6 +18,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:update_async
|
||||
-- alias: MySQL.Sync.execute
|
||||
@@ -29,6 +32,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.update
|
||||
|
||||
@@ -40,6 +44,7 @@ MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, p
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.update_async
|
||||
|
||||
|
||||
Reference in new issue
Block a user