How can i remove all NPC from server?

Hello, i’d like to know is there a way to remove all NPC from the server ?

2 Likes

You have some natives for this like
SetVehicleDensityMultiplierThisFrame() and SetPedDensityMultiplierThisFrame()

Example:

Citizen.CreateThread(function()
	while true do
	    Citizen.Wait(0)
	    SetVehicleDensityMultiplierThisFrame(0.0) -- removes people walking around
        SetPedDensityMultiplierThisFrame(0.0) -- remove vehicles driving
	end
end)

And as you can see no AI :smile:

1 Like

So i create a _resource.lua and a client.lua then i put this Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
SetVehicleDensityMultiplierThisFrame(0.0) – removes people walking around
SetPedDensityMultiplierThisFrame(0.0) – remove vehicles driving
end
end)

Into the client and it should work ?

i just tried with the thing u send but there is pnj anyways…

Should work, any errors?

Put it in resource.lua or client.lua?

1 Like

yea it works… and no errors for me then

fxmanifest.lua

fx_version'bodacious'
game'gta5'

client_script'client.lua'

client.lua

Citizen.CreateThread(function()
	while true do
	    Citizen.Wait(0)
	    SetVehicleDensityMultiplierThisFrame(0.0) -- removes people walking around
        SetPedDensityMultiplierThisFrame(0.0) -- remove vehicles driving
	end
end)

and call the folder anything u want as all here up been said

1 Like