Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If players health is below x, y happens
ApeCake Offline
Member

Posts: 116
Threads: 20
Joined: Jun 2012
Reputation: 4
#1
If players health is below x, y happens

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.
07-21-2012, 02:20 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: If players health is below x, y happens

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

}

I rate it 3 memes.
07-21-2012, 02:36 PM
Find




Users browsing this thread: 1 Guest(s)