├── DynamicTraffic.lua ├── README.md └── fxmanifest.lua /DynamicTraffic.lua: -------------------------------------------------------------------------------- 1 | CreateThread( 2 | function() 3 | while true do 4 | Wait(0) 5 | 6 | local playerPed = PlayerPedId() 7 | local playerId = PlayerId() 8 | 9 | --[[ DISABLE VEHICLE GENERATORS IN PLAYER AREA ]] 10 | 11 | local DensityMultiplier = 1.0 12 | local hour = GetClockHours() 13 | if (hour >= 00 and hour <= 04) then 14 | DensityMultiplier = 0.1 15 | elseif (hour >= 04 and hour <= 05) then 16 | DensityMultiplier = 0.2 17 | elseif (hour >= 05 and hour <= 06) then 18 | DensityMultiplier = 0.3 19 | elseif (hour >= 06 and hour <= 07) then 20 | DensityMultiplier = 0.5 21 | elseif (hour >= 07 and hour <= 10) then 22 | DensityMultiplier = 1.0 23 | elseif (hour >= 10 and hour <= 12) then 24 | DensityMultiplier = 0.5 25 | elseif (hour >= 12 and hour <= 14) then 26 | DensityMultiplier = 0.7 27 | elseif (hour >= 14 and hour <= 15) then 28 | DensityMultiplier = 0.5 29 | elseif (hour >= 15 and hour <= 16) then 30 | DensityMultiplier = 0.7 31 | elseif (hour >= 16 and hour <= 19) then 32 | DensityMultiplier = 1.0 33 | elseif (hour >= 19 and hour <= 21) then 34 | DensityMultiplier = 0.5 35 | elseif (hour >= 21 and hour <= 00) then 36 | DensityMultiplier = 0.3 37 | end 38 | 39 | --[[ DISABLE VEHICLE GENERATORS IN PLAYER AREA ]] 40 | local pos = GetEntityCoords(playerPed) 41 | RemoveVehiclesFromGeneratorsInArea( 42 | pos['x'] - 500.0, 43 | pos['y'] - 500.0, 44 | pos['z'] - 500.0, 45 | pos['x'] + 500.0, 46 | pos['y'] + 500.0, 47 | pos['z'] + 500.0 48 | ) 49 | 50 | --[[ POLICE DISPATCH SPAWNS OFF ]] 51 | for i = 1, 12 do 52 | EnableDispatchService(i, false) 53 | end 54 | SetPlayerWantedLevel(playerId, 0, false) 55 | SetPlayerWantedLevelNow(playerId, false) 56 | SetPlayerWantedLevelNoDrop(playerId, 0, false) 57 | 58 | 59 | -- [[ SET THE DENSITY OF AI]] 60 | SetVehicleDensityMultiplierThisFrame(DensityMultiplier) 61 | SetPedDensityMultiplierThisFrame(DensityMultiplier) 62 | SetRandomVehicleDensityMultiplierThisFrame(DensityMultiplier) 63 | SetParkedVehicleDensityMultiplierThisFrame(DensityMultiplier) 64 | SetScenarioPedDensityMultiplierThisFrame(DensityMultiplier, DensityMultiplier) 65 | 66 | --[[ POLICE IGNORE PLAYER ]] 67 | SetPoliceIgnorePlayer(playerPed, true) 68 | SetDispatchCopsForPlayer(playerPed, false) 69 | 70 | end 71 | end 72 | ) 73 | 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dynamic-Traffic-management [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)] 2 | 3 | :Usefull information:
4 | - Automatically change traffic & peds intensity based on time to create an more realistic environment 5 | 6 | 7 | :CREDITS:
8 | - All credit goes to Me Myself & I? I dunno...
9 | 10 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | games { 'gta5' } 3 | client_script 'DynamicTraffic.lua' --------------------------------------------------------------------------------