Frictional Games Forum (read-only)

Full Version: If players health is below x, y happens
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I want my player to die "instantly" when hit by a specific monster. And before you ask, no, I will not adjust the settings of the monster in the model editor. I want it to be script only. So I had an idea. If the players health is below 99 (100 is the default right?) it will activate setplayerhealth(0);. But unfortunately, I am terrible with the "if" stuff. What I have right now is

void A(Syntax stuff here)
{
if ((getplayerhealth)==<99)
{
Setplayerhealth(0);

}

It comes up with an expression value error.

Please ignore the spelling errors, the missing syntax and the missing capitals, I am writing this on my pone because my internet doesn't work on my pc anymore.
Here's what I made; a timer that checks the players health every 0.2f to see if its less than or equal to 99.


void OnStart()
{
AddTimer("", 0.2f, "CheckHealth");
}

void CheckHealth(string &in asTimer)
{
AddTimer("", 0.2f, "CheckHealth");

if(GetPlayerHealth() <= 99.0f)
{
SetPlayerHealth(0.0f);
}

}