sergiope Posted March 27 Share Posted March 27 (edited) Hi! I'm new to coding in CLEO and I'm trying to make a simple script for GTA SA that replaces a variable's value with another one. My goal is to change CJ’s preset car during a race. When the script is triggered, the car he's in should be converted into the accepted race car. I've identified the correct memory addresses using Cheat Engine, and can modify it succesfully there, but I can't get a script to read and replace the variable. The memory addresses are these two: gta_sa.exe+64AD88 -> 0x00A4AD88 - Indicates the car CJ is in gta_sa.exe+648F60 -> 0x00A48F60 - Determines race car Here's my code: {$CLEO .cs} nop :START wait 0 if Player.IsPlaying($PLAYER_CHAR) // Checks if the game is active goto_if_false @START if 0ADC: test_cheat "CAR" // Detects the "CAR" cheat goto_if_false @START 0A8D: 1@ = read_memory 0x00A4AD88 size 4 virtual_protect 0 // Reads the value from 0x00A4AD88 0A8C: write_memory 0x00A48F60 size 4 value 1@ virtual_protect 0 // Writes to 0x00A48F60 goto @START When I enter the cheat code, I get this error: Invalid pointer '0x0' input argument #1 "address" in script 'change_car.cs' at offset {40} - 0A8D: READ_MEMORY Script suspended. I've successfully written a value to memory before, but reading always gives me this kind of error. How can I fix this? Thanks! Edited March 27 by sergiope forgot to mention the game Link to comment https://gtaforums.com/topic/1001485-help-reading-address-in-simple-cleo-script-gta-sa/ Share on other sites More sharing options...
vladvo Posted March 27 Share Posted March 27 It won't work. You can't switch car by changing just 4 bytes of code. There's a lot lot more stuff required and still it won't be "seamless". sergiope 1 Link to comment https://gtaforums.com/topic/1001485-help-reading-address-in-simple-cleo-script-gta-sa/#findComment-1072524245 Share on other sites More sharing options...
sergiope Posted March 27 Author Share Posted March 27 4 minutes ago, vladvo said: It won't work. You can't switch car by changing just 4 bytes of code. There's a lot lot more stuff required and still it won't be "seamless". Thanks for the answer! When I manually change the value in Cheat Engine, it works—at least for the purpose I’m aiming for. I’ve tested it multiple times, and it doesn’t affect my gameplay (although, as you mentioned, there may be buggy things I can’t see but I’d still like to try it that way). If I hardcode the value in a CLEO script, it also works, but I can’t input the value I need. I’m just looking for a way to read and store that value (0x00A4AD88) through code instead of doing it manually. Isn't that possible? Link to comment https://gtaforums.com/topic/1001485-help-reading-address-in-simple-cleo-script-gta-sa/#findComment-1072524257 Share on other sites More sharing options...
OrionSR Posted March 27 Share Posted March 27 (edited) You've got an odd mix of older SB syntax and SBL syntax, which is probably causing issues with the param order of the read_memory command. Pick an edit mode (SBL in SB4 is recommended) and stick with the syntax of that mode. $PLAYER_CHAR is specific to older edit modes, in SBL it's $player1. It is best not to use opcode ID numbers in SBL mode; it limits the formatting options, which can lead to errors like yours. If you are still having trouble, please specify your SB version and the edit mode you are using. Edited March 27 by OrionSR sergiope 1 Link to comment https://gtaforums.com/topic/1001485-help-reading-address-in-simple-cleo-script-gta-sa/#findComment-1072524308 Share on other sites More sharing options...
sergiope Posted March 27 Author Share Posted March 27 48 minutes ago, OrionSR said: You've got an odd mix of older SB syntax and SBL syntax, which is probably causing issues with the param order of the read_memory command. Pick an edit mode (SBL in SB4 is recommended) and stick with the syntax of that mode. $PLAYER_CHAR is specific to older edit modes, in SBL it's $player1. It is best not to use opcode ID numbers in SBL mode; it limits the formatting options, which can lead to errors like yours. If you are still having trouble, please specify your SB version and the edit mode you are using. That solved the problem! I had mixed old SB code snippets with SBL syntax, since I didn't know much. After converting everything to SBL syntax it works fine now. Thanks a lot for your help! OrionSR 1 Link to comment https://gtaforums.com/topic/1001485-help-reading-address-in-simple-cleo-script-gta-sa/#findComment-1072524342 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