[FREE][Standalone] Waypoint Traffic Lights

Simple deployable traffic lights that can be interacted with to control the flow of AI traffic.
This is an addon for Waypoint Placeables, using it’s logic for placing and picking up the objects.
The traffic light menu allows players to control the traffic light using the following options: Green, Red, Yellow Flashing, and Race Start lights.

Players can get creative and use the traffic lights in a number of ways. Some examples include:

  • Police DUI checkpoints
  • Construction crews controlling traffic
  • Traffic control at events
  • Using the “Race Start” mode for the countdown for drag races

Multiple traffic lights can be placed and operated at the same time. Updates to the traffic lights are synced between all players.

This script is based off of Smallos xnTrafficLights.

Preview
GitHub: wp-trafficlights

Usage

Using the traffic lights is quite simple.

  • Acquire a traffic light item
  • Use the item and place the traffic light in the desired location
  • Interact with the traffic light via target to open the menu
    • You can also use /trafficlight command to open the menu for the traffic light last interacted with
  • Select the “Set stopping point” option
    • Choose the point where you want traffic to stop.
    • Change the radius of the stopping point using the mouse wheel up/down (configurable)
  • Select the traffic light mode: Red, Green, Yellow Flashing, or Race Start

Note: If using flashing yellow, it is recommended to have a large radius for your stopping point. Traffic will move slowly while inside the zone.

Performance

The script is designed to be as performant as possible.

Resource monitor results:

  • While not in use: 0.00ms
  • While in use w/ any mode: 0.00ms
  • While placing stopping point (running a raycast): 0.12ms

Dependencies

  • Waypoint Placeables
    • This is used for placing/picking up the traffic lights items. If you wish to use a different method or do not want an item based system, you can modify to suit your needs or use the original xnTrafficLights.
  • QBCore / ESX / OX for Notifications
  • menuv

Credit

This script is based off of Smallos xnTrafficLights. Original logic and functionality is derived from xnTrafficLights.

Many modifications have been made to the original script to improve usability and performance. Some changes include:

  • improve performance by removing several while true loops
  • remove dependency on jaymenu
  • add additional traffic light modes (flashing yellow, race start)
  • allow placement and control of multiple traffic lights at the same time

Checkout my scripts

10 Likes

Super cool!!!

Future qs-inventory support would be nice :innocent:

2 Likes

If you are willing please contribute a PR to wp-placeables adding support for it in the framework.lua file.

There are just too many flavors of inventories out there for me to keep up with on my own and fully vet that all the changes work, I only provide support for a few of the “major” ones out of the box. More than happy to accept contributions from the community tho! It is an open source project after all :wink:

2 Likes

Completely understandable! I’ll modify the framework. Thanks again :pray:

1 Like

i followed all instructions,
using esx and ox for notify

i can place the traffic light, but upon trying to “remote control the light” it doesnt do anything, no menu pop up… no errors,

if i dont press via the target menu and just type /trafficlight after i place the light it notifys me to connect to the light, when i do the target select, it doesnt give me any errors or any menu pop up,

Do you have the menuv dependency running? That is the script that we are using for the menu.

This is why you should use Dependencies so people can’t start the script without the required scripts :stuck_out_tongue:

1 Like

yes menuv is running.

edit : i fixed it, i had to update menuv

1 Like

Tried building a custom traffic light for this just to see if i could get it to work with a custom model but wasnt able to get the lights to work on the traffic light :cry:

Maybe ill keep playing with it


** Only removed the walk box and button from the pole and added a texture to test **

Cool stuff, if you figure it out we can definitely include it!

1 Like