Skip to content

Commit

Permalink
fixed delete mb on disable resource
Browse files Browse the repository at this point in the history
  • Loading branch information
L0stedMrlion authored Jun 8, 2024
1 parent 1ff95ea commit 4c6073b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ AddEventHandler("lion_medibag:pickupMedbagResponse", function(canCarry, medibagN
local medibag = NetworkGetEntityFromNetworkId(medibagNetId)
if medibag ~= 0 then
DeleteEntity(medibag)
for i, bag in ipairs(bags) do
if bag == medibag then
table.remove(bags, i)
break
end
end
end
else
Notify("Medibag", Config.Locale["cantcarry"], 2000)
end
end)


RegisterNetEvent("lion_medibag:place")
AddEventHandler(
"lion_medibag:place",
Expand All @@ -56,6 +62,7 @@ AddEventHandler(
local newMedBag = CreateObject(medibagprop, pedCoords.x, pedCoords.y, pedCoords.z - 1, true, false, false)
SetEntityHeading(newMedBag, GetEntityHeading(playerPed))
PlaceObjectOnGroundProperly(newMedBag)
table.insert(bags, newMedBag)
end
end
)
Expand All @@ -64,9 +71,9 @@ AddEventHandler(
"onResourceStop",
function(resourceName)
if resourceName == GetCurrentResourceName() then
for _, bag in pairs(bags) do
if DoesEntityExist(bag) then
DeleteEntity(bag)
for _, medibag in pairs(bags) do
if DoesEntityExist(medibag) then
DeleteEntity(medibag)
end
end
end
Expand Down

0 comments on commit 4c6073b

Please sign in to comment.