Frictional Games Forum (read-only)
[SCRIPT] Shows how much health you have. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Shows how much health you have. (/thread-17912.html)



Shows how much health you have. - onv - 08-22-2012

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.


RE: Shows how much health you have. - Melvin - 08-22-2012

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

I'm not sure though.


RE: Shows how much health you have. - Adny - 08-22-2012

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).


RE: Shows how much health you have. - Robby - 08-23-2012

(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.


RE: Shows how much health you have. - Damascus - 08-23-2012

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;