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. Forum Support

    3. Suggestions

Cleo script to heal the player when a key is pressed


M U N D U
 Share

Recommended Posts

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 by Panda_AE86
Link to comment
Share on other sites

Lancerator

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 by SMACKED!
Link to comment
Share on other sites

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 by Panda_AE86
Link to comment
Share on other sites

Mysterdogg

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.

Link to comment
Share on other sites

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 by Panda_AE86
Link to comment
Share on other sites

Springfield
{$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 by Springfield
Link to comment
Share on other sites

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

aiyOdUR.png

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

There is already a opcode database built in Sanny.

 

Ctrl Alt 2

Link to comment
Share on other sites

Yep there is but it doesn't have the whole list I guess

Link to comment
Share on other sites

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

Super Shizuku

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

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

 

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 by M U N D U
Link to comment
Share on other sites

 

 

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

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 by M U N D U
Link to comment
Share on other sites

I tried doing something like that but I still get an error

0QdigzP.png

Link to comment
Share on other sites

kosticn101

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 by kosticn101
  • Like 2
Link to comment
Share on other sites

 

//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 by M U N D U
  • Like 2
Link to comment
Share on other sites

skatefilter5

does the formatted text show only big capital letters "0ACE: show_formatted_text_box "Player Healed" 0x0ACE"?

Link to comment
Share on other sites

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

kosticn101

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 50
Same thing goes for player's money. Edited by kosticn101
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.