Author Topic: Timing System  (Read 431 times)

Legacy_ConnHurr

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Timing System
« on: February 23, 2015, 08:13:44 pm »


               

Hi! 


 


I'm working on a project right now and my team is looking to create a timer based system for each "level" area. We're looking to have the first level take a maximum of 5 minutes for the player to complete and I was looking at scripting it this way:


 



Go to area properties and on entering the area set the current time to 0hours0minutes0seconds. On each heartbeat run a script that gets the current ingame hour and if this is greater then 5 then kill the player using the deathEffect. This is assuming that I set each minute to be one ingame hour in the module properties. 


 


However when I actually do this nothing happens. I was wondering if I am going about this wrong?


 


Thanks!



               
               

               
            

Legacy_Tchos

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +0/-0
Timing System
« Reply #1 on: February 23, 2015, 08:26:14 pm »


               

You can do it without dealing with date/time functions by using the fact that a heartbeat is 6 seconds long.  5 minutes is 300 seconds.  That amounts to 50 heartbeats.  On enter, set a local variable on the area to 0.  On each heartbeat, add 1 to this variable.  If the variable equals 50, kill the player.



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Timing System
« Reply #2 on: February 23, 2015, 11:04:02 pm »


               

Alternately you could use a DelayCommand that points to a function that handles the out of time stuff.


 


Pseudo code


 


<cut>


SetLocalInt(oPC, "TimedOut", 1); // 1 = true
DelayCommand(5.0f, YourScrewed(oPC));

<cut>


 


<cut>


// PC finishes in time
SetLocalInt(oPC, "TimedOut", 0); // 0 = false

<cut>

 


<cut>


// PC finishes out of time
void YourScrewed(object oPC)
{
    if(!(GetLocalInt(oPC, "TimedOut")))
        return;
// failure code from here on
 
}

<cut>


 


TR



               
               

               
            

Legacy_ConnHurr

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Timing System
« Reply #3 on: February 26, 2015, 11:20:06 pm »


               


You can do it without dealing with date/time functions by using the fact that a heartbeat is 6 seconds long.  5 minutes is 300 seconds.  That amounts to 50 heartbeats.  On enter, set a local variable on the area to 0.  On each heartbeat, add 1 to this variable.  If the variable equals 50, kill the player.




 


Thank you!! This worked excellently. 


               
               

               
            

Legacy_Tchos

  • Sr. Member
  • ****
  • Posts: 454
  • Karma: +0/-0
Timing System
« Reply #4 on: February 26, 2015, 11:45:36 pm »


               

You're welcome.