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
Script Help [FIXED] "If get player health" function?
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#5
RE: "If get player health" function?

(05-12-2016, 08:32 PM)Darkfire Wrote: This way it will check the health only once. If you want to check it constantly, you have to use a timer loop (or is there maybe a different way ? I dunno one)
For example
PHP Code: (Select All)
void OnStart()
{
     
AddTimer("TimerName"1.0f"TimerFunction");
}

void TimerFunction(string &in asTimer)
{
     if(
GetPlayerHealth() == 100.0f
         {
             
FadeImageTrailTo(0,0.2f); 
             
CompleteQuest("quest_heal""heal");
         }
      
AddTimer("TimerName"1.0f"TimerFunction"); 

You end up with this: a timer calls a function, which checks if you have health and then starts another timer which leads back to the same function. Loop closed.
Note how to use "if" functions: there's no ; semicolon and another function bracket {} next to the statement - because it's function within a function. Inception shit, eh ?

EDIT:
If you want it to be triggered after entering an area just put the first timer function in the entity collide function.

I want the code to be triggered constantly, but thanks for your propositions anyway.

The problem has been resolved, you can lock up the thread.
(This post was last modified: 05-12-2016, 09:02 PM by Slanderous.)
05-12-2016, 08:50 PM
Find


Messages In This Thread
RE: "If get player health" function? - by Slanderous - 05-12-2016, 08:50 PM



Users browsing this thread: 1 Guest(s)