Skip to content

Mechomancer patch 1 #526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
45 changes: 28 additions & 17 deletions client/drops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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', -1, 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
Expand Down
Loading