Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Recommited Vendor Crash Issue to 1.2.3
  • Loading branch information
Leonheart authored Jan 28, 2023
commit 086db2ef2035261af4e5e6569231a536b490a253
34 changes: 18 additions & 16 deletions plugins/vendor/sv_hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,24 @@ function PLUGIN:VendorTradeAttempt(
vendor:takeStock(itemType)

local position = client:getItemDropPos()
local result = character:getInv():add(itemType)
:next(function(item)
hook.Run("OnCharTradeVendor", client, vendor, item, isSellingToVendor)
client.vendorTransaction = nil
end)
:catch(function(err)
if (IsValid(client)) then
client:notifyLocalized("itemOnGround")
end
client.vendorTransaction = nil
return nut.item.spawn(itemType, position)
end)
:catch(function(err)
client:notifyLocalized(err)
client.vendorTransaction = nil
end)

local result = character:getInv():add(itemType):next(function(item)
hook.Run("OnCharTradeVendor", client, vendor, item, isSellingToVendor)
client.vendorTransaction = nil
end):catch(function(err)
if IsValid(client) then
client:notifyLocalized("Cannot add to inventory! Giving money back!")
end

client.vendorTransaction = nil

return character:giveMoney(price)
end):catch(function(err)
client:notifyLocalized(err)
client.vendorTransaction = nil
end)



nut.log.add(client, "vendorBuy", itemType, vendor:getNetVar("name"))
end
Expand Down