Jump to content

Sign in to follow this  
A-SUICIDAL

Health detection with silent hint (need help)

Recommended Posts

I'm trying to write a script that detects how much damage you have taken and then uses a hintsilent to let you know what your current health is. Here's is what I have written so far, but it doesn't work and before I try a zillion different ways to try to get it to work, I figured I would come here and ask the scripting gods for help. I have a trigger with like a 20000 radius set to repeatedly group to the player. It sidechats the message in the beginning, but then I hop on an ATV and slam myself into a wall to hurt myself, which is when it is supposed to tell me what my current health is, but the hints are not appearing, which means my script needs help. Thanks in advance.

s1 sideChat "starting health check system for player s1";
#loop
if (_target == _this) && (damage _this > 0.9) && (damage _this < 1.0) exitWith { hintsilent "1 HP"; };
} else {
if (_target == _this) && (damage _this > 0.8) && (damage _this < 0.9) exitWith { hintsilent "2 HP"; };
} else {
if (_target == _this) && (damage _this > 0.7) && (damage _this < 0.8) exitWith { hintsilent "3 HP"; };
} else {
if (_target == _this) && (damage _this > 0.6) && (damage _this < 0.7) exitWith { hintsilent "4 HP"; };
} else {
if (_target == _this) && (damage _this > 0.5) && (damage _this < 0.6) exitWith { hintsilent "5 HP"; };
} else {
if (_target == _this) && (damage _this > 0.4) && (damage _this < 0.5) exitWith { hintsilent "6 HP"; };
} else {
if (_target == _this) && (damage _this > 0.3) && (damage _this < 0.4) exitWith { hintsilent "7 HP"; };
} else {
if (_target == _this) && (damage _this > 0.2) && (damage _this < 0.3) exitWith { hintsilent "8 HP"; };
} else {
if (_target == _this) && (damage _this > 0.1) && (damage _this < 0.2) exitWith { hintsilent "9 HP"; };
};
goto "loop"

Share this post


Link to post
Share on other sites

Test this in your init.sqf

nul = [] spawn {
 while {sleep 0.5;alive player} do {
   hintsilent format ["%1 HP",(round (9 - (damage player * 10)))];
 };
};

Share this post


Link to post
Share on other sites

Yes this works well, thank you. But I'd prefer if the message would fade away after a few moments, but reappear if the player is hurt more. Or maybe have it always showing the current health in the bottom left or right corner of the screen instead of in a hint box, since the missions I make often have a hint box appear at times for certain completed tasks and other things and I'd rather not have a "% HP" hint box open the entire game.

I changed the above script to this:

nul = [] spawn {
 while {sleep 0.5;alive player} do {
   hintsilent format ["%1 Percent Health",(round (100 - (damage player * 110)))];
 };
};

...so now if I were to, lets say, hit a tree while driving an ATV, the hint box then suddenly says something like, "82 Percent Health". And if I hit another tree, it updates and then says something like, "68 Percent Health".

Is there a way to make this appear at the bottom left or right corner of the game throughout the game without using a text box?

Share this post


Link to post
Share on other sites

Now I'm searching and reading everything about dialogs that I can find and how to make this work and I'm already losing my mind. lol. Is there a simple tutorial someplace for what I am trying to do?

Share this post


Link to post
Share on other sites

Probably best to start off with an already existing mission that utilizes dialogs/display resources, and strip off the rest. It can be pretty ugly. Prepare for a lot of crashes :p

Share this post


Link to post
Share on other sites

ok, got it working, but my green tahomaB text refuses to show its shadow even though I have the shadow set to be true and the color set to black. I guess it's not that big a deal.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×