Traffic lights

Is it possible to change a traffic light’s state?
Or will it be with OneSync?

Try this one

https://runtime.fivem.net/doc/natives/#_0x57C5DB656185EAC4

1 Like

Thank you I will try out this.

1 Like

What is the model of the traffic light?
EDIT: Nvm I got it. It’s prop_traffic_01a but it has same other models too.

Hmm it works… but the AI don’t care about the overwritten lights… any idea how to make AI care about the overwritten lights?
Also setting the value to 5 seems like to change the traffic light back to dynamic state.

I’ve seen others comment that the AI ignores the overridden lights.

My best guess would be play around with their driving styles… long shot but maybe one of the unknown flags actually tells them to obey the override

Checkout this great resource from @Vespura https://www.vespura.com/drivingstyle/

I will check it out but how can I detect a ped/vehicle/entity is stopped at a specific traffic light? Because without that I can’t really control their driving style.

I think you’d just set the driving style of all AI vehicles to include the flag to obey traffic signal overrides…

assuming there even is a flag for that but hopefully one of the as yet undefined ones actually does this

Peds already driving might not observe your new traffic light state. Try creating a new ped and giving it a task with normal driving style.

That would be little too complicated, I don’t want to replace the whole AI vehicles with a script.
I want a script with you can change a traffic light to green for example in a bus. I don’t know what it called IRL but that would be great in FiveM.

I assume that by bus you mean ambulance, if you’re already running sirens try this, AI should be have much more reasonably, it won’t actually make them care that you changed the light but they should respect your sirens better (though unfortunately, as in real life, not always)

Thanks, I already used this mod. By bus I mean really a scheduled bus, a city bus or something, sometimes buses have little remote controls to not 30 minutes at a single red light.

gotcha, yeah the same black box EMS uses, a lot like a garage door opener really.

yeah I think you’re just going to have to experiment, see if any of those driving style flags actually get them to consider the light state override.

Also the other response about whether it works for newly spawned peds (spawned after the override takes place) is interesting.

Pure speculation here but it might also have to do with driving tasking (you may have to clear the driving task / clear all tasks, for nearby AIs and then toggle the light and then assign driving task to them again (to random destinations I suppose, not sure if you can cache their previous one). Because it may be that the AI is able to predict default light states and does so when it plans the route rather than evaluating lights in real time as it travels… or they may check lights ahead periodically but not frequently enough for you to see a difference because cars approaching the intersection when you flipped the light have already made their decisions about whether to proceed through the intersection or not… but really … unfortunately … who knows.

Fun and interesting problem though

im trying to make the same thing have you found out how do do it or what all the lights models are?