Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local guard = GetHashKey("s_m_m_prisguard_01")
SetPedDropsWeaponsWhenDead(guard, false)
end
end)
Tried many different variations, cant get this native to work.
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local guard = GetHashKey("s_m_m_prisguard_01")
SetPedDropsWeaponsWhenDead(guard, false)
end
end)
Tried many different variations, cant get this native to work.
In
SetPedDropsWeaponsWhenDead(Ped ped, BOOL toggle)
the ‘ped’ has to be an actual ped entity, not just the hash key.
In other words: it isn’t so easy to toggle weapon dropping for all peds of a certain type, afaik.
What it means by ped is exactly what @mraes mentioned. Its just looking for a specific ped identifier, not a ped skin.
Can someone just give us a workin code with disabled weapon for cops?
No, find a way to do it yourself, @mraes has described perfectly what is wrong with the above code, use that.
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
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)
This is a script I did for someone to disable peds from dropping weapons. You can try adapting it if you’d like to whatever. Just post your results for others. Also be sure to thank @supa for the find ped part
I’ll do it when I get home if it’s not done but I’m on my phone now.
Thanks it works.
But why is it workin only with Pistols.
The military can still drop M4
I don’t know I’d have to do some testing to figure it out maybe the peds aren’t for military aren’t the same. You can do some testing with the results if you want.
I’ve never actually ran the script myself I just did a quick make up for a friend.
Sometimes it works and sometimes it is not workin. Any idea?