AlliedModders

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

ehha 10-08-2007 16:11

time left in a round
 
hello, i have searched for a function to get the time left in a round, in http://www.amxmodx.org/funcwiki.php, and didn't find it.

is there another place where can i find it or can someone tell me witch one is it?

thx

_Master_ 10-08-2007 16:58

Re: time left in a round
 
There isn't.
You have to code it yourself.

Wilson [29th ID] 10-09-2007 03:47

Re: time left in a round
 
get_cvar_num("amx_timeleft")

_Master_ 10-09-2007 05:35

Re: time left in a round
 
Wilson... ownd :)

ConnorMcLeod 10-09-2007 10:07

Re: time left in a round
 
3 Attachment(s)
Quote:

Originally Posted by Wilson [29th ID] (Post 540354)
get_cvar_num("amx_timeleft")

This will return the entire map timeleft.



I've made a plugin you can use.
Install the plugin, then you can use the native get_remaining_seconds() in all plugins you want.
You have to put the .inc file in scripting/includes/ folder in order to compile plugins using the native.
You also have to declare my plugin before other plugins that will use the native.

get_remaining_seconds() will return :

- negative values during freezetime
- remaining seconds before round end during a round
- remaining seconds before the bomb explose once bomb is planted
- 0 during round end or when a restart has been triggered

ehha 10-09-2007 12:17

Re: time left in a round
 
thank you very much!

so i`ll need to run you`re plugin for other plugins to use this native?

one more thing, where can i learn how to do this so i won`t ask somebody else how to code my own native?

alien 10-09-2007 20:30

Re: time left in a round
 
Code:
new Float:new_round_time; public plugin_init()   {     register_logevent("on_new_round", 2, "1=Round_Start");     return PLUGIN_CONTINUE;   } public on_new_round()   {     new_round_time = halflife_time();     return PLUGIN_CONTINUE;   } stock Float:round_time_left()   {     return get_cvar_float("mp_roundtime") - (halflife_time() - new_round_time);   }

This could help you if you want to spare some lines. You can also replace halflife_time by get_systime function to get less precise integer result. Round_time_left should return round time left in seconds.

ConnorMcLeod 10-10-2007 05:15

Re: time left in a round
 
I wish it would be so easy, but in fact you have to store mp_roundtime at newround event, because it can be change during the round by an admin or a plugin, so your way will give bad results.
You also have to deal with freezetime, so the round begins at roundstart event and not newround as you did.
Last thing is halflife_time need engine module.
get_systime return integer that make results less accurate.

Wilson [29th ID] 10-10-2007 05:19

Re: time left in a round
 
Oh! Timeleft in a round!

In my country, dayofdefeatia, we don't have rounds. I read right past it. :P

ConnorMcLeod 10-10-2007 05:27

Re: time left in a round
 
In that case, get_timeleft() should do it


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

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