formatting and typos

This commit is contained in:
DokaDoka committed 2022-12-11 15:00:43 +11:00
1 parent 75698216e0
commit 724c7e356d
99 files changed
+515 -305

No files matched your search

@@ -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
+2 -2
View File
@@ -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`
+1 -1
View File
@@ -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`
+2 -2
View File
@@ -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`
+1 -1
View File
@@ -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"
+9 -9
View File
@@ -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.
+4 -4
View File
@@ -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.
+31 -31
View File
@@ -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[]`
+12 -12
View File
@@ -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.
+1 -1
View File
@@ -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).
+2
View File
@@ -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',
+2
View File
@@ -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