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

* refactor: Add h1 headers to all pages missing it

* refactor: missed example h3

* change hooks example heading to bold text

---------

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

No files matched your search

+19 -6
View File
@@ -1,10 +1,14 @@
# Client events
import { Callout } from 'nextra/components';
# Client
This is not a comprehensive list of events and is missing events intended for internal use only.
## Triggers
## Event Triggers
These events are safe to trigger and handle in other scripts.
<Callout type="info">
These events **are safe** to trigger and handle in other scripts.
</Callout>
### ox_inventory:disarm
@@ -14,14 +18,20 @@ Can be triggered to force the player to disarm.
TriggerClientEvent('ox_inventory:disarm', playerId, noAnim)
```
## Handlers
- playerId: `number`
- noAnim: `boolean`
- If `true`, disarm animation will be skipped
These events shouldn't be triggered by any other scripts.
## Event Handlers
<Callout type="warning">
These events **should not** be triggered by any other scripts.
</Callout>
### ox_inventory:updateInventory
Triggered after inventory slots have been updated, included on load.
Changes is a table containing all updated slot data indexed by slotId. Empty slots are "false".
Changes is a table containing all updated slot data indexed by slotId. Empty slots are `false`.
```lua
AddEventHandler('ox_inventory:updateInventory', function(changes) end)
@@ -47,3 +57,6 @@ _Note: Not available for ESX, use esx:addInventoryItem or esx:removeInventoryIte
```lua
AddEventHandler('ox_inventory:itemCount', function(itemName, totalCount) end)
```
- itemName: `string`
- totalCount: `number`
+7 -3
View File
@@ -1,10 +1,14 @@
# Server events
import { Callout } from 'nextra/components';
# Server
This is not a comprehensive list of events and is missing events intended for internal use only.
## Handlers
These events shouldn't be triggered by any other scripts.
<Callout type="warning">
These events **should not** be triggered by any other scripts.
</Callout>
### ox_inventory:openedInventory
@@ -22,5 +26,5 @@ AddEventHandler('ox_inventory:openedInventory', function(playerId, inventoryId)
Triggered after an inventory is closed by a player.
```lua
AddEventHandler('ox_inventory:closeInventory', function(playerId, inventoryId) end)
AddEventHandler('ox_inventory:closeInventory', function() end)
```
+27 -29
View File
@@ -4,6 +4,8 @@ title: ESX
import { Tabs, Tab } from 'nextra-theme-docs';
# ESX
## Compatibility
Ox Inventory is a complete replacement for existing item, inventory, and weapon systems; it is inherently incompatible with ESX and any resources that rely on default behaviour.
@@ -31,7 +33,7 @@ start ox_inventory
- Optionally, type `convertinventory esxproperty` into the server console.
- Restart the server once conversion is complete.
## Optional optimisation
## Optional Optimisation
All item related functions from xPlayer, such as `xPlayer.getInventoryItem`, have been modified for compatibility purposes; however they are considered deprecated.
@@ -40,35 +42,31 @@ The reasoning is fairly simple - there's now additional function references and
You should read through the functions section for further information, but the following should give you a decent idea.
<Tabs items={["ESX", "Ox Inventory"]}>
<Tab>
<Tab>
```lua
if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('antifreeze').count > 4 and xPlayer.getInventoryItem('sudo').count > 9 then
xPlayer.removeInventoryItem("acetone", 3)
xPlayer.removeInventoryItem("antifreeze", 5)
xPlayer.removeInventoryItem("sudo", 10)
end
```
</Tab>
<Tab>
Add the following code somewhere in your resource to cache the exports metatable.
```lua
if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('antifreeze').count > 4 and xPlayer.getInventoryItem('sudo').count > 9 then
xPlayer.removeInventoryItem("acetone", 3)
xPlayer.removeInventoryItem("antifreeze", 5)
xPlayer.removeInventoryItem("sudo", 10)
end
```
```lua
local ox_inventory = exports.ox_inventory
```
</Tab>
<Tab>
You will be able to reference any functions exposed through the export.
Add the following code somewhere in your resource to cache the exports metatable.
```lua
local ox_inventory = exports.ox_inventory
```
You will be able to reference any functions exposed through the export.
```lua
local items = ox_inventory:Search(source, 'count', {'acetone', 'antifreeze', 'sudo'})
if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'acetone', 3)
ox_inventory:RemoveItem(source, 'antifreeze', 5)
ox_inventory:RemoveItem(source, 'sudo', 10)
end
```
</Tab>
```lua
local items = ox_inventory:Search(source, 'count', {'acetone', 'antifreeze', 'sudo'})
if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'acetone', 3)
ox_inventory:RemoveItem(source, 'antifreeze', 5)
ox_inventory:RemoveItem(source, 'sudo', 10)
end
```
</Tab>
</Tabs>
+31 -35
View File
@@ -5,10 +5,10 @@ title: QBCore
import { Callout } from 'nextra/components';
import { Tabs, Tab } from 'nextra-theme-docs';
# QBCore
<Callout type="warning">
QBCore support is experimental and cannot work as a "drag and drop" solution due to many incompatibilities.
QBCore support is experimental and cannot work as a "drag and drop" solution due to many incompatibilities.
</Callout>
## Compatibility
@@ -43,7 +43,7 @@ If you have existing player data, you will need to convert it to a compatible fo
- Start the server and type `convertinventory qb` into the server console.
- Restart the server once conversion is complete.
## Optional optimisation
## Optional Optimisation
All item related functions from Player, such as `Player.Functions.GetItemByName`, have been modified for compatibility purposes; however they are considered deprecated.
@@ -52,38 +52,34 @@ The reasoning is fairly simple - there's now additional function references and
You should read through the functions section for further information, but the following should give you a decent idea.
<Tabs items={["QBCore", "Ox Inventory"]}>
<Tab>
<Tab>
```lua
local acetone = Player.Functions.GetItemByName('acetone')
local antifreeze = Player.Functions.GetItemByName('antifreeze')
local sudo = Player.Functions.GetItemByName('sudo')
if acetone?.amount > 2 and antifreeze?.amount > 4 and sudo?.amount > 9 then
Player.Functions.RemoveItem("acetone", 3)
Player.Functions.RemoveItem("antifreeze", 5)
Player.Functions.RemoveItem("sudo", 10)
end
```
</Tab>
<Tab>
Add the following code somewhere in your resource to cache the exports metatable.
```lua
local acetone = Player.Functions.GetItemByName('acetone')
local antifreeze = Player.Functions.GetItemByName('antifreeze')
local sudo = Player.Functions.GetItemByName('sudo')
if acetone?.amount > 2 and antifreeze?.amount > 4 and sudo?.amount > 9 then
Player.Functions.RemoveItem("acetone", 3)
Player.Functions.RemoveItem("antifreeze", 5)
Player.Functions.RemoveItem("sudo", 10)
end
```
```lua
local ox_inventory = exports.ox_inventory
```
</Tab>
<Tab>
You will be able to reference any functions exposed through the export.
Add the following code somewhere in your resource to cache the exports metatable.
```lua
local ox_inventory = exports.ox_inventory
```
You will be able to reference any functions exposed through the export.
```lua
local items = ox_inventory:Search(source, 'count', {'acetone', 'antifreeze', 'sudo'})
if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'acetone', 3)
ox_inventory:RemoveItem(source, 'antifreeze', 5)
ox_inventory:RemoveItem(source, 'sudo', 10)
end
```
</Tab>
```lua
local items = ox_inventory:Search(source, 'count', {'acetone', 'antifreeze', 'sudo'})
if items and items.acetone > 2 and items.antifreeze > 4 and items.sudo > 9 then
ox_inventory:RemoveItem(source, 'acetone', 3)
ox_inventory:RemoveItem(source, 'antifreeze', 5)
ox_inventory:RemoveItem(source, 'sudo', 10)
end
```
</Tab>
</Tabs>
+96 -94
View File
@@ -1,5 +1,7 @@
import { Tabs, Tab } from 'nextra-theme-docs';
# Client
## openInventory
Opens an inventory using the passed data.
@@ -20,46 +22,42 @@ exports.ox_inventory:openInventory(invType, data)
- `'dumpster'`
- data: `number` or `string` or `table`
### Examples
<Tabs items={['Player', 'Shop', 'Stash']}>
<Tab>
<Tab>
Open the target player's inventory.
**Open the target player's inventory.**
```lua
exports.ox_inventory:openInventory('player', 3)
```
</Tab>
<Tab>
Open the fourth "General Store" [location](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua#L14).
```lua
exports.ox_inventory:openInventory('player', 3)
```
```lua
exports.ox_inventory:openInventory('shop', { type = 'General', id = 4 })
```
</Tab>
<Tab>
Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).
</Tab>
<Tab>
```lua
exports.ox_inventory:openInventory('stash', 1)
```
**Open the fourth "General Store" [location](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua#L14).**
Open a custom stash (created on the server with RegisterStash).
```lua
exports.ox_inventory:openInventory('shop', { type = 'General', id = 4 })
```
```lua
exports.ox_inventory:openInventory('stash', 'society_police')
```
</Tab>
<Tab>
Open a stash with a specific owner.
**Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).**
```lua
exports.ox_inventory:openInventory('stash', 1)
```
**Open a custom stash (created on the server with RegisterStash).**
```lua
exports.ox_inventory:openInventory('stash', 'society_police')
```
**Open a stash with a specific owner.**
```lua
exports.ox_inventory:openInventory('stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
```
</Tab>
```lua
exports.ox_inventory:openInventory('stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
```
</Tab>
</Tabs>
## openNearbyInventory
@@ -157,7 +155,7 @@ exports.ox_inventory:setStashTarget(id, owner)
- Stash id.
- owner?: `string` or `number`
**Example:**
### Example
```lua
exports.ox_inventory:setStashTarget('motel5', 'bobsmith')
@@ -208,7 +206,7 @@ exports.ox_inventory:displayMetadata(metadata, value)
- value?: `string`
- Label for the string metadata property to be displayed.
**Example:**
### Example
```lua
exports.ox_inventory:displayMetadata('mustard', 'Mustard')
@@ -250,68 +248,64 @@ exports.ox_inventory:Search(search, item, metadata)
- metadata?: `table` or `string`
- If metadata is provided as a string it will search the item's `metadata.type` property.
**Count**
### Count
<Tabs items={["Single item", "Multiple items"]}>
<Tab>
<Tab>
```lua
local count = exports.ox_inventory:Search('count', 'water')
print('You have '..count.. ' water')
```
</Tab>
<Tab>
```lua
local inventory = exports.ox_inventory:Search('count', {'meat', 'skin'}, {grade="1"})
```lua
local count = exports.ox_inventory:Search('count', 'water')
print('You have '..count.. ' water')
```
</Tab>
<Tab>
```lua
local inventory = exports.ox_inventory:Search('count', {'meat', 'skin'}, {grade="1"})
if inventory then
for name, count in pairs(inventory) do
print('You have '..count..' '..name)
if inventory then
for name, count in pairs(inventory) do
print('You have '..count..' '..name)
end
end
end
```
</Tab>
```
</Tab>
</Tabs>
**Slots**
### Slots
<Tabs items={["Single item", "Multiple items"]}>
<Tab>
<Tab>
```lua
local water = exports.ox_inventory:Search('slots', 'water')
local count = 0
```lua
local water = exports.ox_inventory:Search('slots', 'water')
local count = 0
for _, v in pairs(water) do
print(v.slot..' contains '..v.count..' water '..json.encode(v.metadata))
count = count + v.count
end
print('You have '..count..' water')
```
</Tab>
<Tab>
```lua
local items = exports.ox_inventory:Search('slots', {'meat', 'skin'}, 'deer')
if items then
for name, data in pairs(items) do
local count = 0
for _, v in pairs(data) do
if v.slot then
print(v.slot..' contains '..v.count..' '..name..' '..json.encode(v.metadata))
count = count + v.count
end
end
print('You have '..count..' '..name)
for _, v in pairs(water) do
print(v.slot..' contains '..v.count..' water '..json.encode(v.metadata))
count = count + v.count
end
end
```
</Tab>
print('You have '..count..' water')
```
</Tab>
<Tab>
```lua
local items = exports.ox_inventory:Search('slots', {'meat', 'skin'}, 'deer')
if items then
for name, data in pairs(items) do
local count = 0
for _, v in pairs(data) do
if v.slot then
print(v.slot..' contains '..v.count..' '..name..' '..json.encode(v.metadata))
count = count + v.count
end
end
print('You have '..count..' '..name)
end
end
```
</Tab>
</Tabs>
## GetItemCount
@@ -327,7 +321,8 @@ exports.ox_inventory:GetItemCount(itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number`
Return:
- count: `number`
## GetPlayerItems
@@ -337,7 +332,8 @@ Get all items in the player's inventory.
exports.ox_inventory:GetPlayerItems()
```
**Returns:** `table`
Return:
- items: `table`
## GetPlayerWeight
@@ -347,7 +343,8 @@ Get the total weight of all items in the player's inventory.
exports.ox_inventory:GetPlayerWeight()
```
**Returns:** `number`
Return:
- totalWeight: `number`
## GetPlayerMaxWeight
@@ -357,7 +354,8 @@ Get the maximum carry weight of the player's inventory.
exports.ox_inventory:GetPlayerMaxWeight()
```
**Returns:** `number`
Return:
- maxWeight: `number`
## GetSlotIdWithItem
@@ -372,7 +370,8 @@ exports.ox_inventory:GetSlotIdWithItem(itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number?`
Return:
- slotId: `number?`
## GetSlotsIdWithItem
@@ -387,7 +386,8 @@ exports.ox_inventory:GetSlotIdsWithItem(itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number[]?`
Return:
- slotIds: `number[]?`
## GetSlotWithItem
@@ -402,7 +402,8 @@ exports.ox_inventory:GetSlotWithItem(itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table?`
Return:
- slotData: `table?`
## GetSlotsWithItem
@@ -417,7 +418,8 @@ exports.ox_inventory:GetSlotsWithItem(itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table[]?`
Return:
- slotsData: `table[]?`
## Statebags
@@ -438,7 +440,7 @@ else
end
```
**Disable opening inventory**
#### Disable opening inventory
```lua
LocalPlayer.state.invBusy = true
+68 -70
View File
@@ -1,6 +1,8 @@
import { Tabs, Tab } from 'nextra-theme-docs';
import { Callout } from 'nextra/components';
# Server
## setPlayerInventory
Creates and sets the player's inventory.
@@ -40,44 +42,35 @@ exports.ox_inventory:forceOpenInventory(playerId, invType, data)
- data: `number` or `string` or `table`
<Tabs items={["Player", "Stash"]}>
<Tab>
<Tab>
Open the target player's inventory.
**Open the target player's inventory.**
```lua
exports.ox_inventory:forceOpenInventory(1, 'player', 3)
```
```lua
exports.ox_inventory:forceOpenInventory(1, 'player', 3)
```
Admin command to open a player's inventory.
**Admin command to open a player's inventory.**
```lua
RegisterCommand('openplayerinv', function(source, args)
exports.ox_inventory:forceOpenInventory(source, 'player', tonumber(args[1]))
end, true)
```
</Tab>
<Tab>
```lua
RegisterCommand('openplayerinv', function(source, args)
exports.ox_inventory:forceOpenInventory(source, 'player', tonumber(args[1]))
end, true)
```
Open a custom stash (created on the server with RegisterStash).
</Tab>
<Tab>
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', 'society_police')
```
**Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).**
Open a stash with a specific owner.
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', 'apartment420')
```
**Open a custom stash (created on the server with RegisterStash).**
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', 'society_police')
```
**Open a stash with a specific owner.**
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
```
</Tab>
```lua
exports.ox_inventory:forceOpenInventory(1, 'stash', { id = 'police_locker', owner = 'license:xxxxxxxx' })
```
</Tab>
</Tabs>
## UpdateVehicle
@@ -103,6 +96,7 @@ The following snippet can be used in crafting resources such as okokCrafting or
```lua
local itemNames
ESX.RegisterServerCallback('crafting:itemNames', function(source, cb)
if not itemNames then
itemNames = {}
@@ -118,7 +112,7 @@ end)
Adds an item into the specified inventory.
Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximum weight may be exceeded.
Should be used alongside [CanCarryItem](#cancarryitem) otherwise, the maximum weight may be exceeded.
```lua
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
@@ -143,7 +137,13 @@ If used for glovebox, trunk or stash you must first check the inventory is loade
Returns `success, response` if cb is undefined, otherwise they are used in the callback only.
**Example:**
**Possible value of the "response" argument, on failure:**
- "invalid_item": the item doesn't exist
- "invalid_inventory": the inventory doesn't exist
- "inventory_full": no free slots
### Example
```lua
local success, response = exports.ox_inventory:AddItem('gloveVGH283', 'bread', 4)
@@ -168,12 +168,6 @@ print(json.encode(response, {indent=true}))
]]
```
**Possible value of the "response" argument, on failure:**
- "invalid_item": the item doesn't exist
- "invalid_inventory": the inventory doesn't exist
- "inventory_full": no free slots
## RemoveItem
Removes the specified item from the specified inventory.
@@ -205,7 +199,7 @@ Returns success: `boolean`, response: `string?`.
- "invalid_inventory": the inventory doesn't exist
- "not_enough_items": inventory did not contain enough of the given item
**Example:**
### Example
```lua
-- Removes 2 water from the glovebox for the given plate.
@@ -232,7 +226,7 @@ how many times the item was found.
Otherwise returns the data related to the item _and_ its total count found in the inventory.
**Example**:
### Example
```lua
local item = ox_inventory:GetItem(source, 'water', nil, false)
@@ -287,7 +281,7 @@ exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
- metadata?: `table` or `string`
- If metadata is passed as string then `metadata.type` will be checked.
**Example:**
### Example
```lua
-- Checks if the player calling the event can carry 3 water items
@@ -310,7 +304,7 @@ exports.ox_inventory:CanCarryAmount(inv, item)
- item: `table` or `string`
- Can be array to check multiple items.
Example:
### Example
```lua
-- Checks how much you can carry
@@ -359,7 +353,7 @@ exports.ox_inventory:SetMaxWeight(inv, maxWeight)
- inv: `table` or `string` or `number`
- maxWeight: `number`
**Example:**
### Example
```lua
local ox_inventory = exports.ox_inventory
@@ -396,7 +390,8 @@ exports.ox_inventory:GetItemCount(inv, itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number`
Return:
- itemCount: `number`
## GetItemSlots
@@ -422,7 +417,7 @@ exports.ox_inventory:GetSlot(inv, slot)
- inv: `table` or `string` or `number`
- slot: `number`
**Example:**
### Example
```lua
local slot = exports.ox_inventory:GetSlot(source, 1)
@@ -454,11 +449,12 @@ exports.ox_inventory:GetSlotForItem(inv, itemName, metadata)
- itemName: `string`
- metadata: `table?`
**Returns:** `number?`
Return:
- slotId: `number?`
## GetSlotIdWithItem
Get a slot id in an inventory matching the given name and metadata.
Get a slot id in an inventory matching the given item name and metadata.
```lua
exports.ox_inventory:GetSlotIdWithItem(inv, itemName, metadata, strict)
@@ -470,7 +466,8 @@ exports.ox_inventory:GetSlotIdWithItem(inv, itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number?`
Return:
- slotId: `number?`
## GetSlotIdsWithItem
@@ -486,7 +483,8 @@ exports.ox_inventory:GetSlotIdsWithItem(inv, itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `number[]?`
Return:
- slotIds: `number[]?`
## GetSlotWithItem
@@ -502,7 +500,8 @@ exports.ox_inventory:GetSlotWithItem(inv, itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table?`
Return:
- slotData: `table?`
## GetSlotsWithItem
@@ -518,7 +517,8 @@ exports.ox_inventory:GetSlotsWithItem(inv, itemName, metadata, strict)
- strict?: `boolean`
- Strictly match metadata properties, otherwise use partial matching.
**Returns:** `table[]?`
Return:
- slotsData: `table[]?`
## GetEmptySlot
@@ -530,7 +530,8 @@ exports.ox_inventory:GetEmptySlot(inv)
- inv: `table` or `string` or `number`
**Returns:** `number?`
Return:
- slotId: `number?`
## GetContainerFromSlot
@@ -543,7 +544,8 @@ exports.ox_inventory:GetContainerFromSlot(inv, slotId)
- inv: `table` or `string` or `number`
- slotId: `number`
**Returns:** `table?`
Return:
- containerData: `table?`
## SetSlotCount
@@ -556,7 +558,7 @@ exports.ox_inventory:SetSlotCount(inv, slots)
- inv: `table` or `string` or `number`
- slots: `number`
**Example:**
### Example
```lua
local ox_inventory = exports.ox_inventory
@@ -576,7 +578,7 @@ exports.ox_inventory:GetInventory(inv, owner)
- inv: `number` or `table`
- owner?: `string` or `boolean`
**Example:**
### Example
```lua
local inventory = exports.ox_inventory:GetInventory('example_stash', false)
@@ -606,7 +608,7 @@ exports.ox_inventory:GetInventoryItems(inv, owner)
- inv: `number` or `table`
- owner?: `string` or `boolean`
**Example:**
### Example
```lua
local playerItems = exports.ox_inventory:GetInventoryItems(source)
@@ -616,7 +618,7 @@ local playerItems = exports.ox_inventory:GetInventoryItems(source)
Clears a player's inventory and saves it to a stash.
Use [ReturnInventory](./Server/#returninventory) to return the confiscated inventory back to
Use [ReturnInventory](#returninventory) to return the confiscated inventory back to
the player.
```lua
@@ -629,7 +631,7 @@ exports.ox_inventory:ConfiscateInventory(source)
Returns the confiscated inventory back to the player.
Use it alongside [ConfiscateInventory](./Server/#confiscateinventory.md).
Use it alongside [ConfiscateInventory](#confiscateinventory).
```lua
exports.ox_inventory:ReturnInventory(source)
@@ -702,14 +704,12 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c
- coords?: `vector3` or `vector3[]`
<Callout>
This function needs to be triggered before a player can open the stash.
This function needs to be triggered before a player can open the stash.
</Callout>
**Example:**
### Example
For a use case example on this function check out the written [Guide](../../../Guides/stashes.md) for it.
For a use case example on this function check out the written [Guide](../Guides/stashes) for it.
## CreateTemporaryStash
@@ -736,10 +736,9 @@ exports.ox_inventory:CreateTemporaryStash(properties)
- An array of tables, containing a sequence of itemName, count, metadata.
Return:
- inventoryId: `string`
**Example**
### Example
```lua
local mystash = exports.ox_inventory:CreateTemporaryStash({
@@ -800,10 +799,9 @@ exports.ox_inventory:CreateDropFromPlayer(playerId)
- playerId: `number`
Return:
- dropId: `string`
**Example**
### Example
```lua
local dropId = exports.ox_inventory:CreateDropFromPlayer(1)
@@ -834,7 +832,7 @@ exports.ox_inventory:SetDurability(inv, slot, durability)
- slot: `number`
- durability: `number`
**Example:**
### Example
```lua
local ox_inventory = exports.ox_inventory
@@ -862,7 +860,7 @@ ox_inventory:SetMetadata(inv, slot, metadata)
- slot: `number`
- metadata: `table`
**Example:**
### Example
```lua
local ox_inventory = exports.ox_inventory
+62 -66
View File
@@ -1,4 +1,4 @@
# Event Hooks
# Hooks
Event hooks allow 3rd party resources to define new behaviour without modifying the inventory code directly.
@@ -29,19 +29,20 @@ Return:
Triggered when moving any item from one slot to another, or when "giving" an item.
By returning `false`, you can cancel the action and revert the inventory state.
**Payload:**
- Payload: `table`
- source: `number`
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
- fromInventory: `table` or `string` or `number`
- toInventory: `table` or `string` or `number`
- fromType: `string`
- toType: `string`
- fromSlot: `table`
- toSlot?: `table` or `number`
- count: `number`
- source: `number`
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
- fromInventory: `table` or `string` or `number`
- toInventory: `table` or `string` or `number`
- fromType: `string`
- toType: `string`
- fromSlot: `table`
- toSlot?: `table` or `number`
- count: `number`
**Example**
**Example:**
Blacklists "water" from being moved into or from gloveboxes and trunks.
```lua
local hookId = exports.ox_inventory:registerHook('swapItems', function(payload)
@@ -59,20 +60,19 @@ end, {
})
```
Blacklists "water" from being moved into or from gloveboxes and trunks.
openInventory
### openInventory
**Payload:**
- source: `number`
- inventoryId: `number` or `string`
- inventoryType: `string`
- Payload: `table`
- source: `number`
- inventoryId: `number` or `string`
- inventoryType: `string`
Triggered when a player tries to open a secondary inventory.
By returning `false`, you can cancel the action and keep the player's inventory closed.
**Example:**
**Example**
Disables gloveboxes and trunks.
```lua
local hookId = exports.ox_inventory:registerHook('openInventory', function(payload)
@@ -87,21 +87,20 @@ end, {
})
```
Disables gloveboxes and trunks.
### createItem
**Payload:**
- inventoryId?: `number` or `string`
- metadata: `table`
- item: `table`
- count: `number`
- Payload: `table`
- inventoryId?: `number` or `string`
- metadata: `table`
- item: `table`
- count: `number`
Triggered when an item is created, either by buying it, using AddItem, or when converting inventory data.
By returning a table you can modify or replace the metadata given to an item.
**Example:**
**Example**
Sets the label for "water" to "Mineral Water".
```lua
local hookId = exports.ox_inventory:registerHook('createItem', function(payload)
@@ -117,26 +116,26 @@ end, {
})
```
Sets the label for "water" to "Mineral Water".
### buyItem
**Payload:**
- source: `number`
- shopType: `string`
- shopId: `number`
- toInventory: `number`
- toSlot: `number`
- itemName: `string`
- metadata: `table`
- count: `number`
- price: `number`
- totalPrice: `number`
- currency?: `string`
- Payload: `table`
- source: `number`
- shopType: `string`
- shopId: `number`
- toInventory: `number`
- toSlot: `number`
- itemName: `string`
- metadata: `table`
- count: `number`
- price: `number`
- totalPrice: `number`
- currency?: `string`
Triggered when an item is about to be purchased and can return `false` to prevent the transaction.
**Example:**
**Example**
Prevents players from purchasing items at General stores.
```lua
local hookId = exports.ox_inventory:registerHook('buyItem', function(payload)
@@ -151,26 +150,25 @@ end, {
```
Prevents players from purchasing items at General stores.
### craftItem
**Payload:**
- Payload: `table`
- source: `number`
- benchId: `number`
- benchIndex: `number`
- recipe: `table`
- count: `number`
- duration: `number`
- ingredients: `table<string, number>`
- name: `string`
- slot: `number`
- weight: `number`
- toInventory: `number`
- toSlot: `number`
- source: `number`
- benchId: `number`
- benchIndex: `number`
- recipe: `table`
- count: `number`
- duration: `number`
- ingredients: `table<string, number>`
- name: `string`
- slot: `number`
- weight: `number`
- toInventory: `number`
- toSlot: `number`
**Example**
**Example:**
Prevent lockpicks from being crafted by players.
```lua
local hookId = exports.ox_inventory:registerHook('craftItem', function(payload)
@@ -185,15 +183,13 @@ end, {
```
Prevent lockpicks from being crafted by players.
## removeHooks
Removes a hook created by the invoking resource with the the specified id.
If no id is specified then all hooks registered by the resource are removed.
```lua
exports.ox_inventory:removeHooks(id)
```
- id?: `number`
Removes a hook created by the invoking resource with the the specified id.
If no id is specified then all hooks registered by the resource are removed.
+2
View File
@@ -2,6 +2,8 @@
title: Crafting
---
# Crafting
Crafting locations, items and their ingredients are defined in [data/crafting.lua](https://github.com/overextended/ox_inventory/blob/main/data/crafting.lua).
## Crafting definition
+133 -140
View File
@@ -1,152 +1,147 @@
---
title: Creating items
title: Creating Items
---
import { Tabs, Tab } from 'nextra-theme-docs';
# Creating Items
## Defining item data
Before being able to see or use an item in game it **must** first be defined.
All of the items are defined in the `/data/items.lua` file with key, value pairs.
All of the items are defined in the [/data/items.lua](https://github.com/overextended/ox_inventory/blob/main/data/items.lua) file with key, value pairs.
Key is the name (not the label) of an item and the value is a table containing the
options for the item.
**Item options:**
- label: `string`
- weight?: `number`
- stack?: `boolean`
- If set to false will not allow the item to be stacked.
- degrade?: `number`
- Amount of time in minutes the item will degrade after.
- decay?: `boolean`
- If true the item will be deleted when durability reaches 0 (not instant for degraded items).
- close?: `boolean`
- If set to false does not close the inventory on item use.
- description?: `string`
- Item description that will be shown in the tooltip
- consume?: `number`
- Item count needed and removed use.
- Default: 1
- If set to a decimal will consume durability instead (0.2 = 20%).
- allowArmed?: `boolean`
- If set to true will allow use of item while armed with a weapon.
- server?: `table`
- export?: `string`
- client?: `table`
- export?: `string`
- Export to be triggered after item use.
- event?: `string`
- Event to be triggered after item use.
- status?: `table`
- Adjust esx_status values after use.
- anim?: `table`
- 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)
- disable?: `table`
- Actions to be disabled during the progress bar
- move?: `boolean`
- car?: `boolean`
- combat?: `boolean`
- mouse?: `boolean`
- usetime?: `number`
- cancel?: `boolean`
- If set to true the player canc cancel item use.
- add?: `function`(total: `number`)
- 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`
- buttons?: `table`
- Item options: `table`
- label: `string`
- action: `function`(slot: `number`)
- Callback function when button is clicked in context menu, returns item slot.
- weight?: `number`
- stack?: `boolean`
- If set to false will not allow the item to be stacked.
- degrade?: `number`
- Amount of time in minutes the item will degrade after.
- decay?: `boolean`
- If true the item will be deleted when durability reaches 0 (not instant for degraded items).
- close?: `boolean`
- If set to false does not close the inventory on item use.
- description?: `string`
- Item description that will be shown in the tooltip
- consume?: `number`
- Item count needed and removed use.
- Default: 1
- If set to a decimal will consume durability instead (0.2 = 20%).
- allowArmed?: `boolean`
- If set to true will allow use of item while armed with a weapon.
- server?: `table`
- export?: `string`
- client?: `table`
- export?: `string`
- Export to be triggered after item use.
- event?: `string`
- Event to be triggered after item use.
- status?: `table`
- Adjust esx_status values after use.
- anim?: `table`
- 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)
- disable?: `table`
- Actions to be disabled during the progress bar
- move?: `boolean`
- car?: `boolean`
- combat?: `boolean`
- mouse?: `boolean`
- usetime?: `number`
- cancel?: `boolean`
- If set to true the player canc cancel item use.
- add?: `function`(total: `number`)
- 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`
- buttons?: `table`
- label: `string`
- action: `function`(slot: `number`)
- Callback function when button is clicked in context menu, returns item slot.
**Examples:**
### Examples
<Tabs items={["Burger", "Burger with description", "Burger with notification"]}>
<Tab>
```lua
['burger'] = {
label = 'Burger',
weight = 220,
stack = true,
close = true,
client = {
status = { hunger = 200000 },
anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },
prop = {
model = 'prop_cs_burger_01',
pos = { x = 0.02, y = 0.02, y = -0.02},
rot = { x = 0.0, y = 0.0, y = 0.0}
},
usetime = 2500,
<Tab>
```lua
['burger'] = {
label = 'Burger',
weight = 220,
stack = true,
close = true,
client = {
status = { hunger = 200000 },
anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },
prop = {
model = 'prop_cs_burger_01',
pos = { x = 0.02, y = 0.02, y = -0.02},
rot = { x = 0.0, y = 0.0, y = 0.0}
},
usetime = 2500,
}
}
}
```
```
</Tab>
<Tab>
A modified burger item which includes a description.
</Tab>
<Tab>
A modified burger item which includes a description.
```lua
['burger'] = {
label = 'Burger',
description = 'Just what is the secret formula?'
weight = 220,
stack = true,
close = true,
client = {
status = { hunger = 200000 },
anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },
prop = {
model = 'prop_cs_burger_01',
pos = { x = 0.02, y = 0.02, y = -0.02},
rot = { x = 0.0, y = 0.0, y = 0.0}
},
usetime = 2500,
```lua
['burger'] = {
label = 'Burger',
description = 'Just what is the secret formula?'
weight = 220,
stack = true,
close = true,
client = {
status = { hunger = 200000 },
anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },
prop = {
model = 'prop_cs_burger_01',
pos = { x = 0.02, y = 0.02, y = -0.02},
rot = { x = 0.0, y = 0.0, y = 0.0}
},
usetime = 2500,
}
}
}
```
```
</Tab>
<Tab>
A modified burger item, which gives you notifications on add and remove arguments.
</Tab>
<Tab>
```lua
['burger'] = {
label = 'Burger',
weight = 220,
stack = true,
consume = 0,
client = {
add = function(total)
if total > 0 then
lib.notify({description = 'Nice burger you got there!'})
end
end,
A modified burger item, which gives you notifications on add and remove arguments.
```lua
['burger'] = {
label = 'Burger',
weight = 220,
stack = true,
consume = 0,
client = {
add = function(total)
if total > 0 then
lib.notify({description = 'Nice burger you got there!'})
remove = function(total)
if total < 1 then
lib.notify({description = 'You lost all of your burgers!'})
end
end
end,
remove = function(total)
if total < 1 then
lib.notify({description = 'You lost all of your burgers!'})
end
end
}
}
}
```
</Tab>
```
</Tab>
</Tabs>
## Making the item usable
@@ -229,18 +224,6 @@ end)
Like with other items the item must first be registered.
**Example:**
```lua
['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},
```
When registered you can define the item as a container in `/modules/items/containers.lua`
The key for the container is the `name` you gave it when registering the item.
You can also define the number of slots, the maximum weight, blacklist and whitelist items.
@@ -257,9 +240,19 @@ You can also define the number of slots, the maximum weight, blacklist and white
- Supports single and multiple items
- `{ 'testburger', 'testburger2' }`
**Example:**
### Example
```lua
```lua filename="Register Example"
['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},
```
```lua filename="Properties Example"
setContainerProperties('paperbag', {
slots = 5,
maxWeight = 1000,
+4 -2
View File
@@ -1,7 +1,9 @@
---
title: Creating shops
title: Creating Shops
---
# Creating Shops
Builtin shops are defined in [data/shops.lua](https://github.com/overextended/ox_inventory/blob/main/data/shops.lua), and more can be added here to benefit from the built-in markers or zones support.
## Shop definition
@@ -84,7 +86,7 @@ Shops can be added using `exports.ox_inventory:RegisterShop` on the server, howe
- Blips, markers, and zones will not be created.
- Must use "locations" and not "targets" to define each shop using the archetype.
**Example:**
### Example
```lua
exports.ox_inventory:RegisterShop('TestShop', {
+6 -4
View File
@@ -1,14 +1,16 @@
---
title: Custom stashes
title: Custom Stashes
---
import { GhButton } from '@components/button';
# Custom Stashes
We can set up custom stashes from outside the resource utilising the exported RegisterStash function.
Firstly, we need to define the stashes properties.
### Stash properties
## Stash properties
- id: `string`
- Unique name to identify the stash in the database.
@@ -81,8 +83,8 @@ if ox_inventory:openInventory('stash', property.id) == false then
end
```
## Example resource
## Example Resource
We put together an example resource showcasing how to properly utilise the stash API:
<GhButton link="https://www.github.com/overextended/ox_inventory_examples" />
<GhButton link="https://www.github.com/overextended/ox_inventory_examples" label="Ox Inventory Examples" />
+3 -1
View File
@@ -1,7 +1,9 @@
---
title: Common issues
title: Common Issues
---
# Common Issues
## UI has not been built
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.