someone who knows why the npc police drop in and do not interfere with this code …
local pedindex = {}
function SetWeaponDrops() -- This function will set the closest entity to you as the variable entity.
local handle, ped = FindFirstPed()
local finished = false -- FindNextPed will turn the first variable to false when it fails to find another ped in the index
repeat
if not IsEntityDead(ped) then
pedindex[ped] = {}
end
finished, ped = FindNextPed(handle) -- first param returns true while entities are found
until not finished
for peds,_ in pairs(pedindex) do
if peds ~= nil then -- set all peds to not drop weapons on death.
SetPedDropsWeaponsWhenDead(peds, false)
end
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
SetWeaponDrops()
end
end)
function SetWeaponDrops() -- This function will set the closest entity to you as the variable entity.
local handle, ped = FindFirstPed()
local finished = false -- FindNextPed will turn the first variable to false when it fails to find another ped in the index
repeat
if not IsEntityDead(ped) then
pedindex[ped] = {}
end
finished, ped = FindNextPed(handle) -- first param returns true while entities are found
until not finished
EndFindPed(handle)
for peds,_ in pairs(pedindex) do
if peds ~= nil then -- set all peds to not drop weapons on death.
SetPedDropsWeaponsWhenDead(peds, false)
end
end
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
SetWeaponDrops()
end
end)
You should ask @JinkLeft it’s his code. But some have already stated it works sometimes and sometimes it don’t. I haven’t had a problem with it yet. In the future don’t create a thread for an issue. Ask in the thread you got the code from.
Sorry for the late reply. I’m not as actIve as I used to be on the forums. I’m glad you got the issue worked out. If you have any other issues please let me know.
I have a development server ect but I just don’t actually develop anymore currently as I’ve been pretty busy IRL and I never actually tested that script. It was just a modification of script I used at the request of a friend and they told me it worked so I figured I’d throw it to the community if they wanted to mess around with it.