From 927f5ee72e37ca501bff2da082f5397a9273cc58 Mon Sep 17 00:00:00 2001 From: Adharsh M Date: Mon, 25 Nov 2024 00:55:48 +0530 Subject: [PATCH 1/7] Improved inventory tooltip visibility. --- html/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/main.css b/html/main.css index a3ccc2c75..72ca84599 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 { From 86917130799b613845ec3dcd5fac17380362e748 Mon Sep 17 00:00:00 2001 From: Adharsh M Date: Mon, 25 Nov 2024 03:28:45 +0530 Subject: [PATCH 2/7] Fixed weapon not removing from the player on clear inventory. --- server/functions.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/functions.lua b/server/functions.lua index 3c4ad40d9..aaef24de9 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 ~= GetHashKey('WEAPON_UNARMED') then + RemoveWeaponFromPed(ped, weapon) + end if Player(source).state.inv_busy then TriggerClientEvent('qb-inventory:client:updateInventory', source) end end end From 474e7b44ac1a5fbdc3247383663f66c369ba3efe Mon Sep 17 00:00:00 2001 From: Nejc Cifer Date: Mon, 25 Nov 2024 00:39:11 +0100 Subject: [PATCH 3/7] fix: purchase larger amount than stocked --- server/main.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/main.lua b/server/main.lua index 4c2ace4fa..4a0de30b3 100644 --- a/server/main.lua +++ b/server/main.lua @@ -351,6 +351,12 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function( end end + if amount > itemInfo.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) From 6d7ee8841607a47156f130779383ccd2096f30cf Mon Sep 17 00:00:00 2001 From: Nejc Cifer Date: Mon, 25 Nov 2024 20:49:54 +0100 Subject: [PATCH 4/7] chore: check the server-side variable instead of client-side --- server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 4a0de30b3..7d8881481 100644 --- a/server/main.lua +++ b/server/main.lua @@ -351,7 +351,7 @@ QBCore.Functions.CreateCallback('qb-inventory:server:attemptPurchase', function( end end - if amount > itemInfo.amount then + if amount > shopInfo.items[itemInfo.slot].amount then TriggerClientEvent('QBCore:Notify', source, 'Cannot purchase larger quantity than currently in stock', 'error') cb(false) return From fad44d86a48b0b62e4690d3d32a703b8d83ee865 Mon Sep 17 00:00:00 2001 From: Adharsh M Date: Tue, 26 Nov 2024 07:51:17 +0530 Subject: [PATCH 5/7] Refactored: Use precomputed hash keys for weapon checks Co-authored-by: Joel <34402846+Qwerty1Verified@users.noreply.github.com> --- server/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/functions.lua b/server/functions.lua index aaef24de9..1307990a8 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -432,7 +432,7 @@ function ClearInventory(source, filterItems) TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'ClearInventory', 'red', logMessage) local ped = GetPlayerPed(source) local weapon = GetSelectedPedWeapon(ped) - if weapon ~= GetHashKey('WEAPON_UNARMED') then + if weapon ~= `WEAPON_UNARMED` then RemoveWeaponFromPed(ped, weapon) end if Player(source).state.inv_busy then TriggerClientEvent('qb-inventory:client:updateInventory', source) end From 9f94c14d0dd6909fadc89bee72354f1b9f06cbb6 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 25 Nov 2024 20:05:44 -0800 Subject: [PATCH 6/7] fix: validate purchase item name with server-side data --- server/main.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/main.lua b/server/main.lua index 7d8881481..080e662e0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -351,6 +351,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) From e86c8a9f46407d281981c8c17ccdeda9bcdbcd46 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 25 Nov 2024 20:06:34 -0800 Subject: [PATCH 7/7] fix: validate item price server-side --- server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 080e662e0..c60077220 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 @@ -368,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')