Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsPlayerDrivingDangerously #813

Merged
merged 3 commits into from
Nov 26, 2023

Conversation

Lucas7yoshi
Copy link
Contributor

0xF10B44FD479D69F3 is used for a voice line about the player driving in "the correct lanes" (wrong lanes) for nigel2.c

@themonthofjune
Copy link

GET_IS_PLAYER_DRIVING_WRECKLESS

@Lucas7yoshi
Copy link
Contributor Author

I will not apply this due to the origin of it unless I get told to do otherwise

Copy link
Contributor

@4mmonium 4mmonium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked up the native in IDA and p2 may be some sort of type, it ranges from 0 to 2.

Apparently 2 is against traffic as you're saying, but then I looked up other offsets that the native checks depending on p2 and there's a check for traffic lights. I noticed it was traffic lights since I did some research on junctions and traffic lights a while ago and that offset led me there. Pseudo-code provided for demonstration purposes only.

Notice the comment (names are speculative guesses):
image

And p2 being 1 matches 0xbf8, which is the check for traffic lights, game code specifically checks if a traffic light is red.
image

So we know two things for sure:
State/Type 1: Is a check for traffic lights, specifically red.
State/Type 2: Is a check for driving against traffic as you are saying.
State/Type 0: Is a check for 'last time driven on pavement', may get set when the player isn't driving on pavement/car is in the air?

@Lucas7yoshi
Copy link
Contributor Author

Testing reveals that 1 does indeed seem to be for running through red lights, does take a bit of time for it to begin to return true though (which might have something to do with the time mentions there?)

Testing with value 0 i could not find any situation in which it would return true.

@Lucas7yoshi Lucas7yoshi changed the title IsPlayerDrivingAgainstTraffic IsPlayerDrivingDangerously Nov 15, 2023
@4mmonium
Copy link
Contributor

4mmonium commented Nov 15, 2023

Testing reveals that 1 does indeed seem to be for running through red lights, does take a bit of time for it to begin to return true though (which might have something to do with the time mentions there?)

Testing with value 0 i could not find any situation in which it would return true.

0 is the time since the player drove on pavement, let's check this native and follow the line:
image

Notice 0x1078 is the exact same offset in the other screenshot I posted here

Then there's the 0xBF4 offset which confirms it:
image

Maybe not driving on pavement or having the car fly in the air causes the native to return something when calling the IsPlayerDrivingDangerously native with type 0?

@Lucas7yoshi
Copy link
Contributor Author

Testing reveals that 1 does indeed seem to be for running through red lights, does take a bit of time for it to begin to return true though (which might have something to do with the time mentions there?)
Testing with value 0 i could not find any situation in which it would return true.

0 is the time since the player drove on pavement, let's check this native and follow the line: image

Notice 0x1078 is the exact same offset in the other screenshot I posted here

Then there's the 0xBF4 offset which confirms it: image

Maybe not driving on pavement or having the car fly in the air causes the native to return something when calling the IsPlayerDrivingDangerously native with type 0?

i believe i tried that while testing all 3 and got nothing. might be non functional

Added an enum with different violation types.
Added type 0 which I was able to test in-game, it only returns true when driving on paved sidewalks.
Copy link
Contributor

@4mmonium 4mmonium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I tested all this including type 0 which I documented, everything works. I'm approving and merging!

Thanks 😊

@4mmonium 4mmonium merged commit e499934 into citizenfx:master Nov 26, 2023
1 check passed
@JajarGaming
Copy link
Contributor

I will not apply this due to the origin of it unless I get told to do otherwise

https://nativedb.dotindustries.dev/gta5/natives/0xF10B44FD479D69F3?search=0xF10B44FD479D69F3+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants