The Eagle Eye Posted May 24, 2020 Share Posted May 24, 2020 (edited) I am new to GTA codding and i get many issues making simple mods, i wasted a lot of time for this script but couldn't find to solve it. Please fix it and tell me what's wrong. Thanks. ----- Script.cs ( I just want to show the text when i get wanted level.) ----- {$CLEO .cs} wait 0 ms if 01C0: 0@ = player $PLAYER_CHAR wanted_level 0002: jump @SHOW_TEXT_1 :SHOW_TEXT_1 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL" time 5000 0A93: terminate_this_custom_script Edited May 24, 2020 by The Eagle Eye Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/ Share on other sites More sharing options...
OrionSR Posted May 24, 2020 Share Posted May 24, 2020 (edited) {$CLEO .cs} wait 5000 ms // time for game to load :Waiting 0001: wait 250 ms // default wait time 01C0: 0@ = player $PLAYER_CHAR wanted_level 00D6: if 0019: 0@ > 0 004D: jump_if_false @Waiting 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL" time 5000 0A93: terminate_this_custom_script Problem 1: Opcode 01C0 is not a conditional check. Look for commands that are indented a little more than others. Problem 2: The conditions of an If statement should always be follow by where to jump if the statement is not true. Problem 3: The script would instantly end before CJ could cause any trouble. You need a loop that waits for a while. Omitting the opcodes from your wait and if statements was not a problem. Sanny would add the required opcodes for these keywords. Edited May 25, 2020 by OrionSR Increased wait times Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222329 Share on other sites More sharing options...
The Eagle Eye Posted May 24, 2020 Author Share Posted May 24, 2020 (edited) I thought the variable 0@ goes to "player_char" not the wanted level. Thanks for help. Have you tested this mod on your computer, does it work ? i have tested it but it doesn't work. i am not using any mods anyway. Edited May 24, 2020 by The Eagle Eye OrionSR 1 Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222378 Share on other sites More sharing options...
OrionSR Posted May 24, 2020 Share Posted May 24, 2020 (edited) 32 minutes ago, The Eagle Eye said: Have you tested this mod on your computer, does it work ? I have now, and it worked as expected. But it only works the first time since the script ends after the messages is displayed. I would not expect this script to work properly if compiled with an SCR edit mode. Make sure the edit mode is set for the standard PC version San Andreas (lower right corner). The CLEO box next to the edit mode should have a black border. Click if it's red to install cleo. Use Compile and Copy so the script ends up in the cleo folder of your game directory. Check if it's there. Cleo will report how many scripts are running in the pause screen (add 5000 to the first wait during testing). Note: It's a good idea to have a long wait at the start of an untested script so you have enough time for the screen to fade in and to see the save working before a buggy script crashes the game. Edited May 24, 2020 by OrionSR Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222429 Share on other sites More sharing options...
The Eagle Eye Posted May 24, 2020 Author Share Posted May 24, 2020 Now, I had already installed cleo library v4 and the border was black too, but in the lower corner, there some GTA games included (GTA SA SCR), which itwasn't SCR before just GTA SA. otherwise i selected it and a box shown says install cleo v4 again, i did install that and then i compiled it and it says COMPILE ERROR (wait 0 ms). what's wrong again ?! Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222444 Share on other sites More sharing options...
OrionSR Posted May 24, 2020 Share Posted May 24, 2020 Sorry, I've renamed my edit modes and forget the original tag. SCR is wrong, mobile is wrong - select the other mode for SA. Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222452 Share on other sites More sharing options...
The Eagle Eye Posted May 24, 2020 Author Share Posted May 24, 2020 3 hours ago, OrionSR said: {$CLEO .cs} wait 0 ms :Waiting 0001: wait 0 ms 01C0: 0@ = player $PLAYER_CHAR wanted_level 00D6: if 0019: 0@ > 0 004D: jump_if_false @Waiting 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL" time 5000 0A93: terminate_this_custom_script Problem 1: Opcode 01C0 is not a conditional check. Look for commands that are indented a little more than others. Problem 2: The conditions of an If statement should always be follow by where to jump if the statement is not true. Problem 3: The script would instantly end before CJ could cause any trouble. You need a loop that waits for a while. Omitting the opcodes from your wait and if statements was not a problem. Sanny would add the required opcodes for these keywords. Now it's working, my savegame just had some issue after compiling the script. I am really thankful to you. OrionSR 1 Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071222592 Share on other sites More sharing options...
The Eagle Eye Posted May 25, 2020 Author Share Posted May 25, 2020 (edited) Hi, I am back again with another step. how to jump to the next "WanterLevel". Now i have added two more levels but i want to know how to go to the next wanted level, only the first one is working and showing the text but the others are not showing anything. please explain how to go to the next one if the first one is true. Sorry to bother you. --- {$CLEO .cs} wait 5000 ms :WantedLevel_1 0001: wait 0 ms 00D6: if 010F: player $PLAYER_CHAR wanted_level == 0 004D: jump_if_false @WantedLevel_1 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL BY 1 STAR" time 1000 0A93: terminate_this_custom_script :WantedLevel_2 0001: wait 5000 ms 00D6: if 0019: player $PLAYER_CHAR wanted_level == 1 004D: jump_if_false @WantedLevel_2 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL BY 2 STAR" time 1000 0A93: terminate_this_custom_script :WantedLevel_3 0001: wait 5000 ms 00D6: if 0019: player $PLAYER_CHAR wanted_level == 2 004D: jump_if_false @WantedLevel_3 0ACD: show_text_highpriority "YOU GOT WANTED LEVEL BY 3 STAR" time 1000 0A93: terminate_this_custom_script Edited May 25, 2020 by The Eagle Eye Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071223153 Share on other sites More sharing options...
OrionSR Posted May 25, 2020 Share Posted May 25, 2020 (edited) 7 hours ago, The Eagle Eye said: 010F: player $PLAYER_CHAR wanted_level == 0 Nice find, but it's not being used correctly. I searched through a main.scm (decompiled with Write Opcodes option enabled) and all examples of opcode 010F use a greater than format. Keep in mind that the text included in a command is ignored by Sanny. If keywords are used instead of opcodes (compare with a script without Write Opcodes enabled) then the text is important. The only important information is the data, in this case; opcode, $PLAYER_CHAR, and 0. The descriptors are just there to make the script easier to read by describing the purpose of the command. Also, the forum software will strip the extra spaces in the conditional commands if you don't include them in code tags - use the <> icon next to the Quote tool in the toolbar. The proper format is: 010F: player $PLAYER_CHAR wanted_level > 0 Tip: You can reverse the action of any conditional check by changing the first digit in the opcode to 8. You can get the functionality you wanted using the following command. 810F: not player $PLAYER_CHAR wanted_level > 0 The opcode below is all messed up - remember, the text doesn't matter. 0019: will return true if a local variable is greater than an integer, and here you are comparing a global variable to an integer; there's another opcode for that. 0019: player $PLAYER_CHAR wanted_level == 1 Main problem: 0A93: terminate_this_custom_script When your script encounters this command it will stop running and won't run again unless you reload a save, start a new game, or re-launch it with another script. I've got other things to do this morning so I'm not ready to consider your larger script. In the meantime, I suggest that you revisit my example above (tweaked wait times) and replace the terminate script command with a loop that waits until the wanted level is 0 before jumping back to the beginning and waiting for another wanted level. Tip: Practice executing the script in your head as you imagine game play and how your actions will change the variables. Keep track of the execution pointer as it jumps through the script at lightning speed until it encounters a wait command. You need to trap the execution pointer within your script and make sure it always has a place to go, wait, or end gracefully. Tip: Describe what you want the script to do in plain text. Start with the general big picture and then start adding details. Do this before asking for help because describing the problem will often offer solutions. Also, broken code seldom explains what you were really trying to do. This isn't a criticism of what you've done, it's just good practice that leads to more efficient codes and quicker progress. Added: Consider a strategy to save the current wanted level when a message is displayed, then compare the current wanted level with the saved wanted level to decide whether to wait, escalate, or de-escalate your messages. Check out this code: (the %u is replaced by the value of 0@) 0AD0: print_formatted "YOU GOT A %u STAR WANTED LEVEL" time 5000 0@ Edited May 25, 2020 by OrionSR Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071223627 Share on other sites More sharing options...
The Eagle Eye Posted May 25, 2020 Author Share Posted May 25, 2020 i have applied it, still it didn't work, even i did some changes to it, nothing happened. i have changed 0@ to 1@ and 2@ that didn't work too. and the opcode text also i applied still didn't work, please tell me that you tested it again and it works on your computer ?! now my computer is allowing it to work but the first one only works, others are not changing. you see there, says JUMP IF FALSE, which means it will start from beginning but if it's TRUE, it DOESN'T JUMP TO THE NEXT LEVEL. please fix the whole script and share it. been waiting for to reply and also couldn't stop fixing this issue. Thanks ----- {$CLEO .cs} wait 5000 ms :WantedLevel_1 0001: wait 0 ms 00D6: if 010F: player $PLAYER_CHAR wanted_level > 0 004D: jump_if_false @WantedLevel_1 0AD0: print_formatted "YOU GOT A %u STAR WANTED LEVEL" time 2000 0@ :WantedLevel_2 0001: wait 2000 ms 00D6: if 0019: player $PLAYER_CHAR wanted_level > 1 004D: jump_if_false @WantedLevel_2 0AD0: print_formatted "YOU GOT A %u STAR WANTED LEVEL" time 2000 0@ :WantedLevel_3 0001: wait 2000 ms 00D6: if 0019: player $PLAYER_CHAR wanted_level > 2 004D: jump_if_false @WantedLevel_3 0AD0: print_formatted "YOU GOT A %u STAR WANTED LEVEL" time 2000 0@ Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071223859 Share on other sites More sharing options...
OrionSR Posted May 26, 2020 Share Posted May 26, 2020 6 hours ago, The Eagle Eye said: please fix the whole script and share it. Uh..., no. You'll learn the wrong lessons about how to code. 0019: player $PLAYER_CHAR wanted_level > 1 The script does advance to level 2 but the command above has the wrong opcode. Compare this line to the similar line in level 1; make the same adjustment to level 3 as well. You script won't work properly even with the fixes suggested above. This goes to my tip on mentally tracing the execution flow. How would your script respond if a one star wanted level is cleared by a bribe? Or CJ skips level 1 by entering a police station or impound and earns a 2 or 3 star wanted level? Try coding this script I wrote and tested. I'll try to describe the script in full detail. You just need to encode the text with the proper opcodes. First describe what the script should do - The script will display a text message that includes the current wanted level whenever the current wanted level changes. Details: Direct Sanny to compile a cleo script. Wait a few seconds for the game to load. Label the top of the main loop. Wait a quarter second before each loop. Store the player's current wanted level to a local variable. If, - the current wanted level is not the same as a saved wanted level then continue. Otherwise, jump to the top of the loop. Display a message with the new wanted level. Set the saved wanted level equal to the variable with the current wanted level. Jump to the top of the loop. Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071224080 Share on other sites More sharing options...
The Eagle Eye Posted May 26, 2020 Author Share Posted May 26, 2020 (edited) I don't know how to create loops. can you gimme an example please. i searched for it on the web but still no similar to this, the script i made is difficult, it's uncomfortable btw. needs high IQ to worked with. Another thing i want to know, what are those called in sanny builder ? when they start with this symbol : this is important that if knew that, i will get more tips, their names are more important than coding. for example as i typed in the script ( :WantedLevel ). what it's called ? Edited May 26, 2020 by The Eagle Eye Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071224302 Share on other sites More sharing options...
OrionSR Posted May 26, 2020 Share Posted May 26, 2020 A very basic loop: {$CLEO .cs} // directive that tells Sanny to compile as a cleo script with a .cs extension 0000: NOP // An opcode that performs No Operation. (because scripts can't jump to a label with an offset of 0) :Top_of_Loop // This is a label, a destination for a jump, gosub, or create thread 0001: wait 100 ms // Most loops need to wait for the game to process information 0109: player $PLAYER_CHAR money += 1 0002: jump @Top_of_Loop // change the execution pointer to the offset marked by the label :Top_of_Loop Technical: Labels such as :Top_of_Loop are not actually compiled into the .cs script. Sanny keeps track of this offset, or total compiled bytes, from the start to that point in the script. Sanny will replace @Top_of_Loop with the value of that offset, in this case -2, since the NOP compiles as two empty bytes (0000). 3 hours ago, The Eagle Eye said: needs high IQ to worked with Well, sort of. Anyone comfortable with basic algebra should be able to learn coding. Your early examples demonstrate that you have the required talent. Don't be discouraged about a great deal of confusion and frustration as you get started - that's perfectly normal. It gets better with more experience, but the frustration never really goes away, and is actually part of the fun - exploration and puzzle solving. 3 hours ago, The Eagle Eye said: I don't know how to create loops. can you gimme an example please. Yeah, I know. I already gave you one example of a loop - the loop that waits until the player has a wanted level greater than 0. Now I'm trying to get you to build your own loop, or rather, extend the loop to the whole script so it doesn't end. In my opinion, you are trying to run before you've learned to walk. So please, try to build the script I described in my previous post. Don't try to expand it into what you want until it's working as described. I'm trying to guarantee your success - stick with me for a bit. For perspective, this is not "your" script. Consider it an assignment. (I don't expect you to enjoy coding mod requests either, but this is a test to see if you will follow instructions.) This script has a clear description so you can tell if it has fulfilled the objectives. You haven't clearly described what your script should do. Each bulleted line in the detailed description represents a line in my test script. Much of the script is the same as the previous example. Some opcodes will need to be changed and you'll need to identify a couple of new opcodes, common ones like jump and local = local. In the end you should have all three parts for the same script. A clear description; always include this when requesting help. A detailed description; when requesting help you need to include the details of where you are having problems, but not necessarily of the whole script. A working script; something you can build on. Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071224670 Share on other sites More sharing options...
The Eagle Eye Posted May 26, 2020 Author Share Posted May 26, 2020 (edited) 4 hours ago, OrionSR said: A very basic loop: {$CLEO .cs} // directive that tells Sanny to compile as a cleo script with a .cs extension 0000: NOP // An opcode that performs No Operation. (because scripts can't jump to a label with an offset of 0) :Top_of_Loop // This is a label, a destination for a jump, gosub, or create thread 0001: wait 100 ms // Most loops need to wait for the game to process information 0109: player $PLAYER_CHAR money += 1 0002: jump @Top_of_Loop // change the execution pointer to the offset marked by the label :Top_of_Loop Technical: Labels such as :Top_of_Loop are not actually compiled into the .cs script. Sanny keeps track of this offset, or total compiled bytes, from the start to that point in the script. Sanny will replace @Top_of_Loop with the value of that offset, in this case -2, since the NOP compiles as two empty bytes (0000). Well, sort of. Anyone comfortable with basic algebra should be able to learn coding. Your early examples demonstrate that you have the required talent. Don't be discouraged about a great deal of confusion and frustration as you get started - that's perfectly normal. It gets better with more experience, but the frustration never really goes away, and is actually part of the fun - exploration and puzzle solving. Yeah, I know. I already gave you one example of a loop - the loop that waits until the player has a wanted level greater than 0. Now I'm trying to get you to build your own loop, or rather, extend the loop to the whole script so it doesn't end. In my opinion, you are trying to run before you've learned to walk. So please, try to build the script I described in my previous post. Don't try to expand it into what you want until it's working as described. I'm trying to guarantee your success - stick with me for a bit. For perspective, this is not "your" script. Consider it an assignment. (I don't expect you to enjoy coding mod requests either, but this is a test to see if you will follow instructions.) This script has a clear description so you can tell if it has fulfilled the objectives. You haven't clearly described what your script should do. Each bulleted line in the detailed description represents a line in my test script. Much of the script is the same as the previous example. Some opcodes will need to be changed and you'll need to identify a couple of new opcodes, common ones like jump and local = local. In the end you should have all three parts for the same script. A clear description; always include this when requesting help. A detailed description; when requesting help you need to include the details of where you are having problems, but not necessarily of the whole script. A working script; something you can build on. Does jf mean jump if false or what ? and also what I understand that jump means to move to another label or whatever, but what does that mean ? Gotta tell you more about issue, I even tried a special script for each label, still WL2 and WL3 didn't work, only first one worked. I think this is an issue from sanny builder. ----- LOOK!! I HAVE MADE IT. {$CLEO .cs} THREAD 'WANTED_LEVEL' :WantedLevel_1 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 0 004D: jump_if_false @WantedLevel_1 0AD0: print_formatted "YOU GOT A 1 STAR WANTED LEVEL" time 3000 ms jump @WantedLevel_2 :WantedLevel_2 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 1 004D: jump_if_false @WantedLevel_2 0AD0: print_formatted "YOU GOT A 2 STAR WANTED LEVEL" time 3000 ms jump @WantedLevel_3 :WantedLevel_3 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 2 004D: jump_if_false @WantedLevel_3 0AD0: print_formatted "YOU GOT A 3 STAR WANTED LEVEL" time 3000 ms jump @WantedLevel_4 :WantedLevel_4 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 3 004D: jump_if_false @WantedLevel_4 0AD0: print_formatted "YOU GOT A 4 STAR WANTED LEVEL" time 3000 ms jump @WantedLevel_5 :WantedLevel_5 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 4 004D: jump_if_false @WantedLevel_5 0AD0: print_formatted "YOU GOT A 5 STAR WANTED LEVEL" time 3000 ms jump @WantedLevel_6 :WantedLevel_6 0001: wait 0 ms 00D6: if player.WantedLevel($PLAYER_CHAR) > 0 004D: jump_if_false @WantedLevel_6 0AD0: print_formatted "YOU GOT A 6 STAR WANTED LEVEL" time 3000 ms 004E: end_thread but the only thing left is when the stars are suspended, the message will not be shown again, only one time. as you see in the end I typed END THREAD so the game won't crash, before i do that, i typed JUMP @wantedlevel1 which displays the first label message. gonna fix that problem if I could. Edited May 26, 2020 by The Eagle Eye Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071225002 Share on other sites More sharing options...
OrionSR Posted May 26, 2020 Share Posted May 26, 2020 (edited) 1 hour ago, The Eagle Eye said: Does jf mean jump if false or what ? Yes, jf is a keyword that can be used instead of opcode 004D:. Sanny will highlight keywords with bold text. When Sanny encounters this keyword it knows to convert the line with the 004D: opcode. Decompiling scripts without the Show Opcodes option enabled, the default setting, will result in a format with keywords and classes. I prefer to post codes with the Show Opcodes format, but for my own private use I frequently use keywords. For a list of keywords available in Sanny, check keywords.txt in the edit mode folder for that game. (else_jump is another keyword for 004D:) Execution flow, I've been suggesting that you trace the execution order of the script in your head - maybe start with your finger. How to explain...? Let's try a train analogy, see how long it holds up. Your train will leave the train yard (top of script) and travel down, executing each command in turn, until it quite literally crashes (the game) when it runs out of tracks. That's why it's important to include a safe terminal (terminate_this_custom_script). Or, if you want the train to keep running, you could divert the train (with a jump command) to loop back around to the top of the track. But for that you need a valid destination station (label). Tracing the route of the train again, it leaves the train yard and travels to a station, waits a bit, and then continues down the track until it comes to a junction, (jump_if_false) where it might get diverted somewhere else if it doesn't pass the test. Or a fork (jump table) which can lead to several destinations depending on it's routing number. Or a branch (gosub), which will divert the train along a different track that will return to the same location and continue down the track. So, a little extra information, sorry. But the point is, there aren't that many ways to divert the train. Jump if false and basic jumps are by far the most common. You need to be able to follow your train, know where it's going, and whether or not it is passing the tests or stuck in a loop. It takes practice, but it will be difficult to continue if you can't figure it out. Keep trying. You're getting close. Edited May 26, 2020 by OrionSR Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071225199 Share on other sites More sharing options...
The Eagle Eye Posted May 27, 2020 Author Share Posted May 27, 2020 How to use LESS THAN, when i type:- player.WantedLevel($PLAYER_CHAR) < 5 it can't compile it. it says it's and error. please explain. Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071226279 Share on other sites More sharing options...
OrionSR Posted May 27, 2020 Share Posted May 27, 2020 1 hour ago, The Eagle Eye said: How to use LESS THAN You can't, directly. Open Sanny's Opcode Search Tool (Ctrl-Alt-2) and search for "<" and you won't find any examples. You could try: 810F: not player $PLAYER_CHAR wanted_level > 4 Or, read the current wanted level to a variable and reverse the order of the parameters. (If the wanted level < 5 then 5 must be > the wanted level.) 01C0: 0@ = player $PLAYER_CHAR wanted_level 00D6: if 001B: 5 > 0@ ... Thanks for using code tags. Link to comment https://gtaforums.com/topic/955586-sa-whats-wrong-with-this-cleo-script/#findComment-1071226341 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