AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   finding time left in a round (https://forums.alliedmods.net/showthread.php?t=24740)

onfirenburnin420 03-01-2006 19:00

finding time left in a round
 
Im having trouble figureing this out. Please help me out. I need to find the time left on a round.
Code:
public RoundStart(id) {         new roundtime = get_cvar_num("mp_roundtime")     new time_left = ???????????????     if(time_left == 60.0) {         set_task(1.0,"check_map")     } }

Thanks in advance :D

Jordan 03-01-2006 20:22

Edit: Sry bout that

onfirenburnin420 03-01-2006 20:25

thats for the map time. i need round :shock:

Jordan 03-01-2006 20:26

Woops sry didn't see :P I'll look into it.

onfirenburnin420 03-01-2006 20:27

okay <3 :D

Kraugh 03-01-2006 22:00

Code:
new Float:round_started; public plugin_init() {    register_logevent("new_round",2,"1=Round_Start"); } public new_round() {    round_started = get_gametime(); } public Float:get_roundtimeleft() {    return (get_cvar_float("mp_roundtime") * 60.0) - (get_gametime() - round_started); }

this stores the game time when a new round starts. when you call the function, it determines how much time has gone by since then, and subtracts it from the maximum round time.

VEN 03-02-2006 04:29

mp_roundtime is in minutes
get_systime() is in seconds
Also i'm not sure but i think that roundtime not depend on systime but on get_gametime because server can lag etc.

Kraugh 03-02-2006 16:45

thanks. i have updated the code.

VEN 03-03-2006 06:04

You have to do get_cvar_float("mp_roundtime") in other case (0.X * 60) seconds of roundtime could be missed.
And CS mostly uses floor rounding method.

Kraugh 03-03-2006 15:16

alright then, fixed.


All times are GMT -4. The time now is 20:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.