Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Contract
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    2. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    3. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    4. Bugs*

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    6. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

      1. GTANet 20th Anniversary
    2. Support

    3. Suggestions

[C#] Vehicle MemoryAddress


Zetsu
 Share

Recommended Posts

Hey!

 

I need a hint with this code

Vehicle vehicle = player.CurrentVehicle;IntPtr vehPtr = vehicle.MemoryAddress;// Following needs unsafe context (/unsafe)Int16 susp = *(Int16* )(vehPtr + 0x7A2);

Actually, it doesn't work because there are some invalid arguments and declarations (like vehicle.MemoryAddress into IntPtr type. MemAdd... is INT). Also, I have problems when I compile. Using an "unsafe" function stops me from building solution. What I want to do is to create a function which helps me to change gear and acceleration (I preffer C#).

 

What's missing?

Link to comment
Share on other sites

unknown modder

Hey!

 

I need a hint with this code

Vehicle vehicle = player.CurrentVehicle;IntPtr vehPtr = vehicle.MemoryAddress;// Following needs unsafe context (/unsafe)Int16 susp = *(Int16* )(vehPtr + 0x7A2);

Actually, it doesn't work because there are some invalid arguments and declarations (like vehicle.MemoryAddress into IntPtr type. MemAdd... is INT). Also, I have problems when I compile. Using an "unsafe" function stops me from building solution. What I want to do is to create a function which helps me to change gear and acceleration (I preffer C#).

 

What's missing?

use Int16 susp = *(Int16*)((vehPtr + 0x7A2).ToPointer());.

Then make sure the function is marked as unsafe, or the block is in an unsafe block.

Finally in project settings make sure Allow Unsafe Code is checked.

Link to comment
Share on other sites

 

Hey!

 

I need a hint with this code

Vehicle vehicle = player.CurrentVehicle;IntPtr vehPtr = vehicle.MemoryAddress;// Following needs unsafe context (/unsafe)Int16 susp = *(Int16* )(vehPtr + 0x7A2);

Actually, it doesn't work because there are some invalid arguments and declarations (like vehicle.MemoryAddress into IntPtr type. MemAdd... is INT). Also, I have problems when I compile. Using an "unsafe" function stops me from building solution. What I want to do is to create a function which helps me to change gear and acceleration (I preffer C#).

 

What's missing?

use Int16 susp = *(Int16*)((vehPtr + 0x7A2).ToPointer());.

Then make sure the function is marked as unsafe, or the block is in an unsafe block.

Finally in project settings make sure Allow Unsafe Code is checked.

 

I'll see that. And how do I change the value of 0x7A2 (which is current gear actually)? I can't see any INT argument here defining the gear.

Link to comment
Share on other sites

 

Hey!

 

I need a hint with this code

Vehicle vehicle = player.CurrentVehicle;IntPtr vehPtr = vehicle.MemoryAddress;// Following needs unsafe context (/unsafe)Int16 susp = *(Int16* )(vehPtr + 0x7A2);

Actually, it doesn't work because there are some invalid arguments and declarations (like vehicle.MemoryAddress into IntPtr type. MemAdd... is INT). Also, I have problems when I compile. Using an "unsafe" function stops me from building solution. What I want to do is to create a function which helps me to change gear and acceleration (I preffer C#).

 

What's missing?

use Int16 susp = *(Int16*)((vehPtr + 0x7A2).ToPointer());.

Then make sure the function is marked as unsafe, or the block is in an unsafe block.

Finally in project settings make sure Allow Unsafe Code is checked.

 

 

Why use unsafe code?

 

Marshal.ReadInt16 works fine :p

Link to comment
Share on other sites

I solved that... Now I got in game and nothing happens, even if my mod is telling me that I'm in 3rd gear, LeeFixSpeedometer tells me 1,2, depending on acceleration. Something missing?

 

I'm looking at this hash
lOhfgi.jpg

 

Code:

veh = player.CurrentVehicle;Int32* vehPtr = veh.MemoryAddress;*(Int16*)(vehPtr + 0x7A0) = 3;
Link to comment
Share on other sites

0x7A0? Try reading 0x7A2.

 

Also try my manual transmission's debug thingy

 

Both return 0 without modifying them

Link to comment
Share on other sites

Oh crap, wait. So, i can't convert int* to IntPtr.

 

8rYBze.jpg

 

To get it working I replaced with Int32 (vehPtr variable). veh.MemoryAddress returns a int* result

Link to comment
Share on other sites

The error clearly states that there is an explicit cast, not implicit. Just do this

short* currentVehPointer = veh.MemoryAddress;short* currentGear = currentVehPointer + 0x7A0;*currentGear = 3;

Anyway, you need to nop specific code, so your gear wouldn't be overwritten. And just a friendly note: GTA V only supports gear from 0 to 7, inclusive.

 

All the best,
Paul.

Edited by leftas
Link to comment
Share on other sites

The error clearly states that there is an explicit cast, not implicit. Just do this

 

short* currentVehPointer = veh.MemoryAddress;short* currentGear = currentVehPointer + 0x7A0;*currentGear = 3;

Anyway, you need to nop specific code, so your gear wouldn't be overwritten. And just a friendly note: GTA V only supports gear from 0 to 7, inclusive.

 

All the best,

Paul.

 

Thanks, buut...

 

kzIrgC.jpg

 

And i knew top gear was 7 :) I have modded a "1000HP" Supra. Thanks for that, anyway.

Link to comment
Share on other sites

Ugh, explicit means (short*)veh.MemoryAddress.

So you do like this

short* currentVehPointer = (short*)veh.MemoryAddress;short* currentGear = currentVehPointer + 0x7A0;*currentGear = 3;

All the best,

Paul.

Link to comment
Share on other sites

And agaain, nothing happens. I'd like to switch to C++, but I get cancer trying to understand some little things and fail when I build solution. Also, In @ikt's scripts, he uses different types. (uint64_t for memory address, to get the memory address, that function returns a uintptr_t and so on..).

Link to comment
Share on other sites

unknown modder

And agaain, nothing happens. I'd like to switch to C++, but I get cancer trying to understand some little things and fail when I build solution. Also, In @ikt's scripts, he uses different types. (uint64_t for memory address, to get the memory address, that function returns a uintptr_t and so on..).

uint64_t and uintptr_t are the same thing

Link to comment
Share on other sites

And agaain, nothing happens. I'd like to switch to C++, but I get cancer trying to understand some little things and fail when I build solution. Also, In @ikt's scripts, he uses different types. (uint64_t for memory address, to get the memory address, that function returns a uintptr_t and so on..).

Please be exact with "nothing happens". Gear haven't changed up ? The offset still only returns 0 ? C++ and C# won't change a thing when editing memory with pointers.

 

All the best,

Paul

Link to comment
Share on other sites

 

Cast it? Unless you make currentVehPtr an int*.

What do you mean ?

 

Just what you said, casting it to a short*.

 

Or, using the same type as veh.MemoryAddress; so you don't need a cast, so int* currentVehPointer = veh.MemoryAddress;

Edited by ikt
Link to comment
Share on other sites

 

 

Cast it? Unless you make currentVehPtr an int*.

What do you mean ?

 

Just what you said, casting it to a short*.

 

Or, using the same type as veh.MemoryAddress; so you don't need a cast, so int* currentVehPointer = veh.MemoryAddress;

 

Why use short anyway? The address won't fit in a short.

 

Pointers are pointers, they are different type. And gear is a byte long only, so casting currentGear to it would seem logical, though it really doesn't matter either you use int or short, because game reads only from 0-255.

Back to pointers: in c# terms the short type is only one byte, but when it becomes a pointer(short*), sizeof(short*) is 4/8 bytes depending on used architecture of the program. Because pointer is a variable holding an address and address in x64 is 8 bytes and in x32 is 4 bytes.

 

All the best,

Paul

Edited by leftas
Link to comment
Share on other sites

[...]

Pointers are pointers, they are different type. And gear is a byte long only, so casting currentGear to it would seem logical, though it really doesn't matter either you use int or short, because game reads only from 0-255.

Back to pointers: in c# terms the short type is only one byte, but when it becomes a pointer(short*), sizeof(short*) is 4/8 bytes depending on used architecture of the program. Because pointer is a variable holding an address and address in x64 is 8 bytes and in x32 is 4 bytes.

 

All the best,

Paul

Yeah, I misinterpreted it initially and I removed the last part in my post when I realized my mistake, while you were posting.

Link to comment
Share on other sites

What doesn't work precisely? The gear isn't set? You do need to realize you need to kill the automatic downshifting/upshifting in GTA, or continously loop the gear setting.

 

You can also try to change vehicle health, which sticks and shouldn't have a dozen instructions changing it continuously.

Link to comment
Share on other sites

What doesn't work precisely? The gear isn't set? You do need to realize you need to kill the automatic downshifting/upshifting in GTA, or continously loop the gear setting.

 

You can also try to change vehicle health, which sticks and shouldn't have a dozen instructions changing it continuously.

 

That's the problem. Killing automatic down/upshifting. Right now I have a paid project which I have to finish fast and I will try again after I finish this.

I've noticed that GTA systems sucks. I attached to E key to turn the engine on (just to see if my mod works ok) and after engine goes off, automatically get back on.

Edited by Zetsu
Link to comment
Share on other sites

Ok, so i've tried in C++ using your source for steering wheel. Still nothing... I'm gonna give up for real right now. It's pathetic.

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
 Share

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