mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
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:
1 parent
74227cc262
commit
1d2c490b26
95 files changed
+2167
-2289
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
Reference in new issue
Block a user