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
Timer help
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#4
RE: Timer help

void OnStart()
{
    AddEntityCollideCallback("Player", "TheTime", "MonsterTimerBegin", true, 1); //TheTime is the script area you mention.
        SetLocalVarInt("MonTimLoopVal", 0);
}

void MonsterTimerBegin(string &in asParent, string &in asChild, int alState)
{  
        AddTimer("MonTimLoop", 1.0f, "MonsterTimerLoop"); //Begins the timer with the duration of 30 sec.
}

void MonsterTimerLoop(string &in asTimer)
{    
    AddLocalVarInt("MonTimLoopVal", 1); // adds 1 to var each time function is called
       if ((GetLocalVarInt("MonTimLoopVal") == 30) || (HasItem("KEYNAMEHERE"))) {
            SetEntityActive("MONSTERNAME", true);   //Change MONSTERNAME to whatever your monster's name is.
       }
       else {
         AddTimer("MonTimLoop", 1, "MonsterTimerLoop");
       }
}

In the MonsterTimerLoop function, the 'if' is checking whether...
A. 30 seconds have expired
OR
B. Player has the key in their inventory
THEN
Spawn the monster
and if neither 30 seconds has gone by nor the player has the key, add another timer with 1 second to call the same func
Next time the func is called, 1 gets added to the total var for time keeping, and so on and so forth

Word of warning, I just wrote this at work so I havent tested whether it works, let me know if you get any errors

(This post was last modified: 03-13-2013, 05:36 PM by Adrianis.)
03-13-2013, 05:35 PM
Find


Messages In This Thread
Timer help - by VisualTech48 - 03-13-2013, 02:28 PM
RE: Timer help - by PutraenusAlivius - 03-13-2013, 03:45 PM
RE: Timer help - by VisualTech48 - 03-13-2013, 05:21 PM
RE: Timer help - by Adrianis - 03-13-2013, 05:35 PM
RE: Timer help - by VisualTech48 - 03-13-2013, 06:15 PM



Users browsing this thread: 2 Guest(s)