From 5c69f8dd28502f2d5273c3c5174290ae5d4b6278 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Thu, 26 Jun 2025 20:04:32 +0100 Subject: [PATCH] add new function `hasFreeInventorySlots()` using the function to grab slot info, this can now check if you have enough inventory slots for items to be given, allowing it to check before TRYING to add them --- shared/itemcontrol.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shared/itemcontrol.lua b/shared/itemcontrol.lua index af4d1db..73bbfd1 100644 --- a/shared/itemcontrol.lua +++ b/shared/itemcontrol.lua @@ -870,6 +870,18 @@ function getCurrentInvWeight() return weight end +function hasFreeInventorySlots(slots, src) + local inv = getPlayerInv(src) + print(countTable(inv)) + print(countTable(inv) + slots) + print(InventorySlots) + print((countTable(inv) + slots) <= InventorySlots) + if (countTable(inv) + slots) <= InventorySlots then + return true + end + return false +end + ------------------------------------------------------------- -- Check Item Existance - return boolean(true,false) -------------------------------------------------------------