Hi guys, trying to get a a working health bar for my player pawn. Sorry for the repost, but doesn't like anyone's reading or responding to my older thread anymore. I took Juutis's advice and used the built in players health bar. I sinchronised the player pawn and built in players health with the following bit of code, and set the health attribute to the same as my pawns in player.ini. However, if my player pawn gets hit once, he is still alive, but the health bar is reduced to 0. Any ideas on how to correct this?
HEALTHATTRIB [healthgood]
PAWNHEALTH [self.health]
if(self.in_pain)
{
self.think="Pain";
}
}]
Pain[()
{
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
self.think="Fight";
}
}]
Here's a copy of the health attribute code in the player.ini
[healthgood]
type = horizontal
frame = hud\hud_health_oxygen.bmp
framealpha = hud\a_hud_health.bmp
indicator = hud\hud_health_oxygeni.bmp
indicatoralpha = hud\a_hud_healthi.bmp
framex = 10
framey = 10
indicatoroffsetx = 75
indicatoroffsety = 0
indicatorwidth = 160
active = true
Help with HUD
Help with HUD
A good warrior knows his limits, but a great warrior finds his way around them.
Patience, my friend. You would've gotten an answer to the other thread too. It just may take some days.
Also you don't need a seperate pain order when in low level (unless you really want it). You can write:
I don't get this. Is this supposed to define the amount of the health attribute? If so, you should try using 'PAWNHEALTH [100]' or something like that.PAWNHEALTH [self.health]
Also you don't need a seperate pain order when in low level (unless you really want it). You can write:
Code: Select all
if(self.in_pain)
{
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
}
}]
Pain is only psychological.
You are trying to set an attribute to a string. Let me explain:
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
PAWNHEALTH is a string, namely "self.health".
Because of this, you are doing this:
SetAttribute(HEALTHATTRIB,"self.health","Player");
This cannot work, because rf thinks you want to set the player's health attribute to "self.health". Attributes can only be numbers, no strings, and so rf just sets the attribute to 0.
If you want it to work, just type:
SetAttribute(HEALTHATTRIB,self.health,"Player");
This is different, because now rf sees that self.health is a value and no string.
hope this helps
SetAttribute(HEALTHATTRIB,PAWNHEALTH,"Player");
PAWNHEALTH is a string, namely "self.health".
Because of this, you are doing this:
SetAttribute(HEALTHATTRIB,"self.health","Player");
This cannot work, because rf thinks you want to set the player's health attribute to "self.health". Attributes can only be numbers, no strings, and so rf just sets the attribute to 0.
If you want it to work, just type:
SetAttribute(HEALTHATTRIB,self.health,"Player");
This is different, because now rf sees that self.health is a value and no string.
hope this helps
Everyone can see the difficult, but only the wise can see the simple.
-----
-----
Oh, Ok... Didn't realise that would make a differences. Tried it, and it works fine. Sorry for lack of patience, don't get much time to work on my game. All my time gets taken up by my pregnant wife and work. Thanks alot for da help guys. By the way, do you guys have any idea why I keep getting an error message saying, "Invalid session. Please resubmit the form," when trying to reply on the form?
A good warrior knows his limits, but a great warrior finds his way around them.