Jump to content

[C++] How to get vehicle position


oxf0rddev

Recommended Posts

Hello,

 

I was able to get the player's position easily but I am not able to figure out how to get the vehicle's position (x,y,z) from this addresses

Cars0xB6F980 - Is the direct pointer to the pool start (CVehicle)0xBA18FC - Current vehicle pointer:0 = on-foot>0 = in-car0x969084 - First vehicle you got intoNote: To get the next vehicle, so the second one, you need to add +0x4 as many times you want. They are 0 if you haven't entered a first/second/third/etc car yet.0xB74494 - Contains a pointer to main structThis struct:+0 = Contains a pointer to the first element in the pool+4 = Contains a pointer to a byte map indicating which elements are in use+8 = [dword] Is the maximum number of elements in the pool+12 = [dword] Is the current number of elements in the poolEach vehicle object is 2584 (0xA18) bytes. It starts at 0xC502AA0.For each vehicle in the pool:+20 = [byte] Contains a pointer to the rotation/position matrix (84 bytes):+0 = [float] X-axis Rotation (Grad)+4 = [float] Y-axis Rotation (Grad)+8 = [float] Z-axis Rotation (Grad)+16 = [float] X-axis Rotation (Looking)+20 = [float] Y-axis Rotation (Looking)+24 = [float] Z-axis Rotation (Looking)+48 = [float] X-axis Position+52 = [float] Y-axis Position+56 = [float] Z-axis Position+34 = [word] Vehicle ID from vehicles.ide

I just don't understand witch address should I use and how to start and how to get the position from these addresses, also I would like to get the vehicle ID and the speed of the vehicle. The vehicle that I would like to find the position for is the current vehicle I am inside. Could anyone please explain to me how to use this addresses to get to the vehicle's position or speed. thanks a lot.

Edited by salehyassin
Link to comment
Share on other sites

  • 2 weeks later...
Ashwin.Star

Read the vehicle pointer,

add 0x20 to the value, to get the pointer of position matrix,

now read this address, and

now add 0x48, 0x52, 0x56,

to get the memory address of X, Y, Z position respectively,

then read the value of address to get the x, y , z coordinates

of vehicle in float,

Edited by Ashwin the new boy
Link to comment
Share on other sites

  • 7 months later...

Did you manage to get vehicle speed from current vehicle? I'm interested in those addresses too.

 

If my memory serves me correctly you should read the Vehicle pointer and add your offset (see below) then read:

 

  • +68 = [float] X (East-West) speed
  • +72 = [float] Y (North-South) speed
  • +76 = [float] Z (Up-Down) speed
  • +80 = [float] X (NS) Spin
  • +84 = [float] Y (EW) Spin
  • +88 = [float] Z (NW) Spin

Note: Do not get confused about the Spin Angles, these are NOT rotations but the angles of how fast your vehicle is turning in the given axis direction...

Edited by ChopTheDog.
Link to comment
Share on other sites

C++ you said?

CVehicle *veh = FindPlayerVehicle(-1, true);if(veh){    CVector &posn = veh->m_pCoords ? veh->m_pCoords->pos : veh->m_Placement.m_vPosn;    CVector &vel = veh->m_vVelocity;}
Edited by DK22Pac
Link to comment
Share on other sites

DWORD mat = *(DWORD*)((*(DWORD*) 0xBA18FC) + 0x20);float x = *(float*)(mat + 0x48);

edited. i think this is wrong:

 

+20 = [byte] Contains a pointer to the rotation/position matrix (84 bytes):

 

it should be DWORD.

Edited by gta.bullet
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.