Skip to content

Commit 46abe05

Browse files
committed
fix(server): normalise item count as a positive integer
Resolves #1960.
1 parent 6003e1d commit 46abe05

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

modules/inventory/server.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data)
16921692
return
16931693
end
16941694

1695-
if data.count < 1 then return end
1695+
data.count = math.max(1, math.floor(data.count or 1))
16961696

16971697
local playerInventory = Inventory(source)
16981698

@@ -2494,7 +2494,7 @@ local function giveItem(playerId, slot, target, count)
24942494

24952495
if not fromInventory or not toInventory then return end
24962496

2497-
if type(count) ~= 'number' or count <= 0 then count = 1 end
2497+
count = math.max(1, math.floor(count or 1))
24982498

24992499
if toInventory.player then
25002500
local data = fromInventory.items[slot]

modules/shops/server.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ end
199199

200200
lib.callback.register('ox_inventory:buyItem', function(source, data)
201201
if data.toType == 'player' then
202-
if data.count == nil then data.count = 1 end
202+
data.count = math.max(1, math.floor(data.count or 1))
203203

204204
local playerInv = Inventory(source)
205205

0 commit comments

Comments
 (0)