SAFScriptsDocs

Configuration

SAF Traffic is coming soon. These docs describe the build that will ship.

On this page

Everything you would want to change is in config.lua. Staff rules, logs and announcements are in bridge/, covered in Custom servers.

General

OptionDefaultWhat it does
Config.Framework'auto''auto', 'qbx', 'qb', 'esx', 'nd', 'ox' or 'standalone'
Config.StaffAce'traffic.staff'ACE that opens the panel and the staff commands
Config.StaffGroupsadmin, god, superadminFramework groups that also count as staff
Config.SpeedUnit'mph'Speeds in the panel, announcements and exports: 'mph' or 'kmh'
Config.WarnConflictstrueConsole warning when another density script is running

Commands and keys

Set a command to false to turn it off.

OptionDefaultWhat it does
Config.Commands.Panel'traffic'Staff traffic panel with the road map
Config.Commands.PanelKey''Default key for the panel. Players can rebind it. '' means no default key
Config.Commands.Density'trafficdensity'/trafficdensity rush. Staff, also works from the server console
Config.Commands.Clear'trafficclear'/trafficclear removes every closure, jam and speed zone

Density

OptionDefaultWhat it does
Config.Density.Start'normal'Preset on first start
Config.Density.Presets5 presetsThe presets in the panel and for /trafficdensity

Multipliers run from 0 to 1 (GTA ignores anything above 1). Budgets are the population budget levels 0 to 3.

KeyWhat it does
id, labelPreset id and the name in the panel
vehicleTraffic density
randomRandom cars
parkedParked cars
pedPedestrians
scenarioScenario peds (people sitting, working, standing around)
vehicleBudget, pedBudgetHow many cars and peds the game may spawn in total, 0 to 3
rushClosures and jams marked "Rush hours" switch on while this preset is active
boostExtra jam intensity steps for those rush-hour jams
PresetTrafficParkedBudgetsRush
Empty0.00.00
Light0.350.52
Normal1.01.03
Rush hour1.00.83yes
Gridlock1.01.03yes, boost = 1

Rush hour schedule

While the schedule is on, these windows switch to their preset on their own and back to the panel's density afterwards. It uses the SAF Weather clock when SAF Weather runs, otherwise the game clock.

OptionDefaultWhat it does
Config.Schedule.EnabledfalseTurn the schedule on
Config.Schedule.Windows07:00 to 09:00, 16:00 to 19:00{ from, to, preset } for each window
Config.Schedule.MaxWindows6Most windows staff can add in the panel

Jams

A jam slows AI on its roads with speed zones and can add its own cars. Speeds here are in m/s.

LevelLabelSpeedExtra carsStop and go
1Slow9.00
2Heavy5.08
3Crawl2.514
4Stopped0.818yes
OptionDefaultWhat it does
Config.Jam.StopGo{ StopSpeed = 0.0, GoSpeed = 3.0, StopSeconds = 9, GoSeconds = 6 }The zone switches between stopped and creeping, like real stop and go
Config.Jam.MinRadius25Smallest jam circle, metres
Config.Jam.MaxRadius600Largest jam circle, metres
Config.Jam.MaxCarsPerJam24Extra AI cars per jam
Config.Jam.MaxCarsTotal60Extra AI cars across all jams
Config.Jam.ActiveRange400Someone must be this close to a jam for its cars to exist
Config.Jam.MinPlayerDistance60Never spawn a car closer than this to a player
Config.Jam.LeaveMargin150Cars that drive this far out of the jam are recycled when nobody is close
Config.Jam.SpawnPerTick3Cars spawned per tick
Config.Jam.TickSeconds2Seconds between ticks
Config.Jam.CruiseSpeed12.0m/s. The speed zones slow them down inside the jam
Config.Jam.DrivingStyle786603Driving style flags: normal, stops at lights
Config.Jam.Vehicles34 modelsEveryday cars, SUVs, vans and trucks the jam cars are picked from
Config.Jam.Drivers12 modelsPed models for the drivers

The extra cars are spawned by the server, so they work with entity lockdown. The player who owns each driver in OneSync keeps it driving.

Closures

Closed roads are switched off for AI on every client, so traffic routes around them. 'slow' closures keep the road open but slow, for one lane or roadworks.

OptionDefaultWhat it does
Config.Closures.SlowSpeed10Default speed for slow closures and detour routes, in Config.SpeedUnit
Config.Closures.PropstrueDefault for "Place props"
Config.Closures.PedsfalseDefault for "Close footpaths"
Config.Closures.JunctionTrim4.0Metres kept open at each end so crossing roads still work
Config.Closures.MaxArea1500Largest side of an area closure, metres

Props

Barriers, cones and an arrow board at the ends of closures. Spawned by the server and removed with the closure.

OptionDefaultWhat it does
Config.Props.EnabledtrueTurn props off entirely
Config.Props.Barrier'prop_barrier_work05'Barrier model
Config.Props.Cone'prop_roadcone02a'Cone model
Config.Props.Board'prop_trafficdiv_01'Arrow board on the approach. false leaves it out
Config.Props.MaxPerItem36Props per closure
Config.Props.MaxTotal220Props across all closures

Speed zones

OptionDefaultWhat it does
Config.SpeedZones.Default20Default limit, in Config.SpeedUnit
Config.SpeedZones.Min0Lowest limit staff can set
Config.SpeedZones.Max70Highest limit staff can set
Config.SpeedZones.MaxPerItem40Road-following items are built from up to this many zones
Config.SpeedZones.MaxTotal160Zones across all items

Items

Closures, jams, speed zones and detours are all items.

OptionDefaultWhat it does
Config.Items.MaxActive60Most items active at once
Config.Items.MaxMinutes720Longest end timer
Config.Items.LabelLength48Longest label
Config.Items.MaxRoads40Roads one item can cover

Announcements

OptionDefaultWhat it does
Config.Announce.Default'nearby''off', 'nearby' or 'all'. The panel picks per item
Config.Announce.Range800Metres for 'nearby'

Map

OptionDefaultWhat it does
Config.Map.ShowAllPlayerstrueStaff see every player on the map
Config.Map.PlayerRefresh2Seconds between player position updates
Config.Map.Teleporttrue"Go to" in the panel. Every use is logged

Postals

OptionDefaultWhat it does
Config.Postals.EnabledtrueShow postal codes on the map
Config.Postals.ResourcefalseResource that has the postal file. false reads it from the saf-traffic folder
Config.Postals.File'postals.json'Path to the file inside that resource

Road scan

OptionDefaultWhat it does
Config.Scan.Bounds{ -4096, -4096, 4608, 8192 }minX, minY, maxX, maxY. The whole of San Andreas
Config.Scan.Tile512Tile size in metres. Matches the game's path regions
Config.Scan.Step24Sample spacing in metres
Config.Scan.LandStep32Land outline resolution in metres
Config.Scan.CallsPerFrame220Lower it if the scanner's game stutters
Config.Scan.LoadWait3000Milliseconds to wait for a tile's road data to load

Saving and limits

OptionDefaultWhat it does
Config.Save.ItemstrueClosures, jams, zones, density and schedule survive restarts (state.json)
Config.RateLimit.Actions30Actions per player per window
Config.RateLimit.Window10Window length in seconds
SAF Scripts by San Andreas' Finest StoreDiscordsupprot@safrp.org

Not affiliated with or endorsed by Rockstar Games, Take-Two Interactive or Cfx.re.