Remove weapons from NPCs?

Hi there,

I am trying to get rid of weapons from military, mayweather and cops, etc. I’ve been using
“RemoveAllPickupsOfType(GetHashKey(‘PICKUP_WEAPON_CARBINERIFLE’))”, etc for a while but I learned the hard way that when people drop their guns to give to other people the server eats it up.

I was wondering how could I go about resolving this issue?

Thanks for your time and help!

1 Like

Client side only.

function GetPeds()
	local peds       = {}
	for ped in EnumeratePeds() do
		local found = false
		if not found then
			table.insert(peds, ped)
		end
	end
	return peds
end

function PedInPlayerRadius(coords, area) 
	local peds       = GetPeds()
	local pedsInArea = {}

	for i=1, #peds, 1 do
		local pedCoords = GetEntityCoords(peds[i])
		local distance  = GetDistanceBetweenCoords(pedCoords, coords.x, coords.y, coords.z, true)

		if distance <= area then
			table.insert(pedsInArea, peds[i])
		end
	end
	
	return pedsInArea

end
------------------------------------------------------------------------------
Citizen.CreateThread(function()
    while true do
	Citizen.Wait(3333)	-- Every Three Seconds repeatedly do
	-- Set Your Player as centre. 
	local iPed = GetPlayerPed(-1)
	local iPedx = GetEntityCoords(iPed)
	-- Target Peds as the array and xx being the distance around the player.
	--
	local Target = PedInPlayerRadius(iPedx, 86)
	-- For each ped inside the Target array pulled from
	for i=1, #Target, 1 do
		-- Are we sure its a ped?
		if not IsPedAPlayer(Target[i]) then
			-- If Entity is not dead then...
			if not IsPedDeadOrDying(Target[i]) then
				-- Dont Drop Guns!
				SetPedDropsWeaponsWhenDead(Target[i], false)
					if IsEntityAMissionEntity(Target[i]) then 
						break
					else
						RemovePedElegantly(Target[i])
					end
			else
				-- Now if they are dead, I want to make sure we tell the server they are not needed. "CLEAN UP ISLE 7"
				if IsEntityDead(Target[i]) then
					if IsPedInAnyVehicle(Target[i], false) then
						RemovePedElegantly(Target[i])
					end
				end
			end
		end
	end	
    end
end)
------------------------------------------------------------------------------

It’s an old one but seems to do just fine for me.

1 Like

hey did you manage to find something?