Removing NPC's from Specific location

Howdy,

So I know there is a native call to remove NPCS from an area, but it doesn’t seem to be working, most likely because my implementation is incorrect. Just trying to figure out what I need to do to fix it.

I’ve added in my main.lua for the client side of things

Citizen.CreateThread(function()
    while (true) do
		ClearAreaOfPeds(470.00, -990.00, 25.00, 10000, 1)
        Citizen.Wait(0)
    end
end)

Any suggestions / input? I’ve managed to get a functional server, but writing this lul on my part. I should add, that I’m not trying to remove NPC’s from the map, just from a certain location on the map.

1 Like

Radius is a float so need to end with a .0

1 Like

Okay so technically you’re saying

ClearAreaOfPeds(470.00, -990.00, 25.00, 10000.0, 1) ??

I’ll give it a shot, thanks!

Thank you!!

what about removing npc’s car from a specific location?

https://runtime.fivem.net/doc/natives/#_0x01C7B9B38428AEB6

There is a native for it;

CLEAR_AREA_OF_VEHICLES(0, 0, 0, 10000, false, false, false, false, false);

So you can implement with something like

ClearAreaOfVehicles(-555.65, 285.38, 82.18, 10.0, false, false, false, false, false);

thank you man :smiley:

Hey guys, anyone can send me a template of this ? Sorry but i’m new to this and can’t workout on a solution :\

Just put this in a client file @afonsoamaral

Citizen.CreateThread(function()
    while (true) do
		ClearAreaOfPeds(470.00, -990.00, 25.00, 50.0, 1)
        Citizen.Wait(0)
    end
end)

Obviously replace the coordinates to where you need them and the radius.

ClearAreaOfPeds(x.x, x.x, x.x, x.x, 1) ??

@ItzBlakeBro the thing is that i’m trying to put on a map, so i’d have to create the file from scratch…

@afonsoamaral Sure no problem

So, create a folder like I did called “cleararea”

make a __resource.lua file with

resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937"

client_scripts {
    "client/main.lua"
}

Then for client/main.lua

Citizen.CreateThread(function()
    while (true) do
		ClearAreaOfPeds(470.00, -990.00, 25.00, 50.0, 1)
        Citizen.Wait(0)
    end
end)

is this script only for NPCs or also for Vehicle Spawns?

So you can use something like

Citizen.CreateThread(function()
    while (true) do
		ClearAreaOfVehicles(-555.65, 285.38, 82.18, 10.0, false, false, false, false, false);
        Citizen.Wait(0)
    end
end)

it does not work :sob:
Will it be because I have onesync?

Honestly not sure, seems to work fine for me and I’m running a normal 32