I can't find anything that will delete exploded vehicles

Hi there guys!

I’ve got a clearitall resource that admins can use to clear certain things in a radius and it works fine for props, peds and vehicles but if it’s a vehicles that’s crashed, exploded or spawned by an exploiter and dropped from the sky, it does not work. I’ve tried absolutely all of the natives I could find but nothing touches them. Even ClearAreaOfEverything doesn’t clear them.

Does anyone have a method of getting rid of these vehicle carcasses? If so, I’d greatly appreciate the insight on handling them.

Thanks for your time!

This might help you: https://runtime.fivem.net/doc/natives/#_0x957838AAF91BD12D

I’ve gotten a chance to read a hundred threads, post in numerous discords and try as many natives that looked useful but still no joy. I’ve added this to my loop but it’s still not clearing exploded objects(like the cargoplanes):

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(500)
            if eraser then
                local player = PlayerId()
                local playerPed = GetPlayerPed(-1)
                local coord = GetEntityCoords(playerPed, true)
                ClearAreaOfEverything(coord, 100.00, false, false, false, false)

                local handle, object = FindFirstObject()
                local finished = false
                repeat
                Wait(1)
                
                NetworkRequestControlOfEntity(handle)
		SetEntityHealth(handle, 100)
		SetVehicleBodyHealth(handle, 100)
		SetVehicleEngineHealth(handle, 100)
                SetEntityAsNoLongerNeeded(handle)
                DeleteEntity(handle)
        
                finished, object = FindNextObject(handle)
        
                until not finished
                EndFindObject(handle)
            end    
        end
end)

I have also read this post and have changed the manifest to the one indicated without any success.

Does someone have an idea of what else I could try to get these damned things to disappear?

Thanks for your time!

Don’t try to request control of network objects - instead, run your code on all clients and act on objects they already own.

This script is running on all clients but in spite of that, these objects aren’t being removed. If I had to guess, it’s because they’re being added by a player that’s not in that area via mod menu or perhaps you lose control of something after it has exploded. Whatever the reason, It’s a pretty big deal for the legitimate players that these items can’t be removed without a server restart which is very disruptive to play.

The second important point is that these were planes I spawned so I should already own them. In spite of the fact that I should be the one in control of them, I can’t delete them. It seems as if nobody can work on a vehicle after it has blown up.

If anyone knows of a way to remove these exploded vehicles, I’d love to hear about how you managed to do it!

this topic is a bit old and sorry for bumping this but i may have a way to solve this issue

using ClientPools you can scan for blacklisted vehicles and delete them (it doesnt specifically look for blown up ones but rather just the vehicle model in general)

local blacklistedvehicles = {
    "rhino",
    "deluxo2",
    "khanjali",
    "scarab",
    "scarab2",
    "scarab3",
    "APC",
    "thruster",
    "voltic2",
    "oppressor",
    "oppressor2",
    "vigilante",
    "hunter",
    "akula",
    "buzzard",
    "tampa3",
    "ruiner3",
    "ruiner2",
    "dukes2",
    "zr380",
    "zr3802",
    "zr3803",
    "shafter5",
	"shafter6",
    "raptor",
    "paragon2",
    "lazer",
    "kuruma2",
    "jester2",
    "hotring",
    "buffalo3",
    "blista3",
    "scramjet",
    "shotaro",
    "deathbike",
    "deathbike2",
    "deathbike3",
    "bati2",
    "technical",
    "technical2",
    "technical3",
    "rcbandito",
    "nightshark",
    "monster",
    "monster2",
    "monster3",
    "monster4",
    "monster5",
    "menacer",
    "marshall",
    "insurgent",
    "insurgent2",
    "insurgent3",
    "dune4",
    "dune5",
    "dune3",
    "dune2",
    "dune",
    "caracara",
    "bruiser3",
    "bruiser2",
    "bruiser",
    "blazer5",
    "dump",
    "cutter",
    "handler",
    "trailerlarge",
    "armytanker",
    "armytrailer",
    "armytrailer2",
    "tractor",
    "boxville5",
    "tug",
    "valkyrie",
    "valkyrie2",
    "savage",
    "cargobob",
    "cargobob4",
    "cargobob3",
    "buzzard",
    "avenger",
    "avenger2",
    "blimp",
    "blimp2",
    "blimp3",
    "bombushka",
    "cargoplane",
    "hydra",
    "jet",
    "mogul",
    "strikeforce",
    "titan",
    "tula",
    "volatol",
    "pbus2",
    "brickade",
    "barrage",
    "barracks",
    "barracks2",
    "barracks3",
    "chernobog",
    "halftrack",
    "minitank",
    "trailersmall2",
    "terbyte",
    "phantom2",
    "cerberus",
    "cerberus2",
    "cerberus3",
    "cablecar",
    "freight",
    "freightcar",
    "freightcont1",
    "freightcont2",
    "freightgrain",
    "tankercar",
    "metrotrain",
    "cog552",
    "cognoscenti2",
    "limo2",
	"xls2",
	"baller5",
	"baller6",
}

Citizen.CreateThread(function()
    while true do
	Citizen.Wait(4000)
    local vehiclepool = GetGamePool("CVehicle")
        for i=1, #vehiclepool do
            for e=1, #blacklistedvehicles do
                if IsVehicleModel(vehiclepool[i], GetHashKey(blacklistedvehicles[e])) and DoesEntityExist(vehiclepool[i]) then
                    NetworkRequestControlOfEntity(vehiclepool[i])
                    DeleteEntity(vehiclepool[i])
					table.remove(vehiclepool, i)
                else
				end
            end
        end
    Citizen.Wait(0)
    end
end)

1 Like