return value timeleft

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

return value timeleft

Post 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?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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).
Image
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

Great!! TX
User avatar
ViPER
General
Posts: 1058
Joined: Fri Jan 14, 2005 5:48 pm
Location: California
Contact:

Post by ViPER »

JV_map this is for roundbased? I tried a couple things but couldn't get it to work in teamdm :(
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yeah it is for roundbased only... I'm not really sure when the timer starts for tdm maps :?
Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

My guess would be at spawn...
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply