Removing NPC's from Specific location

#1

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.

#2

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

1 Like
#3

Okay so technically you’re saying

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

I’ll give it a shot, thanks!

#4

Thank you!!

#5

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

#6

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);

#7

thank you man :smiley:

#8

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

#9

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) ??

#10

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

#11

@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)