Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Detect if World.GetStreetName is actually nearest street?

Featured Replies

World.GetStreetName returns the name of the nearest named street, but does not indicate how far away that is, or if a closer road exists which is unnamed. I'd like to be able to detect if a Vector3 location is on or near a road with a particular name - and ideally be able to tell how far away they are from the nearest point on the nearest named road. 

Using the native IS_POINT_ON_ROAD you can tell if the location is on a road, but that returns true if the point is on any road (or even dirt path). Using GetStreetName always returns a name even if you're in the middle of the desert far from any roads. Using GetNextPositionOnStreet and checking the distance from the point of interest to that point helps if the next position is on the named street, but if you're on an unnamed street then the next position is often also on the unnamed street and you're back to the same issue. 

So, does anybody have suggestions for a reliable way to detect the nearest named street, and how far away a given point is from the nearest named street?

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

You lost me with what you're trying to achieve here. Especially the part about Vectors. If you know the Vector location why don't you just use Pythagoras theorem to calculate the distance between the player and that location?

As for the name of the street there is a native that gets the name of a street at given coordinates. 

void GET_STREET_NAME_AT_COORD(float x, float y, float z, Hash *streetName,
  Hash *crossingRoad) // 0x2EB41072B4C1E4C0 0xDEBEEFCF

 

Of course you need to enable the use of unsafe contexts because you're messing with pointers here. Check the natives database, http://www.dev-c.com/nativedb/
But by doing this and acquiring the string for that road name you could then just pass it to an if statement to determine if it was the one you were looking for.

Live Streaming daily from 8pm GMT (UK) at https://twitch.tv/OfficialLukeD - I play a variety of things 😄

Join my official discord server for support, general chat and my stream schedule! https://discord.gg/Mddj7PQ

  • Author

I see that my question wasn't entirely clear. Here's an image to illustrate what I'm talking about: 

map.png.58f84b3b71884786d1148e2bce1c67ca

The issue is that both the RPH World.GetStreetName and the native GET_STREET_NAME_AT_COORD return the name for the nearest street that has a name, but that street may actually be quite far from the point of interest (for example, the purple X in the image above). You can't just use GetStreetName because you may not even be on a street at all. You also can't just check for IS_POINT_ON_ROAD because many points are on roads which are unnamed, like the red/blue X shown in the image. If you try to get the name at the red X, you get Great Ocean Hwy. If you try to find the next position on street, you get a point basically right next to it on the same unnamed road, which will also tell you the name is Great Ocean Hwy, even though you aren't on the highway at all. 

What I'd like to be able to do is determine how far away the nearest named road is from a given point, and what the name is.

I can figure out how far away the nearest road is, and I can figure out the name of the nearest named road, but those two roads may not be the same because of how many unnamed roads there are. 

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

58 minutes ago, PNWParksFan said:

What I'd like to be able to do is determine how far away the nearest named road is from a given point, and what the name is.

I can figure out how far away the nearest road is, and I can figure out the name of the nearest named road, but those two roads may not be the same because of how many unnamed roads there are. 

Well I'm not 100% sure still. If I have you interpreted right I don't know if it's possible.

Assuming all unnamed roads are alleyways or dirt racks you could always look for the closest vehicle node, specifying only asphalt option (or use the other native for major vehicle nodes)

BOOL GET_CLOSEST_VEHICLE_NODE(float x, float y, float z, Vector3 *outPosition,
  int nodeType, float p5, float p6)
// 0x240A18690AE96513 0x6F5F1E6C

 

This would give you a Vector location of the nearest main road if you gave the right nodetype. Combine this with the name of road at coords would give you the name and the distance could then be calculated as per usual using pythag.
Again though it's main roads. So it depends on how rockstar decided to name roads which I obviously have no idea.

Am I on the right lines here or am I still not understanding you?

Live Streaming daily from 8pm GMT (UK) at https://twitch.tv/OfficialLukeD - I play a variety of things 😄

Join my official discord server for support, general chat and my stream schedule! https://discord.gg/Mddj7PQ

  • Author
12 hours ago, LukeD said:

Well I'm not 100% sure still. If I have you interpreted right I don't know if it's possible.

Assuming all unnamed roads are alleyways or dirt racks you could always look for the closest vehicle node, specifying only asphalt option (or use the other native for major vehicle nodes)


BOOL GET_CLOSEST_VEHICLE_NODE(float x, float y, float z, Vector3 *outPosition,
  int nodeType, float p5, float p6)
// 0x240A18690AE96513 0x6F5F1E6C

 

This would give you a Vector location of the nearest main road if you gave the right nodetype. Combine this with the name of road at coords would give you the name and the distance could then be calculated as per usual using pythag.
Again though it's main roads. So it depends on how rockstar decided to name roads which I obviously have no idea.

Am I on the right lines here or am I still not understanding you?

You've got the right idea for what I'm looking for. I agree that it seems it may not be possible. Major vehicle nodes still seems to pick up points on unnamed roads, so that doesn't work. Using the asphalt filter is effective, although there are a handful of named dirt roads out in the Senora Desert and Raton Canyon areas (and possibly elsewhere too). I'll just have to make do with this combination of natives to do a best approximation. 

If anybody can figure out a reliable way to actually figure this out I'd be thrilled to hear!

[REL] Coastal Callouts: An action-packed mod with new vehicles, maps, capabilities, and callouts in and around the waters of Los Santos

[REL] Police Tape: Make your scenes more realistic while stopping peds and traffic

[REL] Better EMS: Realistic and dynamic EMS response

Join the Parks Benefactor Program to support my work and get early beta access!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.