M U N D U Posted May 28, 2017 Share Posted May 28, 2017 (edited) I've just started learning how to write scripts in cleo so therefore I decided to attempt to make a simple script that sets the player's health back to 100 whenever the "H" key is pressed however in-game this doesn't seem to work. My guess is i'm using a wrong opcode as the syntax seems to be fine according to the compiler. {$CLEO .cs}:Heal03A4: name_thread "Heal"wait 1000:Heal_1wait 0if0256: player $PLAYER_CHAR defined 004D: jump_if_false @Heal_1if00E1: key_pressed 0 72004D: jump_if_false @Heal_10222: set_player_health $PLAYER_CHAR, 100wait 10jump @Heal_1 Can someone help me out with this one?I'm pretty clueless so far. Edited May 28, 2017 by Panda_AE86 Link to comment Share on other sites More sharing options...
Lancerator Posted May 28, 2017 Share Posted May 28, 2017 (edited) I'm a newbie as well so I can't help you that much, but try this by putting the x in the middle: 00E1: key_pressed 0x72 Also, afaic the 72 key is the 8. Check this. Edited May 28, 2017 by SMACKED! M U N D U 1 Link to comment Share on other sites More sharing options...
M U N D U Posted May 28, 2017 Author Share Posted May 28, 2017 (edited) I also tried to add a text box so I'm sure I'm pressing the right button but it's still not working if I do key_pressed 0x72 the compiler complains that it needs 2 parameters (Changed key code to 86) and I've re-written the script. {$CLEO .cs}:HEALSCRIPT03A4: name_thread "Heal"wait 1000:HEALSCRIPT_1wait 0if0256: player $PLAYER_CHAR defined 004D: jump_if_false @HEALSCRIPT_1if00E1: key_pressed 0 86004D: jump_if_false @HEALSCRIPT_10222: set_player_health $PLAYER_CHAR, 1000ACE: show_formatted_text_box "Player Healed" 0x0ACEwait 10jump @HEALSCRIPT_1 Edited May 28, 2017 by Panda_AE86 Link to comment Share on other sites More sharing options...
Mysterdogg Posted May 28, 2017 Share Posted May 28, 2017 This can be a beginning: //------[email protected] = Actor.EmulateFromPlayer(0):NONAME_1wait 0 if 0AB0: key_pressed 72else_jump @NONAME_2 [email protected] = Actor.Health([email protected])[email protected] += 100 Actor.Health([email protected]) = [email protected]: show_formatted_text_box "Player Healed" 0x0ACEwait 10:NONAME_2jump @NONAME_1 After a quick check with your code, made this, it isn't perfect but it does what you wanted. You can now try to improve it. M U N D U 1 Link to comment Share on other sites More sharing options...
M U N D U Posted May 28, 2017 Author Share Posted May 28, 2017 (edited) This can be a beginning: //[email protected] = Actor.EmulateFromPlayer(0):NONAME_1wait 0 if 0AB0: key_pressed 72else_jump @NONAME_2 [email protected] = Actor.Health([email protected])[email protected] += 100 Actor.Health([email protected]) = [email protected]: show_formatted_text_box "Player Healed" 0x0ACEwait 10:NONAME_2jump @NONAME_1 After a quick check with your code, made this, it isn't perfect but it does what you wanted. You can now try to improve it. That worked however i'm trying to understand why my approach doesn't work. Not meaning to be an asshole, I just want to try and understand the logic Thanks for the help Edited May 28, 2017 by Panda_AE86 Link to comment Share on other sites More sharing options...
Springfield Posted May 28, 2017 Share Posted May 28, 2017 (edited) {$CLEO .cs}0000: NOP 0226: [email protected] = actor $PLAYER_ACTOR health WHILE True wait 0if 0AB0: key_pressed 72 then [email protected] += 100 0223: set_actor $PLAYER_ACTOR health_to [email protected] endend Here is the example in High-Level language! {$CLEO .cs}0000: NOP 0226: [email protected] = actor $PLAYER_ACTOR health :HH wait 0if 0AB0: key_pressed 72 jf @HH [email protected] += 100 0223: set_actor $PLAYER_ACTOR health_to [email protected] jump @HHend_thread Here is the example in Low-Level! Edited May 29, 2017 by Springfield M U N D U 1 Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 Thanks to both of you guys! I tried combining both and it works! Now I'll experiment with adding an option to set armor to 100% Link to comment Share on other sites More sharing options...
Springfield Posted May 29, 2017 Share Posted May 29, 2017 For armour, replace 0226 opcode with this: 04DD: [email protected] = actor $PLAYER_ACTOR armour and you're done! Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 I guess I'm missing that opcode now The Opcode database is currently down so i guess I'll mess with it tomorrow! Link to comment Share on other sites More sharing options...
deltaCJ Posted May 29, 2017 Share Posted May 29, 2017 There is already a opcode database built in Sanny. Ctrl Alt 2 Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 Yep there is but it doesn't have the whole list I guess Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 Just for future reference for anyone that may be looking for help with this kind of thing, here's the fully working script with 1 second of delay between each action: {$CLEO .cs}0226: [email protected] = actor $PLAYER_ACTOR health //Declare variable [email protected] and store the vlaue of OPCODE 0026 (Health)04DD: [email protected] = actor $PLAYER_ACTOR armour //Declare variable [email protected] and store the vlaue of OPCODE 04DD (Armour) :HEALwait 0 if 0AB0: key_pressed 72 //Make sure that "H" is pressedelse_jump @ARMOUR // If not ignore this part and jump to the second [email protected] += 100 //Add 100 to whatever is in variale [email protected]: set_actor $PLAYER_ACTOR health_to [email protected] //set the player's health to what we have store in variable [email protected]: show_formatted_text_box "Player Healed" 0x0ACE //Showing a text box at the top of the screenwait 1000 //Wait one second before allowing the script to be ran again:ARMOURwait 0 if 0AB0: key_pressed 71 // Make sure that "G" is pressedelse_jump @HEAL // if not go back to the first [email protected] += 100 // Add 100 to whatever value is store in @2035F: set_actor $PLAYER_ACTOR armour_to [email protected] //Set the player's armour level to whatever is store in [email protected]: show_formatted_text_box "Player Armored" 0x0ACE //Show a text box at the top of the screenwait 1000 //Wait 1 second before running the script again0002: jump @HEAL // After completing this script jump back to the first part to start the process over again Link to comment Share on other sites More sharing options...
Super Shizuku Posted May 29, 2017 Share Posted May 29, 2017 If I want to make the reversed version of this script, can I just simply change the value? Link to comment Share on other sites More sharing options...
deltaCJ Posted May 29, 2017 Share Posted May 29, 2017 If I want to make the reversed version of this script, can I just simply change the value? Yes you can, but you have to make sure it is -= 50 not 100 cuz -100 will kill you. Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 (edited) If I want to make the reversed version of this script, can I just simply change the value? Yes you can, but you have to make sure it is -= 50 not 100 cuz -100 will kill you. I tried doing -=50 for the Armour but that doesn't remove 50 points from the Armour bar it removes 100 points for some reason (Basically removes Armour) However the health works fine with that Edited May 29, 2017 by M U N D U Link to comment Share on other sites More sharing options...
deltaCJ Posted May 29, 2017 Share Posted May 29, 2017 If I want to make the reversed version of this script, can I just simply change the value? Yes you can, but you have to make sure it is -= 50 not 100 cuz -100 will kill you. I tried doing -=50 for the Armour but that doesn't remove 50 points from the Armour bar it removes 100 points for some reason (Basically removes Armour) However the health works fine with that Ahhh, I know why, it's because armor is less than health. So make it -25 Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 (edited) I decided to re-write the code again to make it more expandable however I can't figure out a way to use an else if condition since I'm kinda familiar with python and I can't seem to find any tutorials online about it. Here's the code (I know it's incorrect ) {$CLEO .cs}0226: [email protected] = actor $PLAYER_ACTOR health //Declare variable [email protected] and store the vlaue of OPCODE 0026 (Health)04DD: [email protected] = actor $PLAYER_ACTOR armour //Declare variable [email protected] and store the vlaue of OPCODE 04DD (Armour)010B: [email protected] = actor $PLAYER_ACTOR money //Declare variable [email protected] and store the vlaue of OPCODE 010B (Money)//--------------------------------------------------------------------------------------------------------:MAIN_MENUif0AB0: key_pressed 72 //Make sure that "H" is pressedJump @HEALelse0AB0: key_pressed 71 //Make sure that "G" is pressedJump @ARMOURelse if0AB0: key_pressed 77 //Make sure that "M" is pressedJump @MONEY//--------------------------------------------------------------------------------------------------------:HEALwait 0 [email protected] += 100 //Add 100 to whatever is in variale [email protected]: set_actor $PLAYER_ACTOR health_to [email protected] //set the player's health to what we have store in variable [email protected]: show_formatted_text_box "Player Healed" 0x0ACE //Showing a text box at the top of the screenwait 1000 //Wait one second before allowing the script to be ran againJump @MAIN_MENU //Go back to the main menu//---------------------------------------------------------------------------------------------------------:ARMOURwait 0 [email protected] += 100 // Add 100 to whatever value is store in @2035F: set_actor $PLAYER_ACTOR armour_to [email protected] //Set the player's armour level to whatever is store in [email protected]: show_formatted_text_box "Player Armored" 0x0ACE //Show a text box at the top of the screenwait 1000 //Wait 1 second before running the script againjump @MAIN_MENU // After completing this script jump back to the first part to start the process over again//----------------------------------------------------------------------------------------------------------:MONEYwait [email protected] +=99999999903FE: set_actor $PLAYER_ACTOR money_to [email protected]: show_formatted_text_box "Funds have been added" 0x0ACE //Show a text box at the top of the screenwait 1000 //Wait 1 second before running the script againjump @MAIN_MENU // After completing this script jump back to the first part to start the process over again//----------------------------------------------------------------------------------------------------------- Edited May 29, 2017 by M U N D U Link to comment Share on other sites More sharing options...
Lancerator Posted May 29, 2017 Share Posted May 29, 2017 You're saying that you're not familiar with else? I asked something related ages ago. Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 I tried doing something like that but I still get an error Link to comment Share on other sites More sharing options...
kosticn101 Posted May 29, 2017 Share Posted May 29, 2017 (edited) Hi. I think that there isn't IF...THEN...ELSE IF statement in Sanny Builder. if condition(s)then do somethingend if condition(s)then what to do if condition is satisfiedelse what to do if condition isn't satisfiedend This code should compile. while true wait 0//:BEGINNING//wait 0 if 0AB0: key_pressed 72 then [email protected] += 100 0223: set_actor $PLAYER_ACTOR health_to [email protected] 0ACE: show_formatted_text_box "Player Healed" 0x0ACE wait 1000 //if you don't want to test for key_pressed 71 and 77 you can use "continue". //loop will start over, ie. rest of code in a loop will be skipped. continue //this is same as jump @BEGINNING end if 0AB0: key_pressed 71 then //...do something... continue //loop will start over and key_pressed 77 will be skipped <=> jump @BEGINNING end if 0AB0: key_pressed 77 then //...do something... endend Also, in low level there is only if..else_jump statement, so you can't say if...jump, but you can say if...else_jump...jump. if conditionelse_jump @COND_ISNOT_SATISFIEDjump @COND_IS_SATISFIED Just a note. while true wait 0 //...something...end is same as :STARTwait 0//..something..jump @START First is high level syntax, and second is in low level syntax. If...then...else is part of high level syntax also, if...else_jump is low level. You can use either and you can mix them but eg. for me is easier to read and understand high level. This is also possible. //rest of your code//----------------------------:MAIN_MENUwait 0 //without this game will freezeif 0AB0: key_pressed 72 //Make sure that "H" is pressedthen Jump @HEALendif 0AB0: key_pressed 71 //Make sure that "G" is pressedthen Jump @ARMOURendif 0AB0: key_pressed 77 //Make sure that "M" is pressedthen Jump @MONEYendJump @MAIN_MENU//-------------------------//rest of your code Edited May 29, 2017 by kosticn101 M U N D U and deltaCJ 2 Link to comment Share on other sites More sharing options...
M U N D U Posted May 29, 2017 Author Share Posted May 29, 2017 (edited) //rest of your code//----------------------------:MAIN_MENUwait 0 //without this game will freezeif 0AB0: key_pressed 72 //Make sure that "H" is pressedthen Jump @HEALendif 0AB0: key_pressed 71 //Make sure that "G" is pressedthen Jump @ARMOURendif 0AB0: key_pressed 77 //Make sure that "M" is pressedthen Jump @MONEYendJump @MAIN_MENU//-------------------------//rest of your code That last one was what I was aiming to do! Thanks very much for the detailed explanation! Edited May 29, 2017 by M U N D U deltaCJ and kosticn101 2 Link to comment Share on other sites More sharing options...
skatefilter5 Posted May 29, 2017 Share Posted May 29, 2017 does the formatted text show only big capital letters "0ACE: show_formatted_text_box "Player Healed" 0x0ACE"? Link to comment Share on other sites More sharing options...
deltaCJ Posted May 30, 2017 Share Posted May 30, 2017 does the formatted text show only big capital letters "0ACE: show_formatted_text_box "Player Healed" 0x0ACE"? No? It just shows the text lmao... Link to comment Share on other sites More sharing options...
kosticn101 Posted June 2, 2017 Share Posted June 2, 2017 (edited) 2 M U N D U 035F: set_actor $PLAYER_ACTOR armour_to [email protected] //Set the player's armour level to whatever is store in [email protected] Hey, this actually increases players armour for amount that is stored in [email protected] It looks like that your opcode description is wrong: http://gtaforums.com/topic/888326-critical-health-script/?p=1069609277. So you can experience unwanted behaviour. 03FE: set_actor $PLAYER_ACTOR money_to [email protected] This opcode doesn't apply to player. For player you have 0109: player $PLAYER_CHAR money += [email protected]. It also increases player's money for specified amount. It looks like there is no opcode to set player's money and armour to given amount if you want to do it. What you can do is to decrease it first to 0, and then increase it for wanted amount. Example on how to set player's armour to eg. 50: 04DD: [email protected] = actor $PLAYER_ACTOR armour0012: [email protected] *= -1035F: actor $PLAYER_ACTOUR armour += [email protected] //armour is now 0035F: actor $PLAYER_ACTOUR armour += 50 //armour is now 50Same thing goes for player's money. Edited June 2, 2017 by kosticn101 Link to comment Share on other sites More sharing options...