formatting and typos

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

No files matched your search

@@ -6,6 +6,7 @@ Searches the inventory for an item, or list of items, with the result varying ba
```lua
exports.ox_inventory:Search(search, item, metadata)
```
* search: `'slots'` or `'count'`
* `'slots'` returns a table of slots where the item was found at.
* `'count'` returns the count of the specified item in player's inventory. If searching for multiple items
+2 -2
View File
@@ -9,7 +9,7 @@ The following snippet can be used in crafting resources such as okokCrafting or
```lua
local itemNames = {}
for item, data in pairs(exports.ox_inventory:Items()) do
for item, data in pairs(exports.ox_inventory:Items()) do
itemNames[item] = data.label
end
```
```
@@ -10,8 +10,8 @@ Returns whether the player's inventory is currently running an action (i.e. usin
local isInventoryBusy = LocalPlayer.state.invBusy
if isInventoryBusy then
-- Do stuff when busy
-- Do stuff when busy
else
-- Do stuff when not busy
-- Do stuff when not busy
end
```
@@ -10,7 +10,7 @@ Returns whether the player's inventory is currently open or not.
local isInventoryOpen = LocalPlayer.state.invOpen
if isInventoryOpen then
-- Do stuff when open
-- Do stuff when open
else
-- Do stuff when closed
-- Do stuff when closed
end
@@ -5,4 +5,5 @@ Mostly used for weaponised vehicles, though could be called for "minigames"
```lua
local exports.ox_inventory:weaponWheel(state)
```
* state: `boolean`
@@ -3,6 +3,7 @@ Sets a metadata property to display in the tooltip.
```lua
exports.ox_inventory:displayMetadata(metadata, value)
```
* metadata: `table` or `string`
* If metadata is a string then it's the metadata property you want to display, value is **not** optional then.
* Can be a table of key-value pairs, key being the metadata property and value being the label for that property.
@@ -10,6 +11,7 @@ exports.ox_inventory:displayMetadata(metadata, value)
* Label for the string metadata property to be displayed.
**Example:**
```lua
exports.ox_inventory:displayMetadata('mustard', 'Mustard')
```
@@ -6,6 +6,7 @@ Opens an inventory using the passed data.
```lua
exports.ox_inventory:openInventory(invType, data)
```
* invType: `string`
* `'player'`
* `'shop'`
@@ -3,6 +3,7 @@ Forces the secondary-inventory key to open the passed inventory. Can be useful t
```lua
exports.ox_inventory:setStashTarget(id, owner)
```
* id: `string` or `number`
* Stash id.
* owner?: `string` or `number`
@@ -1,9 +1,10 @@
Uses the passed item, then triggers the callback function.
Uses the passed item, then triggers the callback function.
Should be calling during item callbacks to utilise the builtin methods (server checks, progress bar, etc.).
```lua
exports.ox_inventory:useItem(data, cb)
```
* data: `table`
* cb?: `function`
@@ -3,4 +3,5 @@ Uses the item in the given inventory slot.
```lua
exports.ox_inventory:useSlot(slot)
```
* slot: `number`
+1 -1
View File
@@ -24,7 +24,7 @@ By returning `false`, you can cancel the action and revert the inventory state.
- source: `number`
- action: `'move'` or `'stack'` or `'swap'` or `'give'`
- fromInventory: `number` or `string`
- toInventory:` number` or `string`
- toInventory: `number` or `string`
- fromType: `string`
- toType: `string`
- fromSlot: `table`
@@ -5,6 +5,7 @@ Should be used alongside [CanCarryItem](./CanCarryItem.md) otherwise, the maximu
```lua
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)
```
- inv: `table` or `string` or `number`
- The inventory's unique id, or a table with the id and owner.
- playerId: `1`
@@ -3,6 +3,7 @@ Returns the amount a player can hold based on available weight.
```lua
exports.ox_inventory:CanCarryAmount(inv, item)
```
* inv: `string` or `number`
* item: `table` or `string`
* Can be array to check multiple items.
@@ -5,6 +5,7 @@ The function checks for inventory weight and available slots.
```lua
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
```
* inv: `string` or `number`
* item `table` or `string`
* Can be array of items.
@@ -13,6 +14,7 @@ exports.ox_inventory:CanCarryItem(inv, item, count, metadata)
* If metadata is passed as string then `metadata.type` will be checked.
**Example:**
```lua
-- Checks if the player calling the event can carry 3 water items
if exports.ox_inventory:CanCarryItem(source, 'water', 3) then
@@ -3,6 +3,7 @@ Returns if inventory can carry specified weight and free inventory weight.
```lua
exports.ox_inventory:CanCarryWeight(inv, weight)
```
* inv: `string` or `number`
* weight: `number`
@@ -3,6 +3,7 @@ Returns true if the item swap is possible based on inventory weight.
```lua
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
```
* inv: `string` or `number`
* firstItem: `string`
* firstItemCount: `number`
@@ -3,5 +3,6 @@ Clears the specified inventory. The `keep` argument is either a string or an arr
```lua
exports.ox_inventory:ClearInventory(inv, keep)
```
* inv: `string` or `number`
* keep?: `string` or `string[]`
@@ -6,4 +6,5 @@ the player.
```lua
exports.ox_inventory:ConfiscateInventory(source)
```
* source: `number`
@@ -3,11 +3,14 @@ Takes traditional item data and updates it to support ox_inventory.
```lua
exports.ox_inventory:ConvertItems(playerId, items)
```
* playerId: `number`
* items: `table`
Data conversion example:
```
Old: [{"cola":1, "bread":3}]
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
```lua
Old: [{"cola":1, "bread":3}]
New: [{"slot":1,"name":"cola","count":1},
{"slot":2,"name":"bread","count":3}]
```
@@ -3,6 +3,7 @@ Drops can be created from other resources, containing a variety of items and uti
```lua
exports.ox_inventory:CustomDrop(prefix, items, coords, slots, maxWeight, instance)
```
* prefix: `string`
* items: `table`
* name: `string`
@@ -4,4 +4,5 @@ Returns the player's currently equipped weapon as a table.
-- inv: string or number
exports.ox_inventory:GetCurrentWeapon(inv)
```
* inv: `string` or `number`
@@ -3,23 +3,25 @@ Returns the inventory associated with the ID (and owner if defined). Otherwise r
```lua
exports.ox_inventory:GetInventory(inv, owner)
```
* inv: `number` or `table`
* owner?: `string` or `boolean`
**Example:**
```lua
local inventory = exports.ox_inventory:GetInventory('example_stash', false)
print(json.encode(inventory, {indent = true}))
--[[
{
"id": "example_stash,
"label": "Police Stash",
"type": "stash,
"slots": 50,
"weight": 0,
"maxWeight": 100000,
"owner": false,
...
"id": "example_stash,
"label": "Police Stash",
"type": "stash,
"slots": 50,
"weight": 0,
"maxWeight": 100000,
"owner": false,
...
}
]]
```
@@ -3,10 +3,12 @@ Returns all slots with items in a inventory.
```lua
exports.ox_inventory:GetInventoryItems(inv, owner)
```
* inv: `number` or `table`
* owner?: `string` or `boolean`
**Example:**
```lua
local playerItems = exports.ox_inventory:GetInventoryItems(source)
```
@@ -3,6 +3,7 @@ Returns the item from the specified inventory.
```lua
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)
```
* inv: `string` or `number`
* item: `table` or `string`
* Can be items array.
@@ -15,6 +16,7 @@ how many times the item was found.
Otherwise returns the data related to the item _and_ it's total count found in the inventory.
**Example**:
```lua
local item = ox_inventory:GetItem(source, 'water', nil, false)
@@ -3,6 +3,7 @@ Returns the number of slots the specified item is in, the item's total count and
```lua
exports.ox_inventory:GetItemSlots(inv, item, metadata)
```
* inv: `string` or `number`
* item: `table` or `string`
* metadata?: `table`
@@ -4,24 +4,26 @@ Returns the specified slot data as a table.
exports.ox_inventory:GetSlot(inv, slot)
```
* inv: `string` or `number`
* slot: `number`
**Example:**
```lua
local slot = exports.ox_inventory:GetSlot(source, 1)
print(json.encode(slot, {indent=true}))
--[[
{
"weight": 2000,
"name": "water",
"metadata": [],
"slot": 1,
"label": "Water",
"close": true,
"stack": true,
"count: 4
"weight": 2000,
"name": "water",
"metadata": [],
"slot": 1,
"label": "Water",
"close": true,
"stack": true,
"count: 4
}
]]
```
@@ -3,6 +3,7 @@ Creates a new custom stash.
```lua
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
```
* id: `string` or `number`
* Stash identifier when loading from the database.
* label: `string`
@@ -14,9 +15,9 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c
* `true`: Each player has a unique stash but can request other player's stashes.
* `nil`: Always shared.
* groups: `table`
* Table of player groups (jobs) able to access the stash.
* Table of group names where the numeric value is the minimum grade required.
* `{['police'] = 0, ['ambulance'] = 2}`
* Table of player groups (jobs) able to access the stash.
* Table of group names where the numeric value is the minimum grade required.
* `{['police'] = 0, ['ambulance'] = 2}`
* coords: `vector3`
:::caution
@@ -5,4 +5,5 @@ Use it alongside [ConfiscateInventory](./ConfiscateInventory.md).
```lua
exports.ox_inventory:ReturnInventory(source)
```
* source: `number`
@@ -1,9 +1,9 @@
Searches an inventory for a specified item.
```lua
exports.ox_inventory:Search(inv, search, item, metadata)
```
* inv: `string` or `number`
* search: `string`
* item: `table` or `string`
@@ -5,11 +5,13 @@ Can be used for repairing weapons.
```lua
exports.ox_inventory:SetDurability(inv, slot, durability)
```
* inv: `string` or `number`
* slot: `number`
* durability: `number`
**Example:**
```lua
local ox_inventory = exports.ox_inventory
@@ -3,11 +3,13 @@ Sets metadata on the specified slot.
```lua
ox_inventory:SetMetadata(inv, slot, metadata)
```
* inv: `string` or `number`
* slot: `number`
* metadata: `table`
**Example:**
```lua
local ox_inventory = exports.ox_inventory
@@ -18,6 +20,7 @@ for k, v in pairs(water) do
water = v
break
end
water.metadata.type = 'clean'
ox_inventory:SetMetadata(source, water.slot, water.metadata)
print(('modified %sx water in slot %s with new metadata'):format(water.count, water.slot))
@@ -3,6 +3,7 @@ Swaps slots in specified inventories.
```lua
exports.ox_inventory:SwapSlots(fromInventory, toInventory, slot1, slot2)
```
* fromInventory: `any`
* toInventory: `any`
* slot1: `number`
+2 -2
View File
@@ -11,10 +11,10 @@ local itemNames
ESX.RegisterServerCallback('crafting:itemNames', function(source, cb)
if not itemNames then
itemNames = {}
for item, data in pairs(exports.ox_inventory:Items()) do
for item, data in pairs(exports.ox_inventory:Items()) do
itemNames[item] = data.label
end
end
cb(itemNames)
end)
```
```
@@ -3,6 +3,7 @@ Creates and sets the player's inventory.
```lua
exports.ox_inventory:setPlayerInventory(player, data)
```
* player: `table`
* source: `number`
* identifier: `string`