From 694c91f21dd9799d2af64eaf3b9caa585f2efad8 Mon Sep 17 00:00:00 2001 From: Mechomancer <62558658+Mechomancer@users.noreply.github.com> Date: Wed, 29 May 2024 07:01:31 -0500 Subject: [PATCH 1/3] Update main.lua This code was added to check the drop for items if no items this removes the bag drop from the world Adding more code on client side so your unable to pick up more than one drop at a time. Avoids getting a drop with or without items stuck to you by picking up another. --- server/main.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/main.lua b/server/main.lua index 508476e0d..68b74fe2f 100644 --- a/server/main.lua +++ b/server/main.lua @@ -159,6 +159,13 @@ RegisterNetEvent('qb-inventory:server:closeInventory', function(inventory) end if Drops[inventory] then Drops[inventory].isOpen = false + if #Drops[inventory].items == 0 and not Drops[inventory].isOpen then -- if no listeed items in the drop on close + TriggerClientEvent('qb-inventory:client:removeDropTarget', Drops[inventory].entityId) + Wait(500) + local entity = NetworkGetEntityFromNetworkId(Drops[inventory].entityId) + if DoesEntityExist(entity) then DeleteEntity(entity) end + Drops[inventory] = nil + end return end if not Inventories[inventory] then return end From 910d0e447d3c7e9d9e9cd93e8512188561f74cc4 Mon Sep 17 00:00:00 2001 From: Mechomancer <62558658+Mechomancer@users.noreply.github.com> Date: Wed, 29 May 2024 07:07:02 -0500 Subject: [PATCH 2/3] Update drops.lua This was added as part of the multi drop holding conundrum and to ensure there can only be one drop held at a time by the player. When drop has no items it's deleted this also removes the target on the bag before it's deleted. --- client/drops.lua | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/client/drops.lua b/client/drops.lua index 10c8a3788..b59045c29 100644 --- a/client/drops.lua +++ b/client/drops.lua @@ -32,6 +32,14 @@ end -- Events +RegisterNetEvent('qb-inventory:client:removeDropTarget', function(dropId) + while not NetworkDoesNetworkIdExist(dropId) do Wait(10) end + local bag = NetworkGetEntityFromNetworkId(dropId) + while not DoesEntityExist(bag) do Wait(10) end + --Run exsport to remove entity target bag + exports['qb-target']:RemoveTargetEntity(bag) +end) + RegisterNetEvent('qb-inventory:client:setupDropTarget', function(dropId) while not NetworkDoesNetworkIdExist(dropId) do Wait(10) end local bag = NetworkGetEntityFromNetworkId(dropId) @@ -51,29 +59,32 @@ RegisterNetEvent('qb-inventory:client:setupDropTarget', function(dropId) icon = 'fas fa-hand-pointer', label = 'Pick up bag', action = function() - AttachEntityToEntity( - bag, - PlayerPedId(), - GetPedBoneIndex(PlayerPedId(), Config.ItemDropObjectBone), - Config.ItemDropObjectOffset[1].x, - Config.ItemDropObjectOffset[1].y, - Config.ItemDropObjectOffset[1].z, - Config.ItemDropObjectOffset[2].x, - Config.ItemDropObjectOffset[2].y, - Config.ItemDropObjectOffset[2].z, - true, true, false, true, 1, true - ) - bagObject = bag - holdingDrop = true - heldDrop = newDropId - exports['qb-core']:DrawText('Press [G] to drop the bag') + if not holdingDrop then + AttachEntityToEntity( + bag, + PlayerPedId(), + GetPedBoneIndex(PlayerPedId(), Config.ItemDropObjectBone), + Config.ItemDropObjectOffset[1].x, + Config.ItemDropObjectOffset[1].y, + Config.ItemDropObjectOffset[1].z, + Config.ItemDropObjectOffset[2].x, + Config.ItemDropObjectOffset[2].y, + Config.ItemDropObjectOffset[2].z, + true, true, false, true, 1, true + ) + bagObject = bag + holdingDrop = true + heldDrop = newDropId + exports['qb-core']:DrawText('Press [G] to drop the bag') + else + QBCore.Functions.Notify("Your already holding a bag, Go Drop it!", "error", 5500) + end end, } }, distance = 2.5, }) end) - -- NUI Callbacks RegisterNUICallback('DropItem', function(item, cb) From b21febdee61fd0a33875eef12ad4c9e14eec30b5 Mon Sep 17 00:00:00 2001 From: Mechomancer <62558658+Mechomancer@users.noreply.github.com> Date: Wed, 29 May 2024 09:25:52 -0500 Subject: [PATCH 3/3] Update main.lua added source or -1 to the client call --- server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 68b74fe2f..d9e0f4012 100644 --- a/server/main.lua +++ b/server/main.lua @@ -160,7 +160,7 @@ RegisterNetEvent('qb-inventory:server:closeInventory', function(inventory) if Drops[inventory] then Drops[inventory].isOpen = false if #Drops[inventory].items == 0 and not Drops[inventory].isOpen then -- if no listeed items in the drop on close - TriggerClientEvent('qb-inventory:client:removeDropTarget', Drops[inventory].entityId) + TriggerClientEvent('qb-inventory:client:removeDropTarget', -1, Drops[inventory].entityId) Wait(500) local entity = NetworkGetEntityFromNetworkId(Drops[inventory].entityId) if DoesEntityExist(entity) then DeleteEntity(entity) end