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 Activating a monster if the player stands in area for certain time problem [SOLVED]
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#1
Activating a monster if the player stands in area for certain time problem [SOLVED]

Hey. I've been making a script on a separated map just to test it out, basically what I'm aiming to do is activating a monster if the player stands in a specific area for 5 seconds. The problem is, no matter whether I stand there for 1, 2 or 4 seconds, the monster still spawns.

Here is what my .hps file contains.

Thanks in advance

PS. Sorry for damn long thread name, but I didn't know how to describe it shorter.
(This post was last modified: 07-18-2015, 07:32 PM by Slanderous.)
07-18-2015, 05:55 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Activating a monster if the player stands in area for certain time problem

Make it simple. The simpler the better.

After entering the area, add a timer. Upon leaving the area, remove the timer. Have the monster enable in the timer callback.

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""SpidersHatch"false0);
}

void SpidersHatch(string &in asParentstring &in asChildint alState)
{
    if(
alState == 1AddTimer("hatch_time"5.0f"Hatching_Timer");
    if(
alState == -1RemoveTimer("hatch_time");
}

void Hatching_Timer(string &in asTimer)
{
    
SetEntityActive("Spiders?"true);


(This post was last modified: 07-18-2015, 06:32 PM by Mudbill.)
07-18-2015, 06:31 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#3
RE: Activating a monster if the player stands in area for certain time problem

(07-18-2015, 06:31 PM)Mudbill Wrote: Make it simple. The simpler the better.

After entering the area, add a timer. Upon leaving the area, remove the timer. Have the monster enable in the timer callback.

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""SpidersHatch"false0);
}

void SpidersHatch(string &in asParentstring &in asChildint alState)
{
    if(
alState == 1AddTimer("hatch_time"5.0f"Hatching_Timer");
    if(
alState == -1RemoveTimer("hatch_time");
}

void Hatching_Timer(string &in asTimer)
{
    
SetEntityActive("Spiders?"true);


Worked as intended, I didn't realise you can do it in such way XD Anyways, thanks a lot man!
07-18-2015, 07:01 PM
Find




Users browsing this thread: 1 Guest(s)