G-Modifications Posted January 3, 2012 Share Posted January 3, 2012 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 More sharing options...
fastman92 Posted January 3, 2012 Share Posted January 3, 2012 (edited) 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 January 3, 2012 by fastman92 Link to comment Share on other sites More sharing options...
Silent Posted January 3, 2012 Share Posted January 3, 2012 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 More sharing options...
G-Modifications Posted January 3, 2012 Author Share Posted January 3, 2012 Thanks, I will try that G-Modifications Link to comment Share on other sites More sharing options...
aStiffSausage Posted January 3, 2012 Share Posted January 3, 2012 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 More sharing options...
fastman92 Posted January 3, 2012 Share Posted January 3, 2012 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 More sharing options...
G-Modifications Posted January 4, 2012 Author Share Posted January 4, 2012 (edited) 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 January 4, 2012 by G-Modifications Link to comment Share on other sites More sharing options...
aStiffSausage Posted January 4, 2012 Share Posted January 4, 2012 There's even simpler way, not sure if it's CLEO4 only though. 06A3: get_car [email protected] mass_to [email protected] Link to comment Share on other sites More sharing options...
DK22Pac Posted January 4, 2012 Share Posted January 4, 2012 (edited) oksa8 +1. Beat all coders Edited January 4, 2012 by DK22Pac Link to comment Share on other sites More sharing options...
G-Modifications Posted January 4, 2012 Author Share Posted January 4, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now