Jump to content

Get players max health.


chaosislife

Recommended Posts

I'm trying to figure out how to "get" not "set" the players max health with stat 24 and set it as a local var so I can compare it to the player present health. I've seen instances for how to add to players max health but nothing yet on how to find out what the players max health is. Anyone got an idea?

Link to comment
Share on other sites

Taken from Wesser's Windshield GUI, should work well.

 

 

0653: 0@ = float_stat 24 0017: 0@ /= 5.690092: 0@ = float 0@ to_integer

 

 

I don't know how the multiplier was made, I trust Wess though tounge.gif

Link to comment
Share on other sites

thanks, I'll try that out.

 

Edit: Sanny doesn't seem to like the if 2@ < 3@ operation in this

:Regen_1wait 5ifplayer.Defined(#PLAYER_CHAR)jf @Regen_1:Regen_20wait 5002@ = Actor.Health($PLAYER_ACTOR)0653: 3@ = float_stat 24if2@ < 3@jf @Regen_12@ += 1 Actor.Health($PLAYER_ACTOR) = 2@jump @Regen_1

, is it even possible to compare the two like that? I can actually get it to work fine without needing to check if the present health is lower than the max health, it's just that it shouldn't continue adding a hitpoint once the health is back to full.

Edited by chaosislife
Link to comment
Share on other sites

Silent, I took it from Demarest's source, so you have to trust him though. tounge.gif

 

chaos, SB doesn't recognize that structure when comparing 2 values without typing any opcode number. You should do something like this (untested):

 

{$CLEO}0000: NOPvar 1@: Integer 2@: Integerendwhile true wait 0  if  0256:  player $PLAYER_CHAR defined then   0226: 1@ = actor $PLAYER_ACTOR health   0A96: 0@ = actor $PLAYER_ACTOR struct   0@ += 0x544    0A8D: 2@ = read_memory 0@ size 4 virtual_protect 0    0092: 2@ = float 2@ to_integer   if      1@ < 2@    then     2@ += 1      0223: set_actor $PLAYER_ACTOR health_to 2@    end endend

 

It's better reading the max health value over the memory. This little list would help.

Link to comment
Share on other sites

Wouldn't that only work in cleo? Cleo doesn't seem to work well on my windows 7 so I'm just doing everything in the regular scm.

Link to comment
Share on other sites

ya I did that and i got a message about needing the cleo library for it, and trying to download that from within sanny failed for some reason. I had cleo in before, but i removed the asi and the folder for it to see if that was why my game was crashing within a few minutes of running it. It's also possible that it's due to the "bikearmfix.asi" that is part of the skateboard animation mod.

 

 

EDIT: anyhow, in case anyone is interested here's the code for this regeneration

:Regen_1wait 5ifPlayer.Defined($PLAYER_CHAR)jf @Regen_1:Regen_20wait 252@ = Actor.Health($PLAYER_ACTOR)2@ += 1 Actor.Health($PLAYER_ACTOR) = 2@jump @Regen_1

 

 

Just change the wait and the value of 2@ +=1 to change the speed and amount of health regenerated. It has yet to cause me an error even without the check for max health now that I figured out what was causing me errors before. (i didn't rebuild the archive) I've seen 1-2 other regeneration codes, one was convoluted so i couldn't actually figured out what it was doing and the other was locked so i couldn't check it.

Edited by chaosislife
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
  • 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.