Aller au contenu

Photo

Timing System


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
ConnHurr

ConnHurr
  • Members
  • 4 messages

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!



#2
Tchos

Tchos
  • Members
  • 5 081 messages

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.



#3
Tarot Redhand

Tarot Redhand
  • Members
  • 2 688 messages

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



#4
ConnHurr

ConnHurr
  • Members
  • 4 messages

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. 



#5
Tchos

Tchos
  • Members
  • 5 081 messages

You're welcome.