mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
Merge pull request #70 from overextended/inventory-crafting
Inventory crafting
This commit is contained in:
32 files changed
+308
-228
No files matched your search
@@ -4,17 +4,16 @@ import TabItem from '@theme/TabItem';
|
|||||||
Searches the inventory for an item, or list of items, with the result varying based on the first argument.
|
Searches the inventory for an item, or list of items, with the result varying based on the first argument.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- search: string
|
|
||||||
-- item: table or string
|
|
||||||
-- metadata: table or string (optional)
|
|
||||||
exports.ox_inventory:Search(search, item, metadata)
|
exports.ox_inventory:Search(search, item, metadata)
|
||||||
```
|
```
|
||||||
|
* search: `'slots'` or `'count'`
|
||||||
If the `search` argument is defined as `'slots'` the return will be a table
|
* `'slots'` returns a table of slots where the item was found at.
|
||||||
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
|
||||||
|
returns key-value pairs of itemName = count.
|
||||||
Otherwise if the `search` argument is defined as `'count'` the return value
|
* item: `table` or `string`
|
||||||
will be the amount of the specified item in player's inventory.
|
* Can be a single item name or array of item names.
|
||||||
|
* metadata?: `table` or `string`
|
||||||
|
* If metadata is provided as a string it will search the item's `metadata.type` property.
|
||||||
|
|
||||||
### Count
|
### Count
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ Enables the weapon wheel, but disables the use of inventory items.
|
|||||||
Mostly used for weaponised vehicles, though could be called for "minigames"
|
Mostly used for weaponised vehicles, though could be called for "minigames"
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- state: boolean
|
|
||||||
local exports.ox_inventory:weaponWheel(state)
|
local exports.ox_inventory:weaponWheel(state)
|
||||||
```
|
```
|
||||||
|
* state: `boolean`
|
||||||
@@ -1,18 +1,13 @@
|
|||||||
Sets a metadata property to display in the tooltip.
|
Sets a metadata property to display in the tooltip.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- metadata: table or string
|
|
||||||
-- value: string (optional)
|
|
||||||
exports.ox_inventory:displayMetadata(metadata, value)
|
exports.ox_inventory:displayMetadata(metadata, value)
|
||||||
```
|
```
|
||||||
|
* metadata: `table` or `string`
|
||||||
`metadata` can either be table or string, if it's a string it's the metadata property
|
* If metadata is a string then it's the metadata property you want to display, value is **not** optional then.
|
||||||
that 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.
|
||||||
|
* value?: `string`
|
||||||
`value` represents the _label_ for the property you want to display.
|
* Label for the string metadata property to be displayed.
|
||||||
|
|
||||||
Otherwise `metadata` can be a table of key value pairs, key being the metadata property
|
|
||||||
and value being the label for that metadata.
|
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
@@ -24,4 +19,4 @@ exports.ox_inventory:displayMetadata({
|
|||||||
mustard = 'Mustard',
|
mustard = 'Mustard',
|
||||||
ketchup = 'Ketchup'
|
ketchup = 'Ketchup'
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
@@ -1,13 +1,22 @@
|
|||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
Opens an inventory using on the passed data.
|
Opens an inventory using the passed data.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- invType: string
|
|
||||||
-- data: number | string | table
|
|
||||||
exports.ox_inventory:openInventory(invType, data)
|
exports.ox_inventory:openInventory(invType, data)
|
||||||
```
|
```
|
||||||
|
* invType: `string`
|
||||||
|
* `'player'`
|
||||||
|
* `'shop'`
|
||||||
|
* `'stash'`
|
||||||
|
* `'crafting'`
|
||||||
|
* `'container'`
|
||||||
|
* `'drop'`
|
||||||
|
* `'glovebox'`
|
||||||
|
* `'trunk'`
|
||||||
|
* `'dumpster'`
|
||||||
|
* data: `number` or `string` or `table`
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<TabItem value="1" label="Player">
|
<TabItem value="1" label="Player">
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
Forces the secondary-inventory key to open the passed inventory. Can be useful to enable inventory access while standing inside a marker.
|
Forces the secondary-inventory key to open the passed inventory. Can be useful to enable inventory access while standing inside a marker.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string or number
|
|
||||||
-- owner: string or number (optional)
|
|
||||||
exports.ox_inventory:setStashTarget(id, owner)
|
exports.ox_inventory:setStashTarget(id, owner)
|
||||||
|
```
|
||||||
|
* id: `string` or `number`
|
||||||
|
* Stash id.
|
||||||
|
* owner?: `string` or `number`
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```lua
|
||||||
exports.ox_inventory:setStashTarget('motel5', 'bobsmith')
|
exports.ox_inventory:setStashTarget('motel5', 'bobsmith')
|
||||||
```
|
```
|
||||||
@@ -2,10 +2,10 @@ Uses the passed item, then triggers the callback function.
|
|||||||
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
|
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- data: table
|
|
||||||
-- cb: function (optional)
|
|
||||||
exports.ox_inventory:useItem(data, cb)
|
exports.ox_inventory:useItem(data, cb)
|
||||||
```
|
```
|
||||||
|
* data: `table`
|
||||||
|
* cb?: `function`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
exports('bandage', function(data, slot)
|
exports('bandage', function(data, slot)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Uses the item in the given inventory slot.
|
Uses the item in the given inventory slot.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- slot: number
|
|
||||||
exports.ox_inventory:useSlot(slot)
|
exports.ox_inventory:useSlot(slot)
|
||||||
```
|
```
|
||||||
|
* slot: `number`
|
||||||
@@ -5,7 +5,6 @@ Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximu
|
|||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
||||||
```
|
```
|
||||||
|
|
||||||
- inv: `table` or `string` or `number`
|
- inv: `table` or `string` or `number`
|
||||||
- The inventory's unique id, or a table with the id and owner.
|
- The inventory's unique id, or a table with the id and owner.
|
||||||
- playerId: `1`
|
- playerId: `1`
|
||||||
@@ -21,6 +20,8 @@ exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
|
|||||||
- A specific slot to add the item to. If the slot is invalid, the first available slot will be used instead.
|
- A specific slot to add the item to. If the slot is invalid, the first available slot will be used instead.
|
||||||
- cb?: function(success: `boolean`, response?: `string`)
|
- cb?: function(success: `boolean`, response?: `string`)
|
||||||
|
|
||||||
|
If used for glovebox, trunk or stash you must first check the inventory is loaded with [GetInventory](./GetInventory.md)
|
||||||
|
|
||||||
Returns `success, response` if cb is undefined, otherwise they are used in the callback only.
|
Returns `success, response` if cb is undefined, otherwise they are used in the callback only.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
Returns the amount a player can hold based on available weight.
|
Returns the amount a player can hold based on available weight.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param inv string | number
|
|
||||||
---@param item table | string
|
|
||||||
exports.ox_inventory:CanCarryAmount(inv, item)
|
exports.ox_inventory:CanCarryAmount(inv, item)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* item: `table` or `string`
|
||||||
|
* Can be array to check multiple items.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ Returns true or false depending if the inventory can carry the specified item.
|
|||||||
The function checks for inventory weight and available slots.
|
The function checks for inventory weight and available slots.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- item: table or string
|
|
||||||
-- count: number
|
|
||||||
-- metadata: table or string (optional)
|
|
||||||
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* item `table` or `string`
|
||||||
|
* Can be array of items.
|
||||||
|
* count: `number`
|
||||||
|
* metadata?: `table` or `string`
|
||||||
|
* If metadata is passed as string then `metadata.type` will be checked.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
@@ -18,4 +20,4 @@ if exports.ox_inventory:CanCarryItem(source, 'water', 3) then
|
|||||||
else
|
else
|
||||||
-- Do stuff if can't carry
|
-- Do stuff if can't carry
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
Returns true if the item swap is possible based on inventory weight.
|
Returns true if the item swap is possible based on inventory weight.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- firstItem: string
|
|
||||||
-- firstItemCount: number
|
|
||||||
-- testItem: string
|
|
||||||
-- testItemCount: number
|
|
||||||
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
|
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* firstItem: `string`
|
||||||
|
* firstItemCount: `number`
|
||||||
|
* testItem: `string`
|
||||||
|
* testItemCount: `number`
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
Clears the specified inventory. The `keep` argument is either a string or an array of strings containing the name(s) of the item(s) to keep in the inventory after clearing.
|
Clears the specified inventory. The `keep` argument is either a string or an array of strings containing the name(s) of the item(s) to keep in the inventory after clearing.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- keep:? string or string[]
|
|
||||||
exports.ox_inventory:ClearInventory(inv, keep)
|
exports.ox_inventory:ClearInventory(inv, keep)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* keep?: `string` or `string[]`
|
||||||
@@ -4,6 +4,6 @@ Use [ReturnInventory](./ReturnInventory.md) to return the confiscated inventory
|
|||||||
the player.
|
the player.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- source: number
|
|
||||||
exports.ox_inventory:ConfiscateInventory(source)
|
exports.ox_inventory:ConfiscateInventory(source)
|
||||||
```
|
```
|
||||||
|
* source: `number`
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
Takes traditional item data and updates it to support ox_inventory.
|
Takes traditional item data and updates it to support ox_inventory.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- playerId: number
|
|
||||||
-- items: table
|
|
||||||
exports.ox_inventory:ConvertItems(playerId, items)
|
exports.ox_inventory:ConvertItems(playerId, items)
|
||||||
```
|
```
|
||||||
|
* playerId: `number`
|
||||||
|
* items: `table`
|
||||||
|
|
||||||
Data conversion example:
|
Data conversion example:
|
||||||
```
|
```
|
||||||
Old: [{"cola":1, "bread":3}]
|
Old: [{"cola":1, "bread":3}]
|
||||||
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
|
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
|
||||||
```
|
```
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
Drops can be created from other resources, containing a variety of items and utilising a custom label (instead of 'Drop 32648').
|
Drops can be created from other resources, containing a variety of items and utilising a custom label (instead of 'Drop 32648').
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- prefix: string
|
|
||||||
-- items: table
|
|
||||||
-- name: string
|
|
||||||
-- count: number
|
|
||||||
-- metadata: table (optional)
|
|
||||||
-- coords: vector3
|
|
||||||
-- slots: number (optional)
|
|
||||||
-- maxWeight: number (optional)
|
|
||||||
-- instance: string | number (optional)
|
|
||||||
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
|
||||||
```
|
```
|
||||||
|
* prefix: `string`
|
||||||
|
* items: `table`
|
||||||
|
* name: `string`
|
||||||
|
* count: `number`
|
||||||
|
* metadata?: `table`
|
||||||
|
* coords: `vector3`
|
||||||
|
* slots?: `number`
|
||||||
|
* maxWeight?: `number`
|
||||||
|
* instance?: `string` or `number`
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
exports.ox_inventory:CustomDrop('Carcass', {
|
exports.ox_inventory:CustomDrop('Carcass', {
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ Returns the player's currently equipped weapon as a table.
|
|||||||
-- inv: string or number
|
-- inv: string or number
|
||||||
exports.ox_inventory:GetCurrentWeapon(inv)
|
exports.ox_inventory:GetCurrentWeapon(inv)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
+8
-6
@@ -1,12 +1,14 @@
|
|||||||
Returns the inventory associated with the ID (and owner if defined). Otherwise returns null
|
Returns the inventory associated with the ID (and owner if defined). Otherwise returns null.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
---@param id number | table
|
exports.ox_inventory:GetInventory(inv, owner)
|
||||||
---@param owner string | boolean (optional)
|
|
||||||
exports.ox_inventory:Inventory(id, owner)
|
|
||||||
```
|
```
|
||||||
Example:
|
* inv: `number` or `table`
|
||||||
|
* owner?: `string` or `boolean`
|
||||||
|
|
||||||
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
local inventory = exports.ox_inventory:Inventory('example_stash', false)
|
local inventory = exports.ox_inventory:GetInventory('example_stash', false)
|
||||||
print(json.encode(inventory, {indent = true}))
|
print(json.encode(inventory, {indent = true}))
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,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)
|
||||||
|
```
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
Returns the item from the specified inventory.
|
Returns the item from the specified inventory.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- item: table or string
|
|
||||||
-- metadata: any (optional)
|
|
||||||
-- returnsCount: boolean (optional)
|
|
||||||
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
|
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* item: `table` or `string`
|
||||||
|
* Can be items array.
|
||||||
|
* metadata?: `any`
|
||||||
|
* returnsCount?: `boolean`
|
||||||
|
|
||||||
If `returnsCount` is set to true, the returned value will be the `count` based on
|
If `returnsCount` is set to true, the returned value will be the `count` based on
|
||||||
how many times the item was found.
|
how many times the item was found.
|
||||||
@@ -29,4 +30,4 @@ print(json.encode(item, {indent=true}))
|
|||||||
"close": true
|
"close": true
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
```
|
```
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
Returns the number of slots the specified item is in, the item's total count and the remaining empty slots.
|
Returns the number of slots the specified item is in, the item's total count and the remaining empty slots.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- item: table or string
|
|
||||||
-- metadata: table (optional)
|
|
||||||
exports.ox_inventory:GetItemSlots(inv, item, metadata)
|
exports.ox_inventory:GetItemSlots(inv, item, metadata)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* item: `table` or `string`
|
||||||
|
* metadata?: `table`
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
Returns the specified slot data as a table.
|
Returns the specified slot data as a table.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- slot: number
|
|
||||||
exports.ox_inventory:GetSlot(inv, slot)
|
exports.ox_inventory:GetSlot(inv, slot)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* slot: `number`
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
@@ -23,4 +24,4 @@ print(json.encode(slot, {indent=true}))
|
|||||||
"count: 4
|
"count: 4
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
```
|
```
|
||||||
@@ -1,25 +1,23 @@
|
|||||||
Creates a new custom stash.
|
Creates a new custom stash.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- id: string or number
|
|
||||||
-- label: string
|
|
||||||
-- slots: number
|
|
||||||
-- maxWeight: number
|
|
||||||
-- owner: string or boolean or nil
|
|
||||||
-- groups: table
|
|
||||||
-- coords: vector3
|
|
||||||
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
|
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
|
||||||
```
|
```
|
||||||
|
* id: `string` or `number`
|
||||||
* `id` - Stash identifier when loading from the database.
|
* Stash identifier when loading from the database.
|
||||||
* `label` - Display name when inventory is open.
|
* label: `string`
|
||||||
* `owner` - Defines stash permissions.
|
* Display name when inventory is open.
|
||||||
* `string`: Can only access the stash linked to the owner.
|
* slots: `number`
|
||||||
* `true`: Each player has a unique stash but can request other player's stashes.
|
* maxWeight: `number`
|
||||||
* `nil`: Always shared.
|
* owner: `string` or `boolean` or `nil`
|
||||||
* `groups` - Player groups (jobs) able to access the stash.
|
* `string`: Can only access the stash linked to the owner.
|
||||||
|
* `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.
|
* Table of group names where the numeric value is the minimum grade required.
|
||||||
* `{['police'] = 0, ['ambulance'] = 2}`
|
* `{['police'] = 0, ['ambulance'] = 2}`
|
||||||
|
* coords: `vector3`
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
||||||
@@ -28,4 +26,4 @@ This function needs to be triggered before a player can open the stash.
|
|||||||
|
|
||||||
**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.md) for it.
|
||||||
@@ -3,6 +3,6 @@ Returns the confiscated inventory back to the player.
|
|||||||
Use it alongside [ConfiscateInventory](./ConfiscateInventory.md).
|
Use it alongside [ConfiscateInventory](./ConfiscateInventory.md).
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- source: number
|
|
||||||
exports.ox_inventory:ReturnInventory(source)
|
exports.ox_inventory:ReturnInventory(source)
|
||||||
```
|
```
|
||||||
|
* source: `number`
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
Searches an inventory for a specified item.
|
Searches an inventory for a specified item.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- search: string
|
|
||||||
-- item: table or string
|
|
||||||
-- metadata: table or string (optional)
|
|
||||||
exports.ox_inventory:Search(inv, search, item, metadata)
|
exports.ox_inventory:Search(inv, search, item, metadata)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* search: `string`
|
||||||
|
* item: `table` or `string`
|
||||||
|
* metadata?: `table` or `string`
|
||||||
|
|
||||||
`search` can be either `'slots'` or `'count'`, where slots will return a table of data
|
`search` can be either `'slots'` or `'count'`, where slots will return a table of data
|
||||||
and count will return the found amount of the specified item.
|
and count will return the found amount of the specified item.
|
||||||
@@ -3,11 +3,11 @@ Sets durability onto the specified slot.
|
|||||||
Can be used for repairing weapons.
|
Can be used for repairing weapons.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- slot: number
|
|
||||||
-- durability: number
|
|
||||||
exports.ox_inventory:SetDurability(inv, slot, durability)
|
exports.ox_inventory:SetDurability(inv, slot, durability)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* slot: `number`
|
||||||
|
* durability: `number`
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
@@ -22,4 +22,4 @@ local weapon = ox_inventory:GetCurrentWeapon(source)
|
|||||||
if weapon then
|
if weapon then
|
||||||
ox_inventory:SetDurability(source, weapon.slot, 100)
|
ox_inventory:SetDurability(source, weapon.slot, 100)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
Sets metadata on the specified slot.
|
Sets metadata on the specified slot.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- inv: string or number
|
|
||||||
-- slot: number
|
|
||||||
-- metadata: table
|
|
||||||
ox_inventory:SetMetadata(inv, slot, metadata)
|
ox_inventory:SetMetadata(inv, slot, metadata)
|
||||||
```
|
```
|
||||||
|
* inv: `string` or `number`
|
||||||
|
* slot: `number`
|
||||||
|
* metadata: `table`
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
Swaps slots in specified inventories.
|
Swaps slots in specified inventories.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- fromInventory: any
|
|
||||||
-- toInventory: any
|
|
||||||
-- slot1: number
|
|
||||||
-- slot2: number
|
|
||||||
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
|
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
|
||||||
```
|
```
|
||||||
|
* fromInventory: `any`
|
||||||
|
* toInventory: `any`
|
||||||
|
* slot1: `number`
|
||||||
|
* slot2: `number`
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
Creates and sets the player's inventory.
|
Creates and sets the player's inventory.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- player: table
|
|
||||||
-- source: number
|
|
||||||
-- identifier: string
|
|
||||||
-- name: string
|
|
||||||
-- groups: table (optional)
|
|
||||||
-- sex: string (optional)
|
|
||||||
-- dateofbirth: string (optional)
|
|
||||||
-- data: table
|
|
||||||
exports.ox_inventory:setPlayerInventory(player, data)
|
exports.ox_inventory:setPlayerInventory(player, data)
|
||||||
```
|
```
|
||||||
|
* player: `table`
|
||||||
|
* source: `number`
|
||||||
|
* identifier: `string`
|
||||||
|
* name: `string`
|
||||||
|
* groups?: `table`
|
||||||
|
* sex?: `string`
|
||||||
|
* dateofbirth?: `string`
|
||||||
|
* data?: `table`
|
||||||
|
* If not provided will load player's inventory data from the db.
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
title: Creating crafting points
|
||||||
|
---
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
```lua
|
||||||
|
{
|
||||||
|
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' }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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 },
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
* items: `table`
|
||||||
|
* name: `string`
|
||||||
|
* ingredients: `table`
|
||||||
|
* Item ingredients can be seen in the item tooltip.
|
||||||
|
* Key-value pairs of item name and consume count
|
||||||
|
* key - Item name.
|
||||||
|
* 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.
|
||||||
|
* amount: `number`
|
||||||
|
* Item amount recieved upon crafting.
|
||||||
|
* metadata: `table`
|
||||||
|
* Metadata applied to the item being crafted.
|
||||||
|
* points: `vector3[]`
|
||||||
|
* Interaction locations that will open the crafting inventory.
|
||||||
|
* zones: `table`
|
||||||
|
* ox_lib targeting zones used for ox_target.
|
||||||
|
* coords: `vector3`
|
||||||
|
* size: `vector3`
|
||||||
|
* distance: `number`
|
||||||
|
* rotation: `number`
|
||||||
|
* blip: `table`
|
||||||
|
* id: `number`
|
||||||
|
* Blip sprite number.
|
||||||
|
* colour: `number`
|
||||||
|
* scale: `number`
|
||||||
@@ -14,54 +14,58 @@ Key is the name (not the label) of an item and the value is a table containing t
|
|||||||
options for the item.
|
options for the item.
|
||||||
|
|
||||||
**Item options:**
|
**Item options:**
|
||||||
<Tabs>
|
|
||||||
<TabItem value='shared' label='Shared'>
|
|
||||||
|
|
||||||
```lua
|
* label: `string`
|
||||||
-- label: string
|
* weight?: `number`
|
||||||
-- weight: number (optional)
|
* stack?: `boolean`
|
||||||
-- stack: boolean (optional) -- If set to false will not allow the item to be stacked
|
* If set to false will not allow the item to be stacked.
|
||||||
-- degrade: number (optional) -- The amount of time in minutes an item will degrade after
|
* degrade?: `number`
|
||||||
-- close: boolean (optional) -- If set to false will not close the inventory on item use
|
* Amount of time in minutes the item will degrade after.
|
||||||
-- description: string (optional)
|
* close?: `boolean`
|
||||||
-- consume: number (optional) -- Item count needed, and removed, on use. (Default: 1) Set to a decimal for durability loss (0.2 = 20%)
|
* If set to false does not close the inventory on item use.
|
||||||
-- allowArmed: boolean (optional) -- If set to true will allow use of item while armed with a weapon
|
* description?: `string`
|
||||||
-- client: table (optional)
|
* Item description that will be shown in the tooltip
|
||||||
-- buttons: table (optional) -- Allows you to define custom context menu functions for the item
|
* consume?: `number`
|
||||||
```
|
* Item count needed and removed use.
|
||||||
|
* Default: 1
|
||||||
</TabItem>
|
* If set to a decimal will consume durability instead (0.2 = 20%).
|
||||||
<TabItem value='client' label='Client'>
|
* allowArmed?: `boolean`
|
||||||
|
* If set to true will allow use of item while armed with a weapon.
|
||||||
All values are optional.
|
* client?: `table`
|
||||||
|
* export?: `string`
|
||||||
```lua
|
* Export to be triggered after item use.
|
||||||
-- event: string -- Event to trigger after item use
|
* event?: `string`
|
||||||
-- status: table -- Adjust esx_status values after use
|
* Event to be triggered after item use.
|
||||||
-- anim: table -- Animation during progress bar
|
* status?: `table`
|
||||||
-- dict: string
|
* Adjust esx_status values after use.
|
||||||
-- clip: string
|
* anim?: `table`
|
||||||
-- prop: table -- Attached prop during progress bar
|
* Animation that will be played during the progress bar.
|
||||||
-- model: string or hash
|
* dict: `string`
|
||||||
-- pos: table (x, y, z)
|
* clip: `string`
|
||||||
-- rot: table (x, y, z)
|
* prop?: `table`
|
||||||
-- disable: boolean -- Disables actions during progress bar
|
* Attached prop that will be displayed during the progress bar.
|
||||||
-- usetime: number
|
* model: `string` or `hash`
|
||||||
-- cancel: boolean -- If set to true the player can cancel item use
|
* pos: `table` (x, y, z)
|
||||||
-- add: function(total) -- Function that triggers when recieving an item (Returns total item count as `total`)
|
* rot: `table` (x, y, z)
|
||||||
-- remove: function(total) -- Function that triggers when removing an item (Returns total item count as `total`)
|
* disable?: `table`
|
||||||
```
|
* Actions to be disabled during the progress bar
|
||||||
|
* move?: `boolean`
|
||||||
</TabItem>
|
* car?: `boolean`
|
||||||
<TabItem value='buttons' label='Buttons'>
|
* combat?: `boolean`
|
||||||
|
* mouse?: `boolean`
|
||||||
```lua
|
* usetime?: `number`
|
||||||
-- label: string,
|
* cancel?: `boolean`
|
||||||
-- action: function(slot) -- Callback function when button is clicked in context menu, returns item slot
|
* If set to true the player canc cancel item use.
|
||||||
```
|
* add?: `function`(total: `number`)
|
||||||
|
* Function that triggers when recieving an item
|
||||||
</TabItem>
|
* Returns total item count as `total`
|
||||||
</Tabs>
|
* 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>
|
<Tabs>
|
||||||
@@ -87,11 +91,9 @@ All values are optional.
|
|||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value='custom_burger' label='Custom burger'>
|
<TabItem value='description_burger' label='Description burger'>
|
||||||
|
|
||||||
A modified burger item, with a description and custom crafting table.
|
A modified burger item which includes a description.
|
||||||
|
|
||||||
Combined with several new functions and events you could easily create your own crafting system.
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
['burger'] = {
|
['burger'] = {
|
||||||
@@ -110,16 +112,6 @@ Combined with several new functions and events you could easily create your own
|
|||||||
},
|
},
|
||||||
usetime = 2500,
|
usetime = 2500,
|
||||||
}
|
}
|
||||||
crafting = {
|
|
||||||
['bun'] = 2,
|
|
||||||
['ketchup'] = 1,
|
|
||||||
['mustard'] = 1,
|
|
||||||
['cheese'] = 1,
|
|
||||||
['pickles'] = 1,
|
|
||||||
['lettuce'] = 1,
|
|
||||||
['tomato'] = 1,
|
|
||||||
['onion'] = 1,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -249,17 +241,16 @@ When registered you can define the item as a container under the `Items.containe
|
|||||||
The key for the container is the `name` you gave it when registering the item.
|
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.
|
You can also define the number of slots, the maximum weight, blacklist and whitelist items.
|
||||||
|
|
||||||
```lua
|
* itemName: `table`
|
||||||
['name'] = {
|
* size: `{number, number}`
|
||||||
-- size: {slots, maxWeight}
|
* First index is number of slots the container will have.
|
||||||
-- slots: number
|
* Second index is the maximum weight of the container.
|
||||||
-- maxWeight: number
|
* blacklist: `table`
|
||||||
-- blacklist: table (optional)
|
* Key-value pairs of item name and true
|
||||||
-- ['itemName'] = true
|
* `['itemName'] = true`
|
||||||
-- whitelist: table (optional)
|
* whitelist: `table`
|
||||||
-- ['itemName'] = true
|
* Key-value pairs of item name and true
|
||||||
}
|
* `['itemName'] = true`
|
||||||
```
|
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
title: Creating shops
|
title: Creating shops
|
||||||
---
|
---
|
||||||
|
|
||||||
import IconButton from '@site/src/components/IconButton'
|
|
||||||
import { BsGithub } from 'react-icons/bs'
|
|
||||||
|
|
||||||
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.
|
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
|
## Shop definition
|
||||||
|
|||||||
@@ -5,39 +5,31 @@ title: Creating custom stashes
|
|||||||
import IconButton from '@site/src/components/IconButton'
|
import IconButton from '@site/src/components/IconButton'
|
||||||
import { BsGithub } from 'react-icons/bs'
|
import { BsGithub } from 'react-icons/bs'
|
||||||
|
|
||||||
We can set up custom stashes from outside the resource utilising the exported RegisterStash function. Firstly, we need to define the stashes properties.
|
We can set up custom stashes from outside the resource utilising the exported RegisterStash function.
|
||||||
|
|
||||||
```lua
|
Firstly, we need to define the stashes properties.
|
||||||
-- id: string
|
|
||||||
-- label: string
|
|
||||||
-- slots: number
|
|
||||||
-- weight: number
|
|
||||||
-- owner: string or boolean (optional)
|
|
||||||
-- groups: table (optional)
|
|
||||||
-- name: string
|
|
||||||
-- grade: number
|
|
||||||
-- coords: vector or table (optional)
|
|
||||||
```
|
|
||||||
|
|
||||||
- `id` - A unique name to identify the stash in the database
|
### Stash properties
|
||||||
- `label` - Display name when viewing the stash
|
|
||||||
- `slots` - Number of slots that the stash will have
|
|
||||||
- `weight` - Maximum stash weight
|
|
||||||
- `owner` - See below
|
|
||||||
- `groups` - Key-value pairs of job name and minimum grade to access
|
|
||||||
- `coords` - Vector or table containing coordinates
|
|
||||||
|
|
||||||
The owner field will set permissions for stash access, with stashes registering to specific identifiers.
|
* id: `string`
|
||||||
- true: Each player has their own unique stash, but can request to open the stash of another player
|
* Unique name to identify the stash in the database.
|
||||||
- false: Only a single stash exists and is shared between all players
|
* label: `string`
|
||||||
- string: The stash explicitly belongs to the given owner, usually a player identifier
|
* Display name when viewing the stash.
|
||||||
|
* slots: `number`
|
||||||
The groups field will restrict access to the given jobs / grades such as below
|
* Number of slots the stash will have.
|
||||||
```
|
* weight: `number`
|
||||||
groups = {["police"] = 0, ["ambulance"] = 2}
|
* Maximum weight of the stash inventory.
|
||||||
```
|
* owner?: `string` or `boolean`
|
||||||
|
* `true`: Each player has their own unique stash, but can request to open the stash of another player
|
||||||
You can set the stash coordinates to prevent the stash from being opened if the player isn't close enough.
|
* `false`: Only a single stash exists and is shared between all players
|
||||||
|
* `string`: The stash explicitly belongs to the given owner, usually a player identifier
|
||||||
|
* groups?: `table`
|
||||||
|
* Key-value pairs of job name and minimum grade to be able to access the stash. (`{["police"] = 0, ["ambulance"] = 2}`)
|
||||||
|
* name: `string`
|
||||||
|
* grade: `number`
|
||||||
|
* coords?: `vector3` or `table`
|
||||||
|
* You can set the stash coordinates to prevent the stash from being opened if the player isn't close enough.
|
||||||
|
* Vector or table containing the coordinates of the stash.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user