[Release] Dynamic NPCs

Here’s a script that allows you to set certain options and densities that change depending how many players are on the server. It allows you to set the following values:

    a_players_under_1 = { -- This will by checked first and trigger if the playercount on the server is below 1
        VehicleDensityMultiplier = 0, -- 0.00 - 1.00
        ParkedVehicleDensityMultiplier = 0, -- 0.00 - 1.00
        PedDensityMultiplier = 0, -- 0.00 - 1.00
        ScenarioPedDensityMultiplier = 0, -- 0.00 - 1.00
        DisabledDispatchServices = { -- Which dispatch services to disable
            PoliceAutomobile = true,
            PoliceAutomobileWaitPulledOver = true,
            PoliceAutomobileWaitCruising = true,
            PoliceRoadBlock = true,
            PoliceRiders = true,
            PoliceVehicleRequest = true,
            PoliceHelicopter = true,
            PoliceBoat = true,
            SwatAutomobile = true,
            SwatHelicopter = true,
            ArmyVehicle = true,
            FireDepartment = true,
            AmbulanceDepartment = true,
            Gangs = true,
            BikerBackup = true
        },
        DisableCops = true -- Wether cops will chase the player or not
    }

You can set up rules in the config file that get worked through in alphabetical order (from a_* to z_*)
For example b_players_under_2 would mean its the second rule that gets checked and applies if the total players on the server are below two (0 and 1).
You can also work with percentages so c_percent_under_20 would be checked third and would apply if below 20% of the servers max players are online.

NOTE: This script replaces the old version: [Release] NPC Control

8 Likes

Just a few tips.

  1. iirc EnableDispatchService(i, false) doesn’t need to be looped in a thread. You only need to run that once.
  2. You should use SetMaxWantedLevel(0) instead of looping the wanted level stuff like you did.

Thanks for the suggestions, will implement them next time i make a change, do you by chance know which one of the dispatch services is what?

I incorporated your proposed changes and also allowed for individual control over which dispatch services are disabled in the config

i wonder if there’s any way to make it increase/decrease density based on time of day, for example:
Day time: more peds in general, Night time: Very few peds walking on the sidewalks/out and about, fewer cars on the road

1 Like

not working for me

not working for me

Literally what I’m looking for

work for u ?

Never tried