View Issue Details

IDProjectCategoryView StatusLast Update
0004120Multi Theft Auto : San AndreasServerpublic2010-07-08 01:22
ReporterKaltsu Assigned ToPeter  
Status resolvedResolutionfixed 
Target Version1.1Fixed in Version1.1 
Summary0004120: Synchronized traffic lights

Would be nice to get the traffic lights synchronized since this would be a benefit for different gamemodes, especially RPG servers.

TagsNo tags attached.



2009-03-24 19:41

viewer   ~~0008615

Last edited: 2009-03-24 22:14

Forum topics related to the subject:


2009-03-24 20:56

viewer   ~~0008616

Yes please this would be great, although I know that this would kill the server's bandwidth but it would be an awesome feature especially for RolePlaying.
Would have to be done for pedestrian traffic too in my opinion.


2009-03-24 20:58

reporter   ~~0008617

Last edited: 2009-03-24 21:00

IMO this isn't important nor useful enough to be considered any kind of priority. Also, there must be hundreds of sets of traffic lights in SA, syncing them all isn't plausible. Maybe having all of them the same would be an option, though.

Also, if it "kills the server's bandwidth," being an "awesome feature" isn't really a good enough reason to justify it, is it? ;)


2009-03-24 21:05

administrator   ~~0008618

This is not worth the effort at all imo. In the absolute majority of gamemodes, players will be completely ignoring traffic lights. Waste of reversing and coding time and of bandwidth.


2009-03-25 00:40

administrator   ~~0008624

Its still a feature that has been requested time and time again. Despite its low gain, if its every implemented it would still have some value to it.

Leave this as an issue to any outsiders who are willing to submit a patch.


2009-03-25 00:52

viewer   ~~0008626

Last edited: 2009-03-25 01:17

The traffic lights change in turns, depending if they are pointing more towards North/South or more towards West/East, no matter where in the map the light is located (tested in Map Editor). So basically there are 2 different sets of traffic lights that would need to be synced.

Here is the timeline for the loop:
0:00 - Set 1 turns green / Set 2 stays red
0:12 - Set 1 turns red / Set 2 turns green
0:22 - Set 2 turns red / Set 1 stays red
0:31 - Set 1 turns green / Set 2 stays red
Total: 31 seconds

Set 1 = Pointing towards North/South
Set 2 = Pointing towards West/East

Both of the lights stay red for the last 9 seconds of the loop, because that's the only period in the loop when the pedestrian lights for both sets turn white.

However, at the moment it seems that the sync of the traffic lights between two players depends on their FPS.
Any way to make it depend on e.g. server time?


2009-03-26 07:26

viewer   ~~0008637

". . . . . syncing them all isn't plausible."
I never said to synchronize the whole lot, just maybe the ones in the perimeter of the player? As in to save bandwidth only those close to the player shall change, then when the player leaves they shall stop. Get it?


2009-03-26 23:29

viewer   ~~0008651

As I explained, all the lights heading North/South change at the same moment all over San Andreas. Same naturally goes for the lights heading West/East.

Therefore I guess it might be enough to sync even one (or two) traffic light pole between the players, since all of the other poles in the map are automatically in sync with each other.


2009-03-29 04:42

reporter   ~~0008685

I found the function addresses, 0x49dab0 (if ret is written, all traffic lights go blank (including pedestrian walk lights), and 0x156e5bc (if ret is written, the traffic ignore the traffic lights (in the origional game)). Maybe someone can have a look around at these addresses and find the memory addresses that they read from. Or maybe just write ret to 0x49dab0 (to keep them all blank) just for now until they are synced. Maybe if someone finds the memory addresses, a script function can be made that sets them, then someone can make a resource with a timer to set them at specific intervals. (There is no real need to sync them to a player because its much simpler to use a server-side timer)


2009-05-10 14:17

developer   ~~0009130

Small note about the patch;
ryden apparently experiences a crash with it at the switch statement in HOOK_CTrafficLights_GetPrimaryLightState(). I fail to reproduce this on three computers.


2009-05-10 14:19

administrator   ~~0009131

If the main game timer was just synced, this should just work - the value is the one returned from CGame::GetSystemTime(). I'm not sure if that'd have side effects, but it's worth trying.

0x49D350 and 0x49D3A0 return (I think) 0, 1 or 2 indicating the phase of the light for each of the two sets. This could be hooked to return whatever is desired and a script function could be added called something like setTrafficLightState(eastOrWest,state). They could be made to do this per actual traffic light entity, but I'm not sure how scripts could refer to the lights that already exist in the world - it could be done for MTA-created elements.


2009-05-10 14:39

administrator   ~~0009133

Peter, is it practical to be able to set the two sets of lights independently rather than having to do both at once?


2009-05-10 14:42

developer   ~~0009134

There'd be lists of "traffic light ID's" with maps and all making things very complex; I don't really see the advantage of enabling per-light control, even though I do agree it would be a possiblity.

Synching the game timer would be an option, it could also be used for various other things (clouds and even waves/wind movements if it'd be high-res enough). I haven't touched MTA code for quite a while however, and I'd prefer if someone who's more familiar with the current codebase did such a change.

Right now there are nine states for the traffic lights;


2009-05-13 09:02

viewer   ~~0009224

In my opinion synching the game timer would possibly be the best option.


2009-06-17 18:35

administrator   ~~0009645

The previous patch was vastly outdated, so i manually merged them to r1111 (it just excludes some credits with Peter's name in it that i didnt bother adding, which probably should go in).

Around 6-7 of us tested and we all got it working fine.


2009-06-17 18:39

manager   ~~0009646

You forgot me.


2009-07-12 13:46

viewer   ~~0009935

Is the patch included in any of the nighty builds yet by default?


2009-07-12 13:46

administrator   ~~0009936

Is this report resolved?


2009-07-12 16:03

updater   ~~0009938

the patch isnt included yet
if you apply it arc_ it will be resolve


2009-07-12 16:04

administrator   ~~0009939

Yes, be warned that some people crash with the patch. In particular i think it applies to debug mode. If that is fixed i think we're good to go.


2009-07-21 00:26

viewer   ~~0010052

maybe add an option to get the traffic light element to have the feature to set it to:

  1. normal
  2. yellow flashing
  3. blank (to simulate "out of service")


2009-09-15 21:14

viewer   ~~0010493

Any updates on this? Anyone been able to fix the crashing with the patch?


2010-03-04 07:22

viewer   ~~0011116

I think since files are already included, we need to prioritize testing. In-fact, I might start tomorrow.


2010-06-01 01:27

administrator   ~~0011540

This would be a nice feature to have, and seems fairly simple?

The patch is probably out of date now though.


2010-07-02 16:21

reporter   ~~0011670

Last edited: 2010-07-02 16:26

Tested in r1800, works fine in release just debug mode I've attached a patch file for r1800 for anyone who wants to try and fix this


2010-07-06 02:23

administrator   ~~0011692

I've opened a TrafficLights branch, so this can be mantained properly.

Issue History

Date Modified Username Field Change