diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/CanCarryItem.md b/docs/ox_inventory/Functions/External/Server/Inventory/CanCarryItem.md index 97553d8f..17fb761a 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/CanCarryItem.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/CanCarryItem.md @@ -8,4 +8,14 @@ The function checks for inventory weight and available slots. -- count: number -- metadata: table or string (optional) exports.ox_inventory:CanCarryItem(inv, item, count, metadata) +``` + +**Example:** +```lua +-- Checks if the player calling the event can carry 3 water items +if exports.ox_inventory:CanCarryItem(source, 'water', 3) then + -- Do stuff if can carry +else + -- Do stuff if can't carry +end ``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/CustomDrop.md b/docs/ox_inventory/Functions/External/Server/Inventory/CustomDrop.md index 790088b3..cc5ff351 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/CustomDrop.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/CustomDrop.md @@ -8,4 +8,7 @@ Creates an inventory drop at the specified coords. -- maxWeight: number -- instance: ? (optional) exports.ox_inventory:CustomDrop(prefix, item, coords, slots, maxWeight, instance) -``` \ No newline at end of file +``` + +**Example:** +You can find and example showcasing this function into furher detail [here](../../../../Guides/customDrop.md). \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/GetItem.md b/docs/ox_inventory/Functions/External/Server/Inventory/GetItem.md index 49cfd5c6..b19b67e0 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/GetItem.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/GetItem.md @@ -8,6 +8,25 @@ Returns the item from the specified inventory. exports.ox_inventory:GetItem(inv, item, metadata, returnsCount) ``` -If `returnsCount` is set to true, the returned value will include `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. +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) + +print(json.encode(item, {indent=true})) +--[[ + { + "consume": 1, + "count": 15, + "stack": true, + "name": "water", + "weight": 500, + "label": "Water", + "close": true + } +]] +``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/GetSlot.md b/docs/ox_inventory/Functions/External/Server/Inventory/GetSlot.md index ea9a1abd..e86452ed 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/GetSlot.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/GetSlot.md @@ -4,4 +4,23 @@ Returns the specified slot data as a table. -- inv: string or number -- slot: number exports.ox_inventory:GetSlot(inv, slot) +``` + +**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 + } +]] ``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/RegisterStash.md b/docs/ox_inventory/Functions/External/Server/Inventory/RegisterStash.md index 9b454d84..b23dc06c 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/RegisterStash.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/RegisterStash.md @@ -24,4 +24,8 @@ exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, c :::caution This function needs to be triggered before a player can open the stash. -::: \ No newline at end of file +::: + +**Example:** + +For a use case example on this function check out the written [Guide](../../../../Guides/stashes.md) for it. \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/RemoveItem.md b/docs/ox_inventory/Functions/External/Server/Inventory/RemoveItem.md index 0abc040a..ff376eec 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/RemoveItem.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/RemoveItem.md @@ -7,4 +7,10 @@ Removes the specified item from the specified inventory. -- metadata: table or string (optional) -- slot: number (optional) exports.ox_inventory:RemoveItem(inv, item, count, metadata, slot) +``` + +**Example:** +```lua +-- Removes 1 water from the inventory +exports.ox_inventory:RemoveItem(source, 'water', 1) ``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/SetDurability.md b/docs/ox_inventory/Functions/External/Server/Inventory/SetDurability.md index ef2f7b4f..59e5a158 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/SetDurability.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/SetDurability.md @@ -7,4 +7,19 @@ Can be used for repairing weapons. -- slot: number -- durability: number exports.ox_inventory:SetDurability(inv, slot, durability) +``` + +**Example:** +```lua +local ox_inventory = exports.ox_inventory + +-- Set the durability of the item in slot 3 of source player's inventory to 100 +ox_inventory:SetDurability(source, 3, 100) + +-- Set the durability of the source player's current weapon to 100 +local weapon = ox_inventory:GetCurrentWeapon(source) + +if weapon then + ox_inventory:SetDurability(source, weapon.slot, 100) +end ``` \ No newline at end of file diff --git a/docs/ox_inventory/Functions/External/Server/Inventory/SetMetadata.md b/docs/ox_inventory/Functions/External/Server/Inventory/SetMetadata.md index 8b6a9da0..fbdb55da 100644 --- a/docs/ox_inventory/Functions/External/Server/Inventory/SetMetadata.md +++ b/docs/ox_inventory/Functions/External/Server/Inventory/SetMetadata.md @@ -5,4 +5,19 @@ Sets metadata on the specified slot. -- slot: number -- metadata: table ox_inventory:SetMetadata(inv, slot, metadata) +``` + +**Example:** +```lua +local ox_inventory = exports.ox_inventory + +local water = ox_inventory:Search(source, 1, 'water') +for k, v in pairs(water) do + print('\n______________'..'\n- index '..k) + print(v.name, 'slot: '..v.slot, 'metadata: '..json.encode(v.metadata)) + water = v +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)) ``` \ No newline at end of file diff --git a/docs/ox_inventory/Guides/customDrop.md b/docs/ox_inventory/Guides/customDrop.md new file mode 100644 index 00000000..3252c7e1 --- /dev/null +++ b/docs/ox_inventory/Guides/customDrop.md @@ -0,0 +1,3 @@ +--- +title: Creating custom drops +--- \ No newline at end of file diff --git a/docs/ox_inventory/Guides/itemData.md b/docs/ox_inventory/Guides/itemData.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/ox_inventory/Guides/usableItems.md b/docs/ox_inventory/Guides/usableItems.md new file mode 100644 index 00000000..e69de29b