From 31bf64baf2ed54abb2514eccaa2cc0a00518e7e8 Mon Sep 17 00:00:00 2001 From: hyprell <75884474+hyprell@users.noreply.github.com> Date: Thu, 1 Dec 2022 12:41:23 +0200 Subject: [PATCH] feat(ox_inventory): CanCarryWeight (#75) * feat(ox_inventory): CanCarryWeight * fix(ox_inventory/CanCarryWeight): mistake --- .../Functions/Server/Inventory/CanCarryWeight | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight b/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight new file mode 100644 index 00000000..ffaeea48 --- /dev/null +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryWeight @@ -0,0 +1,25 @@ +Returns if inventory can carry specified weight and free inventory weight. + +```lua +exports.ox_inventory:CanCarryWeight(inv, weight) +``` +* inv: `string` or `number` +* weight: `number` + +Example: + +```lua +-- Checks if player can carry 1000 grams. +local fillAmount = 1000 +local canCarryWeight, freeWeight = ox_inventory:CanCarryWeight(playerId, fillAmount) + +if freeWeight == 0 then + -- Player can't carry weight. + return +elseif not canCarryWeight then + -- Modify fillAmount, because inventory can't carry specified weight + fillAmount = freeWeight +end + +-- Do something +```