Raised This Month: $32 Target: $400
 8% 

time left in a round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 10-08-2007 , 16:11   time left in a round
Reply With Quote #1

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
ehha is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 10-08-2007 , 16:58   Re: time left in a round
Reply With Quote #2

There isn't.
You have to code it yourself.
_Master_ is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 10-09-2007 , 03:47   Re: time left in a round
Reply With Quote #3

get_cvar_num("amx_timeleft")
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
_Master_
Senior Member
Join Date: Dec 2006
Old 10-09-2007 , 05:35   Re: time left in a round
Reply With Quote #4

Wilson... ownd
_Master_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-09-2007 , 10:07   Re: time left in a round
Reply With Quote #5

Quote:
Originally Posted by Wilson [29th ID] View Post
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
Attached Files
File Type: inc secondsleft.inc (152 Bytes, 869 views)
File Type: sma Get Plugin or Get Source (get_seconds_left.sma - 2040 views - 2.0 KB)

Last edited by ConnorMcLeod; 10-09-2007 at 12:01.
ConnorMcLeod is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 10-09-2007 , 12:17   Re: time left in a round
Reply With Quote #6

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?

Last edited by ehha; 10-09-2007 at 12:20.
ehha is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 10-09-2007 , 20:30   Re: time left in a round
Reply With Quote #7

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.
__________________

Last edited by alien; 10-09-2007 at 20:33.
alien is offline
Send a message via ICQ to alien
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-10-2007 , 05:15   Re: time left in a round
Reply With Quote #8

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.
ConnorMcLeod is offline
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 10-10-2007 , 05:19   Re: time left in a round
Reply With Quote #9

Oh! Timeleft in a round!

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

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-10-2007 , 05:27   Re: time left in a round
Reply With Quote #10

In that case, get_timeleft() should do it
ConnorMcLeod is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:04.


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