Skip to content

Commit

Permalink
Fix shop taking double the item amount
Browse files Browse the repository at this point in the history
  • Loading branch information
IamLation committed Oct 19, 2024
1 parent 44a0862 commit 80affc0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lua54 'yes'

name 'lation_pawnshop'
author 'iamlation'
version '1.1.0'
version '1.1.1'
description 'A Pawn Shop script for ESX, QBCore & QBox using ox_inventory'

server_scripts {
Expand Down
23 changes: 0 additions & 23 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,6 @@ for shopId, data in pairs(Config.Shops) do
inventories[#inventories + 1] = shopId
end

-- Thread to handle removal of non-stackable items
-- A pretty hacky solution, but works nevertheless
--- @param source number
--- @param item string
--- @param count number
local function AwaitRemoval(source, item, count)
local source = source
local wait = 5 -- Increase this number slightly if items failing to remove
while waiting do
Wait(0)
wait = wait - 1
if wait <= 0 then
exports.ox_inventory:RemoveItem(source, item, count)
waiting = false
break
end
end
end

-- Used to handle all movements and final transaction in inventory
--- @param payload table
local function BeginTransaction(payload)
Expand Down Expand Up @@ -105,10 +86,6 @@ local function BeginTransaction(payload)
local message = string.format(log, tostring(playerName), tostring(identifier), tostring(GroupDigits(quantity)), info.label, tostring(GroupDigits(price)))
PlayerLog(source, Strings.Logs.item_sold.title, message)
end
if not payload.stack then
waiting = true
CreateThread(function() AwaitRemoval(source, payload.fromSlot.name, payload.count) end)
end
return true
end
end
Expand Down

0 comments on commit 80affc0

Please sign in to comment.