diff --git a/html/main.css b/html/main.css index a3ccc2c7..72ca8459 100644 --- a/html/main.css +++ b/html/main.css @@ -443,7 +443,7 @@ div { } .custom-tooltip { - max-width: 6vw; + max-width: 20vw; } .custom-tooltip .tooltip-header { diff --git a/server/functions.lua b/server/functions.lua index 3c4ad40d..1307990a 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -430,6 +430,11 @@ function ClearInventory(source, filterItems) if not player.Offline then local logMessage = string.format('**%s (citizenid: %s | id: %s)** inventory cleared', GetPlayerName(source), player.PlayerData.citizenid, source) TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'ClearInventory', 'red', logMessage) + local ped = GetPlayerPed(source) + local weapon = GetSelectedPedWeapon(ped) + if weapon ~= `WEAPON_UNARMED` then + RemoveWeaponFromPed(ped, weapon) + end if Player(source).state.inv_busy then TriggerClientEvent('qb-inventory:client:updateInventory', source) end end end diff --git a/server/main.lua b/server/main.lua index 4c2ace4f..c6007722 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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,12 +350,24 @@ 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) + return + end + if not CanAddItem(source, itemInfo.name, amount) then TriggerClientEvent('QBCore:Notify', source, 'Cannot hold item', 'error') cb(false) 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')