From 02bb1d1dbb1dffc206cc84d5513ded4daf0745a0 Mon Sep 17 00:00:00 2001 From: zozomanx Date: Tue, 15 Oct 2024 19:31:00 -0400 Subject: [PATCH 1/2] feat: Making giveItem more flexible Before when giving a stack of items to another player an error would be given if the exact amount wasn't specified in the count box. A single item was given when "0" was put in the count box. With this change, if 0 is given the entire stack will be given, if an amount greater than the stack is used in the count box then the entire stack will be given. This change is a more natural change than how it was previously being used. --- modules/inventory/server.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/inventory/server.lua b/modules/inventory/server.lua index 25312ab80..7f1945f7d 100644 --- a/modules/inventory/server.lua +++ b/modules/inventory/server.lua @@ -2412,13 +2412,20 @@ local function giveItem(playerId, slot, target, count) local fromInventory = Inventories[playerId] local toInventory = Inventories[target] - if count <= 0 then count = 1 end + if count < 0 then return end + if toInventory?.player then local data = fromInventory.items[slot] if not data then return end + if count == 0 then + count = data.count + elseif count > data.count then + count = data.count + end + local targetState = Player(target).state if targetState.invBusy then From a207082fe7b5d4c25addd24d58de56c97365b297 Mon Sep 17 00:00:00 2001 From: zozomanx Date: Tue, 15 Oct 2024 19:47:05 -0400 Subject: [PATCH 2/2] Update server.lua --- modules/inventory/server.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/inventory/server.lua b/modules/inventory/server.lua index 7f1945f7d..ce03278dc 100644 --- a/modules/inventory/server.lua +++ b/modules/inventory/server.lua @@ -2412,15 +2412,15 @@ local function giveItem(playerId, slot, target, count) local fromInventory = Inventories[playerId] local toInventory = Inventories[target] - if count < 0 then return end - if toInventory?.player then local data = fromInventory.items[slot] if not data then return end - if count == 0 then + if count < 0 then + return { 'cannot_give', count, data.label } + elseif count == 0 then count = data.count elseif count > data.count then count = data.count