SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 18/01/2020, 04:16 PM   #1
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Possible to check if player ran a red light?

Hey, I was wondering if it's possible to check if a player went past a red light. I'm fairly sure it isn't, but it'd be good to know if it is. And if it isn't, if there's any ways of "cheating the system" to recreate a similar effect.

Thanks!
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 18/01/2020, 04:19 PM   #2
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,528
Reputation: 1642
Default Re: Possible to check if player ran a red light?

I remembered there was a script to control traffic lights. https://forum.sa-mp.com/showthread.php?t=646429
This one seems interresting aswell: https://forum.sa-mp.com/showthread.php?t=509952
^ When you know the state of certain traffic lights you can script this detection yourself. Seems you do have to get the positions for that yourself (unless if the second URL contains that data, didn't check)

FYI I searched for "samp traffic light" on g00gl3 and this was result 1 and 3
__________________
Do not click on this URL -It is secret information
RIP Slayer 1981-2019 \m/
Kwarde is offline   Reply With Quote
Old 18/01/2020, 04:22 PM   #3
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: Possible to check if player ran a red light?

Quote:
Originally Posted by Kwarde View Post
I remembered there was a script to control traffic lights. https://forum.sa-mp.com/showthread.php?t=646429
This one seems interresting aswell: https://forum.sa-mp.com/showthread.php?t=509952
^ When you know the state of certain traffic lights you can script this detection yourself. Seems you do have to get the positions for that yourself (unless if the second URL contains that data, didn't check)

FYI I searched for "samp traffic light" on g00gl3 and this was result 1 and 3
I already saw the first link, second one is interesting though. First one put me off because it looked like it only worked for specific custom models, which wouldn't work as I'd want it to work throughout the map. And, I'm not exactly sure how I can check if a player is near a traffic light, which is probably going to flaw the whole system.

Also, (slightly off-topic, didn't want to make a whole new thread for it though), is it possible to make car indicators/blinkers? I saw someone mention attaching an object to the car and doing something, but they didn't go into much detail and I'm not sure what object id would be best for the indicators. If I should make another topic on this, I will, just thought it wasn't worth making a new thread about.
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 19/01/2020, 10:41 PM   #4
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,528
Reputation: 1642
Default Re: Possible to check if player ran a red light?

Well as the topic reads: "All lights facing to North/South and all lights facing to East/West are same in GTA", with these options:
Code:
1- Green (N/S) Red (E/W)
2- Yellow (N/S) Red (E/W)
3- Red (N/S) Green (E/W)
4- Red (N/S) Yellow (E/W)
5- Red (N/S) Red (E/W)(Server starts in that state)
If someone would be facing north/sourth (N/S) and they would be near a N/S traffic light (need an array with quite precise data), and the traffic lights state would be 3 or 4 (or even 5), you could check if they then pass the position they are at the moment. Though it would be harder to tell if they would turn around or drive backwards or forwards.
This data array would need to hold 'trafficlights N/S' and to fix above issue, 'passing point' (position where they passed the traffic light). Example:

The gray box would be the trafficlight's position / the area where the server would detect someone is at a traffic light.
The read box would be the "passing point area"; If someone leaves the traffic light area and enters the "passing point area" while the state of that light is RED, they'd have passed the light. Otherwise they'd have turned.

Now while thinking about it, a better way is: you could just save the facing position of that traffic light. In above example the passing area is up (north). So if you'd save that data (north) to the array and the player would advance to north while the state is red, they'd have passed it.


I don't know about the blinking light.
__________________
Do not click on this URL -It is secret information
RIP Slayer 1981-2019 \m/
Kwarde is offline   Reply With Quote
Old 20/01/2020, 03:02 AM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,892
Reputation: 1321
Default Re: Possible to check if player ran a red light?

Here is what I would do.

Create "Intersection Areas"
Link common intersections
Now think of it like this.

A player enters an intersection area drives through the intersection area to the other side of the street entering the other intersection area. This is where you do some checks to see if they crossed on a red light it is very simple and straight forward.
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
check if player stream to other player ToiletDuck Scripting Help 2 28/01/2019 12:44 PM
How to check if a player is facing another player GameOvr Scripting Help 2 12/12/2018 11:07 AM
How to check if the vehicle light is on? Mavis100 Scripting Help 3 14/05/2014 09:54 AM
NPCs stops for red light and drive at green light Julius95 Scripting Help 2 17/02/2014 01:57 PM
Light Bar> Any one know how to create a working Light Bar for car Txt. and dxt. Ali2627 Scripting Help 3 10/01/2014 03:12 AM


All times are GMT. The time now is 03:22 PM.


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