SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/05/2019, 05:45 PM   #1
rollercaster
Big Clucker
 
Join Date: Oct 2015
Posts: 50
Reputation: 0
Question Is it possible to determine the color at the traffic light (object)?

Is it possible to determine the color at the traffic light (object)?
example below:



rollercaster is offline   Reply With Quote
Old 16/05/2019, 06:11 PM   #2
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,070
Reputation: 184
Default Re: Is it possible to determine the color at the traffic light (object)?

Not sure, but as far as i know they are synced...so it should be possible. Question is how.
__________________
Looking for someone to start drifting server, drop me a pm if you are interested.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that
DRIFT_HUNTER is offline   Reply With Quote
Old 16/05/2019, 06:18 PM   #3
rollercaster
Big Clucker
 
Join Date: Oct 2015
Posts: 50
Reputation: 0
Default Re: Is it possible to determine the color at the traffic light (object)?

I thought about creating the object and adding textures to the bulb
and with IsPlayerInRangeOfPoint determine the color
rollercaster is offline   Reply With Quote
Old 17/05/2019, 02:23 PM   #4
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,638
Reputation: 537
Default Re: Is it possible to determine the color at the traffic light (object)?

Quote:
Originally Posted by DRIFT_HUNTER View Post
Not sure, but as far as i know they are synced...so it should be possible. Question is how.
They are timed based on the direction of the lane (determined by the Z rotation of the object). One cycle takes ~32 seconds, and each cycle consists of 1) green for W/E, 2) red for both and 3) green for N/S (there's no second phase for both lanes being red).

The problem is that pausing the game or running on low FPS will desync them, so if a player pauses for 4 seconds their cycle is different from the others by those 4 seconds. As a result they cannot be calculated correctly since they don't keep in sync. Not sure if it's synced in certain intervals or so but from my observations it doesn't "reset" until a GMX or reconnect.

Imo the best way to recreate them would be creating a custom version without any lights and replace the original ones.
Next, use the node data and object data to recreate the timings based on N/E or W/E directions and generate positions for the road (so you can detect if someone drives past if it's red, for example by creating dynamic areas at the node positions).
Then use small light objects (or fake lights, doesn't need to be a 2dfx) and place them in the correct bulb positions (basically what GTA SA does already).

IIRC Ride2day did something similar but I'm not sure if that's complete or if it's available somewhere.

So in theory you can keep track of every player's traffic lights by detecting if they are paused and how long. However, it is pretty inaccurate and it's not the same for all players. So I doubt this makes much sense.
NaS is offline   Reply With Quote
Old 18/05/2019, 02:11 AM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Is it possible to determine the color at the traffic light (object)?

He can easily use the allobjects array to find all traffic lights then just replace them with prefabs. That is pretty damn easy. The control system is the real work. Not to mention you also need to make a support tool to edit intersections etc.
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ Help ] Traffic Light Speed. LowRyder Scripting Help 3 28/05/2014 04:00 PM
Traffic light's NotePadGaming Scripting Help 4 27/07/2013 02:03 PM
Traffic light - tickcount? Reboma Scripting Help 1 24/05/2013 10:10 AM
Traffic light synchronisation Shredmaster General 2 24/06/2012 06:19 PM
Traffic light Chrham_2 Help Archive 6 07/08/2009 02:06 PM


All times are GMT. The time now is 12:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.