Skip to content

Commit

Permalink
Merge pull request #603 from Qwerty1Verified/fix-spawn-exploit
Browse files Browse the repository at this point in the history
fix: item purchasing spawn exploit
  • Loading branch information
GhzGarage authored Nov 26, 2024
2 parents 5397a6c + e86c8a9 commit 48ed1ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
@@ -327,7 +327,6 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function(
local itemInfo = data.item
local amount = data.amount
local shop = string.gsub(data.shop, 'shop%-', '')
local price = itemInfo.price * amount
local Player = QBCore.Functions.GetPlayer(source)

if not Player then
@@ -351,6 +350,11 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function(
end
end

if shopInfo.items[itemInfo.slot].name ~= itemInfo.name then -- Check if item name passed is the same as the item in that slot
cb(false)
return
end

if amount > shopInfo.items[itemInfo.slot].amount then
TriggerClientEvent('QBCore:Notify', source, 'Cannot purchase larger quantity than currently in stock', 'error')
cb(false)
@@ -363,6 +367,7 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function(
return
end

local price = shopInfo.items[itemInfo.slot].price * amount
if Player.PlayerData.money.cash >= price then
Player.Functions.RemoveMoney('cash', price, 'shop-purchase')
AddItem(source, itemInfo.name, amount, nil, itemInfo.info, 'shop-purchase')

0 comments on commit 48ed1ed

Please sign in to comment.