Page 1 of 1

Help with HUD

Posted: Mon Nov 12, 2007 1:13 pm
by Masta_J
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

Posted: Mon Nov 12, 2007 4:07 pm
by Juutis
Patience, my friend. You would've gotten an answer to the other thread too. It just may take some days. :)
PAWNHEALTH [self.health]
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.

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");
}
}]

Posted: Mon Nov 12, 2007 4:20 pm
by Jay
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 :)

Posted: Mon Nov 12, 2007 4:28 pm
by Juutis
Ah yes, I was being my dumb self again. Ignore my post and listen to Jay. :)

Posted: Mon Nov 12, 2007 9:51 pm
by Masta_J
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?

Posted: Tue Nov 13, 2007 3:19 pm
by fps
i have never gotten an error message like that.
it might be your computer.