man0s / ReducedNPCs

📜 A simple FiveM script for reducing NPCs density, written in Lua.
GNU General Public License v3.0
20 stars 10 forks source link

[SUGGESTION] Allow selection of specific NPCs to disable #1

Open SirHaxe opened 3 years ago

SirHaxe commented 3 years ago

For example: Let normal people drive around, but disable cops, firetrucks and ambulance!

Aniol0012 commented 3 months ago

This can be easly implemented with something like this:

config.lua:

-- Density values from 0.0 to 1.0.
DENSITY_MULTIPLIER = 0.1 -- 10% of the normal density
EMERGENCY_DENSITY_MULTIPLIER = 0.0 -- 0.0 to prevent emergency vehicles and peds from spawning

SPAWN_COPS = false
SPAWN_AMBULANCE = false

client.lua:

local config = {
   DENSITY_MULTIPLIER = DENSITY_MULTIPLIER,
   EMERGENCY_DENSITY_MULTIPLIER = EMERGENCY_DENSITY_MULTIPLIER,
   SPAWN_COPS = SPAWN_COPS,
   SPAWN_AMBULANCE = SPAWN_AMBULANCE
}

Citizen.CreateThread(function()
   while true do
       Citizen.Wait(0)

       -- General density settings
       SetVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetPedDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetRandomVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetParkedVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetScenarioPedDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER, config.DENSITY_MULTIPLIER)

       -- Police settings
       SetDispatchCopsForPlayer(PlayerId(), config.SPAWN_COPS)
       SetCreateRandomCopsNotOnScenarios(config.SPAWN_COPS)
       SetCreateRandomCopsOnScenarios(config.SPAWN_COPS)
       SetCreateRandomCops(config.SPAWN_COPS)

       -- Emergency services settings
       if not config.SPAWN_AMBULANCE then
           -- Disable dispatch services for emergency vehicles
           for i = 1, 15 do
               EnableDispatchService(i, false)
           end
       end
   end
end)
man0s commented 2 weeks ago

This can be easly implemented with something like this:

config.lua:

-- Density values from 0.0 to 1.0.
DENSITY_MULTIPLIER = 0.1 -- 10% of the normal density
EMERGENCY_DENSITY_MULTIPLIER = 0.0 -- 0.0 to prevent emergency vehicles and peds from spawning

SPAWN_COPS = false
SPAWN_AMBULANCE = false

client.lua:

local config = {
   DENSITY_MULTIPLIER = DENSITY_MULTIPLIER,
   EMERGENCY_DENSITY_MULTIPLIER = EMERGENCY_DENSITY_MULTIPLIER,
   SPAWN_COPS = SPAWN_COPS,
   SPAWN_AMBULANCE = SPAWN_AMBULANCE
}

Citizen.CreateThread(function()
   while true do
       Citizen.Wait(0)

       -- General density settings
       SetVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetPedDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetRandomVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetParkedVehicleDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER)
       SetScenarioPedDensityMultiplierThisFrame(config.DENSITY_MULTIPLIER, config.DENSITY_MULTIPLIER)

       -- Police settings
       SetDispatchCopsForPlayer(PlayerId(), config.SPAWN_COPS)
       SetCreateRandomCopsNotOnScenarios(config.SPAWN_COPS)
       SetCreateRandomCopsOnScenarios(config.SPAWN_COPS)
       SetCreateRandomCops(config.SPAWN_COPS)

       -- Emergency services settings
       if not config.SPAWN_AMBULANCE then
           -- Disable dispatch services for emergency vehicles
           for i = 1, 15 do
               EnableDispatchService(i, false)
           end
       end
   end
end)

Thanks for your comment and contribution. Can you make a PR so we can have this functionality in the script?