[TF2] Get the value of timer ?
I'm trying to get the value of the timer in some maps, so when it reach 0:00 it should change map, even if objectives aren't done (Like all control point captured).
I already try to get it by using this but it seems that it always return the value defined by the cvar mp_roundtime and not the actual timer value. Just in case, I'm trying to speak about this timer : http://puu.sh/9OZsl/44a4ef6260.jpg |
Re: [TF2] Get the value of timer ?
|
Re: [TF2] Get the value of timer ?
I asked powerlord about this a while ago, and he had a solution, I think.
I ended up using a different method though, because I just needed the round time. |
Re: [TF2] Get the value of timer ?
Quote:
I did this : PHP Code:
@friagram No way to get your stock/way you did this ? Because I need the round time too. Or should I ask Powerlord ? |
Re: [TF2] Get the value of timer ?
In TF2, round timers are entities named team_round_timer (of class CTeamRoundTimer).
If you want to find the actual time, you need to loop through the timers and check for the timer that has the m_bShowInHUD netprop set to 1 (or true) and then check its m_flTimeRemaining netprop (which is a Float). Edit: It may be the non-Float m_nTimerLength instead. Having said that, when a team_round_timer hits 0 and the game isn't in overtime, it will fire its OnFinished output. Note that OnFinished does not fire when setup time ends. There's one caveat to this: Waiting For Players time and arena preround time are ALSO implemented as team_round_timers, meaning that you need to be careful that the correct timers are being used for this. Edit: Out of curiosity, why do you need this? TF2 usually ends the round when timers end... mp_maxrounds can be used to force mapchanges after certain number of rounds. |
Re: [TF2] Get the value of timer ?
@Powerlord
That's some good infos I got there, thanks ! And it was to fire some random events (bonus for actual loosing teams or what ever, and also change map when timer reach 0.00) a certain time. Anyway, according to what you say, setting mp_maxrounds to 0 will start next map when timer reach 0.00, right ? |
Re: [TF2] Get the value of timer ?
Quote:
Edit: Note that multi-round maps will only consider the round to be over if BLU wins all 3 rounds or RED wins any round. Except TC and PLR maps. |
Re: [TF2] Get the value of timer ?
Coming back to this after a week, the way to retrieve the current time left on a timer is (that isn't paused) is this:
Code:
GetEntPropFloat(timer, Prop_Send, "m_flTimerEndTime") - GetGameTime(); PHP Code:
Note 2: m_nState has a value of 0 in setup and 1 at any other time (including waiting for players). |
Re: [TF2] Get the value of timer ?
If I recall correctly one of the "time"-props is used to store the time "the full clock" has.
If you want to trigger stuff to happen when the timer runs out, you might be better off playing with inputs/outputs. |
Re: [TF2] Get the value of timer ?
Quote:
Incidentally, I wrote the above code because another project I'm working on now needs to stop doing something if there are less than 60 seconds on the clock, but since there isn't an output for when time is added to the clock... |
All times are GMT -4. The time now is 16:30. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.