Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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. Grand Theft Auto Series

      1. Bugs*
      2. 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. GTA San Andreas

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

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

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. 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

    2. Support

    3. Suggestions

Reading memory addresses


Bennington
 Share

Recommended Posts

Hey modder

just got some crisis with memory addresses recently sneaky2.gif

My problem is that I wanna check which immunities a car has.

What I found on GTAModding:

 

    * 0xB6F980 - Is the direct pointer to the pool start (CVehicle)

    * 0xBA18FC - Current vehicle pointer:

          o 0 = on-foot

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

 

This pointer:

 

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

 

# +66 = [byte] Is the BP/EP/DP/DP (Special Flags) status of the car as follows:

Add these values, and write the sum into +66

 

    * 1 = n/a

    * 2 = n/a

    * 4 = bullet-proof

    * 8 = fire-proof

    * 16 = damage-proof (from collisions etc)

    * 32 = n/a

    * 64 = n/a

    * 128 = explosion-proof

 

 

 

OK, well... but how to use it?!?

There isn´t even a documentation or something how to use memory addresses on the page.

Just love you guys if you could refer me to a good one biggrin.gif

Greetz Bennington

Edited by Bennington
Link to comment
Share on other sites

Yo I wrote this script just now (tested and working). When you type "IMMUNE" in a car the script checks what immunities the player's car has and displays them on the screen. The function getCarImmunities can be used for any car whose handle you pass to it. smile.gif

 

{$CLEO .cs}{   GTA SA Check Car Immunities Script   Created by: Adler}const   ANY_CAR    = [email protected]   BULLETP    = [email protected]   FIREP      = [email protected]   EXPLOSIONP = [email protected]   CRASHP     = [email protected]: Starting code...while true   wait 250   if and       00DF:   actor $PLAYER_ACTOR driving       0ADC:   test_cheat "IMMUNE"   then       0811: ANY_CAR = actor $PLAYER_ACTOR car // versionC       gosub @checkLastChar       while  00DF:   actor $PLAYER_ACTOR driving           wait 0           0AB1: call_scm_func @getCarImmunities 1  car_handle: ANY_CAR  store_to: BULLETP FIREP EXPLOSIONP CRASHP           gosub @textShow           if               0ADC:   test_cheat "IMMUNE"           then               gosub @checkLastChar               break           end       end       00BE: text_clear_all   endend:checkLastCharwhile  0AB0:  key_pressed 0x45 // E   wait 0endreturn:getCarImmunities0A97: [email protected] = car [email protected] struct000A: [email protected] += 660A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0if   [email protected] >= 128then   [email protected] = 1 // Explosionproof = True   [email protected] -= 128else   [email protected] = 0 // Explosionproof = Falseendif   [email protected] >= 16then   [email protected] = 1 // Crashproof = True   [email protected] -= 16else   [email protected] = 0 // Crashproof = Falseendif   [email protected] >= 8then   [email protected] = 1 // Fireproof = True   [email protected] -= 8else   [email protected] = 0 // Fireproof = Falseendif   [email protected] == 4then   [email protected] = 1 // Bulletproof = Trueelse   [email protected] = 0 // Bulletproof = Falseend0AB2: ret 4  [email protected] [email protected] [email protected] [email protected]:textShow00BE: text_clear_all045A: draw_text_1number 50.0 150.0 GXT 'NUMBER' number BULLETP045A: draw_text_1number 50.0 170.0 GXT 'NUMBER' number FIREP045A: draw_text_1number 50.0 190.0 GXT 'NUMBER' number EXPLOSIONP045A: draw_text_1number 50.0 210.0 GXT 'NUMBER' number CRASHPreturn

 

23088_s.gif

Link to comment
Share on other sites

 

0A97: [email protected] = car [email protected] struct000A: [email protected] += 660A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0

 

 

That´s the whole deal? Lol... I thought it would be way harder, look at BnBs CPed topic and you know what I mean...

Anyway, that page isn´t that comprehensible to me all way...

Thanks biggrin.gif

Link to comment
Share on other sites

Adler, it will be more accurate (and shorter) via bit checking.

 

 

0AB1: call_scm_func @getCarImmunities 1 car_handle: ANY_CAR store_to: BULLETP FIREP CRASHP EXPLOSIONP :getCarImmunities0A97: [email protected] = car [email protected] struct000A: [email protected] += 0x420A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0if   08B7:   test [email protected] bit 7then  0006: [email protected] = 1 // Explosionproof = Trueelse  0006: [email protected] = 0 // Explosionproof = Falseendif  08B7:   test [email protected] bit 4then  0006: [email protected] = 1 // Crashproof = Trueelse  0006: [email protected] = 0 // Crashproof = Falseendif  08B7:   test [email protected] bit 3then  0006: [email protected] = 1 // Fireproof = Trueelse  0006: [email protected] = 0 // Fireproof = Falseendif  08B7:   test [email protected] bit 2then  0006: [email protected] = 1 // Bulletproof = Trueelse  0006: [email protected] = 0 // Bulletproof = Falseend0AB2: ret 4 [email protected] [email protected] [email protected] [email protected]

 

 

 

Yeah, I know that SCM func sets vars to 0 by default, but it is buggy for me (in CLEO3, CLEO4 has it OK).

Link to comment
Share on other sites

Yeah I wasn't sure of how to use the bit stuff (even after reading Deji's tutorial for it) so that's why I didn't use it. blush.gif

 

But thanks for incorporating the bit stuff into the function. I'll study it so I can learn how to use it. smile.gif

23088_s.gif

Link to comment
Share on other sites

  • 2 weeks later...

Wait... - I´m losing thread.

So it can´t be dealed with only that three lines?

Can anyone describe me the near effect of 0AB1 and 08B7?

Link to comment
Share on other sites

0AB1 calls an SCM function in your script at the label (first param). The second param defines how many variables to pass to the function and the next set of params defines those variables. The set of params after the passed variables retrieves variables from the function by 0AB2. Here's SannyBuilder Help's example (modified a bit by me):

 

[email protected] = 50AB1: call_scm_func @GetSQR  vars: 1  passed_vars: 10  store_to: $resultend_thread.....: GetSQR006A: [email protected] *= [email protected] // 10 is passed to the function as [email protected], any more variables passed on will be [email protected] [email protected] and so on.0AB2: ret  vars: 1  return: [email protected] // [email protected] will be stored to $result

 

The local vars used in SCM functions will not affect local vars used elsewhere in the script unless they are returned by 0AB2 so you can any vars in the function without worrying about it messing up any other part of your script.

 

And here's Deji's Tutorial on bits.

 

The "three lines" are enough to read memory but since you said:

 

My problem is that I wanna check which immunities a car has.

I expanded it to a function that will return each immunity that a car has and displays it on-screen. The function was necessary because the address has the sum of all the immunities so I had to do some reverse-math to separate them and find out which separate immunities the car has rather than the sum of them. biggrin.gif

Edited by Adler
23088_s.gif

Link to comment
Share on other sites

Ah, thank you.

That math thing was already comprehensible to me.

And I´m understanding the bit thing now, too biggrin.gif

But why am I needing 0AB1?

Can´t I just insert

 

03C0: [email protected] = actor $PLAYER_ACTOR car0A97: [email protected] = car [email protected] struct000A: [email protected] += 0x420A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 000D6: if08B7:   test [email protected] bit 7then0006: [email protected] = 1 // Explosionproof = Trueelse0006: [email protected] = 0 // Explosionproof = False00D6: if08B7:   test [email protected] bit 4then0006: [email protected] = 1 // Crashproof = Trueelse0006: [email protected] = 0 // Crashproof = False00D6: if08B7:   test [email protected] bit 3then0006: [email protected] = 1 // Fireproof = Trueelse0006: [email protected] = 0 // Fireproof = False00D6: if08B7:   test [email protected] bit 2then 0006: [email protected] = 1 // Bulletproof = Trueelse 0006: [email protected] = 0 // Bulletproof = False

 

in my script? What are the advantages of that opcode?

Edited by Bennington
Link to comment
Share on other sites

Well I guess you could do that too lol but I like SCM functions because all you have to do is paste the function somewhere in the script and pass on some vars using 0AB1 to the function and get whatever you want. Then you'd be able to use the function repeatedly throughout the script with 0AB1 without wasting bytes pasting the code wherever you need it but gosubs can do the same too. tounge.gif

 

The only times when SCM functions are more advantageous than gosubs are when the functions use too many variables to share with the rest of your script and when the number of passed and received variables does not exceed the number of variables used in the function (since vars used in SCM functions don't affect anything else in the script).

23088_s.gif

Link to comment
Share on other sites

Thanks, then I will try 0AB1.

By the way, can I choose the names for SCM functions on myself?

Link to comment
Share on other sites

Of course since they access a label it will be renamed when the script is decompiled into the enumerated string you defined with 'name_thread' or simply NONAME

cheers

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.