Raised This Month: $ Target: $400
 0% 

How to make a countdown in HUD [SOLVED]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mateo10
Veteran Member
Join Date: Jan 2006
Old 11-30-2006 , 12:25   How to make a countdown in HUD [SOLVED]
Reply With Quote #1

Hello, my title is very descriptive so I'll be short.

I need to know how to make a HUD message which counts from an hour
to 1 second

Last edited by mateo10; 12-01-2006 at 10:11.
mateo10 is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 11-30-2006 , 12:29   Re: How to make a countdown in HUD
Reply With Quote #2

umm... the hud msg generator in studio?
__________________
i stop around here and there.
Da_sk8rboy is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 12:33   Re: How to make a countdown in HUD
Reply With Quote #3

set_task(1.0,"count_down",1234567,"",0,"a",36 00)
public count_down()
{


}
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-30-2006 , 12:37   Re: How to make a countdown in HUD
Reply With Quote #4

oviously he's not asking how to make a hud message . He needs help making it count.

Code:
new Second_Counter;   set_task(1.0,"my_clock",0,"",0,"b");   public my_clock() { --SecondCounter;set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 12.0); show_hudmessage(id, "second left are %i",Second_COUnter);
The Specialist is offline
Send a message via AIM to The Specialist
mateo10
Veteran Member
Join Date: Jan 2006
Old 11-30-2006 , 12:53   Re: How to make a countdown in HUD
Reply With Quote #5

Does this work?
Code:
#include <amxmodx> #include <amxmisc> new g_Switch, g_Time new Hour, Minute, Second public plugin_init() {     register_plugin("Server Restart","1.2","MaTTe (mateo10)")         g_Switch = register_cvar("server_restart", "1")     g_Time = register_cvar("server_restarttime", "3600.0")         set_task(get_pcvar_float(g_Time), "restartServer")     set_task(3600.0, "HourCounter", 0, "", 0, "b")     set_task(60.0, "MinuteCounter", 0, "", 0, "b")     set_task(1.0, "SecondCounter", 0, "", 0, "b") } public CountDown() {     set_hudmessage(0, 0, 255, -1.0, 0.0, 0, 6.0, 1.0)     show_hudmessage(0, "Server Restart In %i:%i:%i", Hour, Minute, Second) } public restartServer(id) {     if(get_pcvar_num(g_Switch)==1)     {         server_cmd("exec server.cfg")         server_cmd("restart")         client_print(0, print_console, "Hourly server restart")     }else{         client_print(id, print_console, "The server restart plugin is disabled.")         return PLUGIN_HANDLED     }     return PLUGIN_CONTINUE } public HourCounter() {     --Hour     set_task(0.0, "CountDown") } public MinuteCounter() {     --Minute     set_task(0.0, "CountDown") } public SecondCounter() {     --Second     set_task(0.0, "CountDown") }
mateo10 is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 11-30-2006 , 18:16   Re: How to make a countdown in HUD
Reply With Quote #6

compile it & find out.
__________________
i stop around here and there.
Da_sk8rboy is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-30-2006 , 20:20   Re: How to make a countdown in HUD
Reply With Quote #7

There are some logic and general code flaws and you're a bit confused on what the task id is. I'd search around the forum for more info and also consult the funcwiki on the main page.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 11-30-2006 , 20:43   Re: How to make a countdown in HUD
Reply With Quote #8

I hope you're happy. You made my eyes bleed.

I would suggest searching the forums for other plugins that have a countdown and see how they did it.

By the way, while you don't need so many set_task calls, it is acceptable to use 0 as each of their task ids in this context. This context being that you're not manually ending the tasks later. However, I'd suggest using _ instead of 0 when the task id isn't meaningful, such as how you're using it. The _ is used when you want to accept the default value for an argument.
__________________
Brad is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 11-30-2006 , 21:01   Re: How to make a countdown in HUD
Reply With Quote #9

I wanted to try my hand at this, since I'm relatively new to writing programs. I spent a while figuring out how to do the counter nicely.

The code below should work fine, though the hudmessage is untested. (I tested it with server_print.) Anyway, I'd really appreciate some feedback on this. If you can do this better, or more efficiently, please show me how.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Restart Timer" #define VERSION "1.0" #define AUTHOR "stupok69" new itimer new clocktime[8] new start_time public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         start_time = register_cvar("restart_server_time", "0")     itimer = get_pcvar_num(start_time)         register_concmd("startcounter", "set_clock", ADMIN_SLAY, "-displays timer, restarts server when finished") } public set_clock(id, level, cid) {     if(!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED         set_task(1.0,"my_clock",0,"",0,"a", itimer)     set_task(0.1,"display_clock",0,"",0,"b")         return PLUGIN_CONTINUE }   public my_clock() {       output_hms(--itimer, clocktime, 7)         if(itimer == 0) server_cmd("restart") } public display_clock() {     set_hudmessage(255, 255, 255, 0.5, 0.3, 0, 6.0, 12.0)     show_hudmessage(0, "Server Restart In %s", clocktime) } output_hms(inputseconds, outputstring[], outputlen) {     if(!inputseconds) return 0         new hours, minutes, seconds, h, m, s         if(inputseconds > 3600)     {         for(h = inputseconds; h >= 3600; h -= 3600)         {                     }             hours = (inputseconds - h) / 3600     }     else     {         hours = 0     }         if(inputseconds > 60)     {         for(s = inputseconds; s >= 60; s -= 60)         {                     }                 seconds = s                 minutes = (inputseconds - s) / 60                 for(m = minutes; m >= 60; m -= 60)         {                     }                 minutes = m     }     else     {         minutes = 0         seconds = inputseconds - 1     }         format(outputstring, outputlen, "%i:%i:%i", hours, minutes, seconds)         return 1 }
stupok is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 11-30-2006 , 21:42   Re: How to make a countdown in HUD
Reply With Quote #10

http://forums.alliedmods.net/attachm...1&d=1160097414

I think this should answer your question a little, I made for a request some time ago.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 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 06:54.


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