Page 1 of 1

return value timeleft

Posted: Sun Jun 26, 2005 1:50 am
by ViPER
I want an event to occur 15 seconds before the end of my maps and not all of my maps have the same length.

Is there a way to watch timeleft? and if so how do i do that?

Posted: Sun Jun 26, 2005 2:28 am
by lizardkid
not sure what the cvar for teh time is, maybe g_time?

i'll assume so..

Code: Select all

if(g_time == g_timelimit - (g_time * -1))
{

//code

}
Ok this is all theoretical, what it does is test the time vs the timeleft, or the time, put into negative, minus the maxtime. That'll return a positive value that SHOULD be the timelft..

Hey cool, this Math ain't so hard.

Posted: Sun Jun 26, 2005 5:51 am
by jv_map
g_timelimit - (g_time * -1)

what's wrong with + ? :P

Anyway, a solid way to do it is the following:

Code: Select all

level waittill roundstart // should already have this line

level.start_time = level.time
Then at any moment you can get the time remaining by:

local.time_remaining = level.dmroundlimit * 60.0 - level.time + level.start_time

So if you want to have something happen at 15 secs before end best put it in a seperate thread:

Code: Select all

somethread:
  while(level.dmroundlimit * 60.0 - level.time + level.start_time > 15.0)
    waitframe

  // do what you have to do
end
This way it'll still work properly even if the user decides to change the roundlimit while playing (unless it is changed in the last 15 seconds).

Posted: Sun Jun 26, 2005 6:36 am
by ViPER
Great!! TX

Posted: Sun Jun 26, 2005 9:27 am
by ViPER
JV_map this is for roundbased? I tried a couple things but couldn't get it to work in teamdm :(

Posted: Sun Jun 26, 2005 10:13 am
by jv_map
Yeah it is for roundbased only... I'm not really sure when the timer starts for tdm maps :?

Posted: Mon Jun 27, 2005 6:59 am
by Rookie One.pl
My guess would be at spawn...