Frictional Games Forum (read-only)

Full Version: Shows how much health you have.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there anyway to put a message on the top of the screen , that shows your health in a number ? (kinda like : "YOUR HEALTH : 100%")
Maybe we can script a loop that checks for player health's every 0.2 seconds ?

Thanks.
I think you need to make a certain model for that.

I'm not sure though.
You could use set message and get player health with an if statement. something like:

void CheckHealth(string &in asTimer)
{

AddTimer("", 0.2f, "CheckHealth")

if (GetPlayerHealth == 100)
{
SetMessage("Health", "100", 0);
}
}

Repeating the script 100 times (for 0-100).
(08-22-2012, 11:05 PM)andyrockin123 Wrote: [ -> ]You could use set message and get player health with an if statement. something like:

void CheckHealth(string &in asTimer)
{

AddTimer("", 0.2f, "CheckHealth")

if (GetPlayerHealth == 100)
{
SetMessage("Health", "100", 0);
}
}

Repeating the script 100 times (for 0-100).
That's a long way to go, but it should work completely. But the text would always appear on the center of the screen. But yeah, this is a great way to try it out.
There may be a way to convert the integer generated by GetPlayerHealth into a string usable with the SetMessage function so you don't literally have to write it out 100 times. I did some research, but I'm not all that familiar with complicated programming, so you can take a look yourself:

PHP Code:
string convertInt(int number)
{
   
stringstream ss;//create a stringstream
   
ss << number;//add number to the stream
   
return ss.str();//return a string with the contents of the stream


PHP Code:
string convertInt(int number)
{
    if (
number == 0)
        return 
"0";
    
string temp="";
    
string returnvalue="";
    while (
number>0)
    {
        
temp+=number%10+48;
        
number/=10;
    }
    for (
int i=0;i<temp.length();i++)
        
returnvalue+=temp[temp.length()-i-1];
    return 
returnvalue;