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

[Q] Memory reading


G-Modifications
 Share

Recommended Posts

G-Modifications

How can I read the mass of a car in CLEO? I know you can do this by memory reading, but I don't know how that works.

 

G-Modifications

Link to comment
Share on other sites

Put at the beggining of script source.

 

constVERSION_UNKNOWN = -1,VERSION_1_0_US_CRACKED = 1VERSION_1_0_EURO_CRACKED = 2VERSION_1_0_EURO_ORIGINAL = 3VERSION_1_01_EURO_CRACKED = 4endjump @Detect_EXE_version_end:Get_EXE_version_ID{Description:    Returns number of running gta_sa.exe, number depends on gta_sa.exe version.Type: PROPERTYParameters:  Passed:    none  Result:    [email protected] - ID of running version, returned values:     ; -1   unknown     ;  1 - GTA San Andreas v1.0 [uS] HOODLUM No-CD  Fixed EXE     ;  2 - GTA San Andreas v1.0 [EURO] No-CD Fixed EXE     ;  3 - GTA San Andreas v1.0 [EURO] Original     ;  4 - GTA: San Andreas v1.01 [EURO] No-CD/Fixed EXEExample: 0AB1: call_scm_func @Get_EXE_version_ID 0 get_version_number_to [email protected]}0A8D: [email protected] = read_memory 0x400088 size 1 virtual_protect 10871: init_jump_table [email protected] total_jumps 4 default_jump 0 @Get_EXE_version_ID_unknown jumps 0x8A @Get_EXE_version_ID_GTA_San_Andreas_v1_0_EURO_No_CD_Fixed_EXE 0xCA @Get_EXE_version_ID_GTA_San_Andreas_v1_0_US_HOODLUM_No_CD_Fixed_EXE 0xD0 @Get_EXE_version_ID_GTA_San_Andreas_v1_01_EURO_No_CD_Fixed_EXE 0xF9 @Get_EXE_version_ID_GTA_San_Andreas_v1_0_EURO_Original -1 @Get_EXE_version_ID_unknown -1 @Get_EXE_version_ID_unknown -1 @Get_EXE_version_ID_unknown:Get_EXE_version_ID_GTA_San_Andreas_v1_0_US_HOODLUM_No_CD_Fixed_EXE0AB2: ret 1 VERSION_1_0_US_CRACKED:Get_EXE_version_ID_GTA_San_Andreas_v1_0_EURO_No_CD_Fixed_EXE0AB2: ret 1 VERSION_1_0_EURO_CRACKED:Get_EXE_version_ID_GTA_San_Andreas_v1_0_EURO_Original0AB2: ret 1 VERSION_1_0_EURO_ORIGINAL:Get_EXE_version_ID_GTA_San_Andreas_v1_01_EURO_No_CD_Fixed_EXE0AB2: ret 1 VERSION_1_01_EURO_CRACKED                       :Get_EXE_version_ID_unknown0AB2: ret 1 VERSION_UNKNOWN:Is_EXE_version_equal{Description:    Compares ID of running gta_sa.exe with passed ID and checks if game version is equal.Type: CHECKParameters:  Passed:    [email protected] - ID of running version, returned values:     ; -1   unknown     ;  1 - GTA San Andreas v1.0 [uS] HOODLUM No-CD  Fixed EXE     ;  2 - GTA San Andreas v1.0 [EURO] No-CD Fixed EXE     ;  3 - GTA San Andreas v1.0 [EURO] Original     ;  4 - GTA: San Andreas v1.01 [EURO] No-CD/Fixed EXE  Result:    noneExample: if 0AB1: call_scm_func @Is_EXE_version_equal 1 is_exe_version_id_like_this 1     // GTA San Andreas v1.0 [uS] HOOLDRUM No-CD  Fixed EXE }0AB1: call_scm_func @Get_EXE_version_ID 0 get_version_number_to [email protected]   if   003B:   [email protected] == [email protected]  // (int)   then     0485: return_true   else     059A: return_false   end0AB2: ret 0:Detect_EXE_version_end

 

 

Put at the end of script source.

 

:getVehStandardHandlingOffsetByModelID{Description:    Returns offset of standard handling data according to passed vehicle ID.Type: PROPERTY Parameters:  Passed:    [email protected] - vehicle ID    Example: 0AB1: call_scm_func @getVehStandardHandlingOffset 1 vehicle_ID 400 store_offset [email protected]}0AB1: call_scm_func @GetAddress_CVehicleHandling_vehicleHandling 0 store_offset [email protected]: call_scm_func @getVehicleHandlingID 1 vehicle_ID [email protected] store_offset [email protected]@ *= 224   // sizeof(CHandlingVehicle)005A: [email protected] += [email protected]  // (int) 0AB2: ret 1 [email protected]:getVehicleHandlingID{Description:    Returns ID of handling data according to passed vehicle ID.Type: PROPERTY Parameters:  Passed:    [email protected] - vehicle ID    Example: 0AB1: call_scm_func @getVehicleHandlingID 1 vehicle_ID 400 store_offset [email protected]}0AB1: call_scm_func @GetAddress_modelPtrs 0 store_offset [email protected]@ *= 4005A: [email protected] += [email protected]  // (int)0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0      // Read _carsModels object [email protected] += 0x4A          // CModelCars.handlingIndex0A8D: [email protected] = read_memory [email protected] size 2 virtual_protect 00AB2: ret 1 [email protected]:ArrayGetValueByIndex{Description:    Returns defined already value according to number of key Type: GETParameters:  Passed:    [email protected] - index to find    [email protected] - amount of input key with values    [email protected] - default value, returned if index hasn`t been found        Repeating:        [email protected] - index1        [email protected] - value1         [email protected] - index2        [email protected] - value2    As many indexes and values as [email protected] number      Result:    [email protected] - value for searched index / default value if index hasn`t been found   Formula to get num_params: 3 + total_values * 2Example:   0AB1: call_scm_func @ArrayGetValueByIndex num_params 7 index [email protected] total_values 2 default_value 0 index1 1 value1 0x005387D0 index2 4 value 0x00538C70 store_value_to [email protected]}[email protected] *= 2   for [email protected] = 1 to [email protected] step 2       if       003B:   [email protected]([email protected],1i) == [email protected]  // (int)       then         0485: return_true       0AB2: ret 1 [email protected]([email protected],1i)       end        end059A: return_false0AB2: ret 1 [email protected]:GetAddress_modelPtrs// Example: 0AB1: call_scm_func @GetAddress_modelPtrs 0 store_offset [email protected]: call_scm_func @Get_EXE_version_ID 0 get_version_number_to [email protected]: call_scm_func @ArrayGetValueByIndex num_params 7 index [email protected] total_values 2 default_value 0 _modelPtrs index1 VERSION_1_0_US_CRACKED value1 0x00A9B0C8 index2 VERSION_1_01_EURO_CRACKED value 0x00A9D748 store_value_to [email protected]: ret 1 [email protected]:GetAddress_CVehicleHandling_vehicleHandling// Example: 0AB1: call_scm_func @GetAddress_CVehicleHandling_vehicleHandling 0 store_offset [email protected]: call_scm_func @Get_EXE_version_ID 0 get_version_number_to [email protected]: call_scm_func @ArrayGetValueByIndex num_params 7 index [email protected] total_values 2 default_value 0 CVehicleHandling_vehicleHandling_pointer index1 VERSION_1_0_US_CRACKED value1 0x004C8E7F index2 VERSION_1_01_EURO_CRACKED value 0x004C907F store_value_to [email protected]: [email protected] = read_memory [email protected] size 4 virtual_protect 0       // CVehicleHandling.vehicleHandling0AB2: ret 1 [email protected]

 

 

Use

 

0AB1: call_scm_func @getVehStandardHandlingOffset 1 vehicle_ID 400 store_offset [email protected]

 

To get the offset to structure that consists of 0xE0 (224) bytes: http://www.gtamodding.com/index.php?title=...s_(SA)#Handling

Add 0x4 to address, because

 

+0x4 = fMass

 

Read float from that address

 

0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0

 

Where [email protected] is address of handling fMass.

 

Last thing: to get the model ID use opcode:

 

0441: [email protected] = car $TEMPVAR_ACTOR_CAR model

 

It will return e.g 400 for landstalker.

Edited by fastman92
Link to comment
Share on other sites

Isn't it easier?

 

 

0A97: [email protected] = car [email protected] struct000A: [email protected] += 0x8C0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0

 

 

Just set proper car handle in 0A97, and get the mass (float) using this method.

Link to comment
Share on other sites

aStiffSausage

If he wants mass, why add 0x8C to car struct, when the address for mass is 0x4?

 

(Yeah, I really suck with memory stuff...)

Link to comment
Share on other sites

 

If he wants mass, why add 0x8C to car struct, when the address for mass is 0x4?

 

(Yeah, I really suck with memory stuff...)

Depending on if it is car struct (CVehicle) (+0x0x8C is fMass) or CHandlingVehicle (+0x4 is fMass).

My method is to access data of loaded handling.cfg, SilentPL posted a code to read mass fMass from CVehicle.

Actually every spawned vehicle has CVehicle structure and it describes this vehicle only.

Also my method is better when you want to read any handling.cfg information. There are not many in CVehicle itself.

Link to comment
Share on other sites

G-Modifications

But I only have to read the mass of the car you are driving in. It's for my speedometer to calculate how much gas you consume.

 

EDIT: I've got it.

 

G-Modifications

Edited by G-Modifications
Link to comment
Share on other sites

oksa8

+1. Beat all coders biggrin.gif

Edited by DK22Pac
Link to comment
Share on other sites

G-Modifications

Yea, I found that opcode. It's much easier. But I still don't know how I read handling.cfg. I don't get it done.

 

G-Modifications

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.