From 0bf84b936a79974605dab079b0a205c14480ed15 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:40:34 +1000 Subject: [PATCH] new inventory exports --- .../Server/Inventory/GetEmptySlot.md | 9 +++ .../Server/Inventory/GetSlotForItem.md | 11 ++++ .../Functions/Server/forceOpenInventory.md | 61 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 docs/ox_inventory/Functions/Server/Inventory/GetEmptySlot.md create mode 100644 docs/ox_inventory/Functions/Server/Inventory/GetSlotForItem.md create mode 100644 docs/ox_inventory/Functions/Server/forceOpenInventory.md diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetEmptySlot.md b/docs/ox_inventory/Functions/Server/Inventory/GetEmptySlot.md new file mode 100644 index 00000000..412179cc --- /dev/null +++ b/docs/ox_inventory/Functions/Server/Inventory/GetEmptySlot.md @@ -0,0 +1,9 @@ +Get the first available empty slot in an inventory. + +```lua +exports.ox_inventory:GetEmptySlot(inv) +``` + +- inv: `table` or `string` or `number` + +**Returns:** `number?` diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetSlotForItem.md b/docs/ox_inventory/Functions/Server/Inventory/GetSlotForItem.md new file mode 100644 index 00000000..029a44dc --- /dev/null +++ b/docs/ox_inventory/Functions/Server/Inventory/GetSlotForItem.md @@ -0,0 +1,11 @@ +Get the slot id of an existing item matching the given data, or an empty slot. + +```lua +exports.ox_inventory:GetSlotForItem(inv, itemName, metadata) +``` + +- inv: `table` or `string` or `number` +- itemName: `string` +- metadata: `table?` + +**Returns:** `number?` diff --git a/docs/ox_inventory/Functions/Server/forceOpenInventory.md b/docs/ox_inventory/Functions/Server/forceOpenInventory.md new file mode 100644 index 00000000..76302499 --- /dev/null +++ b/docs/ox_inventory/Functions/Server/forceOpenInventory.md @@ -0,0 +1,61 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Opens an inventory using the passed data. +Forces a player to open an inventory, without usual security checks (groups, coords). + +```lua +exports.ox_inventory:forceOpenInventory(playerId, invType, data) +``` + +- playerId: `number` +- invType: `string` + - `'player'` + - `'stash'` + - `'container'` + - `'drop'` + - `'glovebox'` + - `'trunk'` + - `'dumpster'` +- data: `number` or `string` or `table` + + + + +**Open the target player's inventory.** + +```lua +exports.ox_inventory:forceOpenInventory(1, 'player', 3) +``` + +**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) +``` + + + + +**Open the first stash in [data/stashes](https://github.com/overextended/ox_inventory/blob/main/data/stashes.lua#L2-L19).** + +```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' }) +``` + + +