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
VisualTech48 Offline
Junior Member

Posts: 21
Threads: 5
Joined: Apr 2012
Reputation: 0
#1
Timer help

Hi, I have ran into a problem where i have no clue how to script this.
Here is the overview of the situation

1.A player enters a room and colides with script area ["TheTime"]

2. The timer must be 30 sek
3. After 30 sek the monster comes in [Brakes the door, but with script and ps]

Case2# If the player findes the key early, the monster brakes the door immediately

And if he dies by the monster "Death" That the sequence happens again (So you dont commit suiced and then just chill walk trought the room)

If anyone could help me it whould be great, Ty Smile

- Order and Law! - The new Mod[WIP]
(This post was last modified: 03-15-2013, 08:06 PM by VisualTech48.)
03-13-2013, 02:28 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Timer help

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""TheTime""MonsterTimerBegin"true1); //TheTime is the script area you mention.
}

void MonsterTimerBegin(string &in asParentstring &in asChildint alState)
{   
        
AddTimer(""30.0f"MonsterTimer"); //Begins the timer with the duration of 30 sec.
}

void MonsterTimer(string &in asTimer)
{    
    
SetEntityActive("MONSTERNAME"true);   //Change MONSTERNAME to whatever your monster's name is.

I don't know how to script Case2, but i think it uses the if else statement.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-13-2013, 03:45 PM
Find
VisualTech48 Offline
Junior Member

Posts: 21
Threads: 5
Joined: Apr 2012
Reputation: 0
#3
RE: Timer help

(03-13-2013, 03:45 PM)JustAnotherPlayer Wrote:
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""TheTime""MonsterTimerBegin"true1); //TheTime is the script area you mention.
}

void MonsterTimerBegin(string &in asParentstring &in asChildint alState)
{   
        
AddTimer(""30.0f"MonsterTimer"); //Begins the timer with the duration of 30 sec.
}

void MonsterTimer(string &in asTimer)
{    
    
SetEntityActive("MONSTERNAME"true);   //Change MONSTERNAME to whatever your monster's name is.

I don't know how to script Case2, but i think it uses the if else statement.

Ty man, but still waiting if anyone cound help me make Case 2#

- Order and Law! - The new Mod[WIP]
03-13-2013, 05:21 PM
Find
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
VisualTech48 Offline
Junior Member

Posts: 21
Threads: 5
Joined: Apr 2012
Reputation: 0
#5
RE: Timer help

(03-13-2013, 05:35 PM)Adrianis Wrote:
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
Ty, gona try when i come back home, hope it works Big Grin Big Grin

- Order and Law! - The new Mod[WIP]
03-13-2013, 06:15 PM
Find




Users browsing this thread: 1 Guest(s)