Quantcast

Jump to content

» «
Photo

[C++] How to get vehicle position

6 replies to this topic
oxf0rddev
  • oxf0rddev

    Player Hater

  • Members
  • Joined: 03 May 2008

#1

Posted 26 March 2014 - 05:17 AM Edited by salehyassin, 26 March 2014 - 05:19 AM.

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

Cars
0xB6F980 - Is the direct pointer to the pool start (CVehicle)
0xBA18FC - Current vehicle pointer:
0 = on-foot
>0 = in-car
0x969084 - First vehicle you got into
Note: 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 struct
This 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 pool
Each 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.


oxf0rddev
  • oxf0rddev

    Player Hater

  • Members
  • Joined: 03 May 2008

#2

Posted 08 April 2014 - 01:53 AM

No one is going to answer me?

Ashwin.Star
  • Ashwin.Star

    i'll be back someday

  • Members
  • Joined: 14 Nov 2010
  • India

#3

Posted 08 April 2014 - 04:04 AM Edited by Ashwin the new boy, 08 April 2014 - 04:21 AM.

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,

Sfullez
  • Sfullez

    Analog Interface

  • New Members
  • Joined: 20 Nov 2014
  • Italy

#4

Posted 20 November 2014 - 04:19 PM

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


ED-E
  • ED-E

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • United-Kingdom

#5

Posted 20 November 2014 - 09:56 PM Edited by ChopTheDog., 20 November 2014 - 09:56 PM.

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...


DK22Pac
  • DK22Pac

  • Feroci
  • Joined: 12 Apr 2009
  • Ukraine
  • Best WIP Mod 2014 [Grand Theft Auto 3D Contribution]
    Contribution Award [Mods]

#6

Posted 21 November 2014 - 07:53 PM Edited by DK22Pac, 21 November 2014 - 08:14 PM.

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;
}

gta.bullet
  • gta.bullet

    Crackhead

  • Members
  • Joined: 19 Jun 2010

#7

Posted 21 November 2014 - 08:39 PM Edited by gta.bullet, 21 November 2014 - 08:48 PM.

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users