Requesting a timer
Requesting a timer
I am looking for a script that allows to have a 2 minute timer, including milli seconds.
I need it to fit into another script, which is also possible to have results after its done.
Preferably this:
Collapsion in: – preferably this text above it
2:00.00 – preferably this many numbers
in BIGFONT, on y-scale 0.2, on the middle
If anybody has one, or the code, i would be really gratefull, i'm looking for this for a while now.
EDIT: the timer is only used once per time you play, so it doesnt need a restart or anything.
I need it to fit into another script, which is also possible to have results after its done.
Preferably this:
Collapsion in: – preferably this text above it
2:00.00 – preferably this many numbers
in BIGFONT, on y-scale 0.2, on the middle
If anybody has one, or the code, i would be really gratefull, i'm looking for this for a while now.
EDIT: the timer is only used once per time you play, so it doesnt need a restart or anything.
Last edited by Mr.Man on Sun Jan 26, 2014 7:46 am, edited 1 time in total.
RE: Requesting a timer
Not tested, written on machine without zan and ACC compiler. There may be errors.
Just follow some comments and you are okay. I assume you will add it to existing script so I didn't write #INCLUDE. You should do so.
Code: Select all
function void DrawMessage( int minutes, int seconds, int milliseconds )
{
SetFont("BigFont");
HudMessageBold( s: "Collapsion in:\n",
s: prefix( minutes, false ), d: minutes, s:":",
s: prefix( seconds, false ), d: seconds, s:".",
s: prefix( milliseconds, true), d: milliseconds;
HUDMSG_PLAIN,
1, //change ID if you need to
CR_yellow, //change colour if you need to
1.5, 0.2, 0);
}
function str prefix( int number, bool milli)
{
if ( milli ) // if milliseconds, then make it for 3 digits
{
if ( number <= 9 ) return "00";
if ( number <= 99 ) return "0";
} else if ( number <= 9 ) return "0"; // otherwise make it be 2 digits
return "";
}
script 1337 (void) //change 1337 to your number
{
int minutes, seconds, remtics, milliseconds;
for(int tics = 35 * 60 * 2; tics >= 0; tics --) // counter
{
minutes = ( tics / 35 ) / 60;
seconds = ( tics / 35 ) % 60;
remtics = tics % 35;
if ( !remtics ) milliseconds = 0; // DIVISION BY ZERO MUST BE AVOIDED AT ANY COSTS
else milliseconds = (100000 / ( 3500 / remtics ));
DrawMessage( minutes, seconds, milliseconds );
delay( 1 );
}
}
Last edited by Klofkac on Mon Jan 27, 2014 10:36 am, edited 1 time in total.
𝕂𝕝𝕠𝕗𝕜𝕒𝕔
- ibm5155
- Addicted to Zandronum
- Posts: 1641
- Joined: Tue Jun 05, 2012 9:32 pm
- Location: Somewhere, over the rainbow
RE: Requesting a timer
String function o.o i never knew this one :O
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
-
Watermelon
- Zandrone
- Posts: 1244
- Joined: Thu Jun 28, 2012 9:07 pm
- Location: Rwanda
RE: Requesting a timer
That's because strings are indices so you can make functions that return thanks to StrParamibm5155 wrote: String function o.o i never knew this one :O
Last edited by Watermelon on Mon Jan 27, 2014 1:05 pm, edited 1 time in total.
RE: Requesting a timer
That is awesome klofkac, but i have a change of mind (which is probably real dickerish)
I actually want it to support different amounts of time, because it seems allot more efficient, also for a mod i'm making.
EDIT: i might be able to do this myself do.
I just change script 1337 (void) to (int tics) and remove the tics info, dont i?
I actually want it to support different amounts of time, because it seems allot more efficient, also for a mod i'm making.
EDIT: i might be able to do this myself do.
I just change script 1337 (void) to (int tics) and remove the tics info, dont i?
Last edited by Mr.Man on Mon Jan 27, 2014 4:22 pm, edited 1 time in total.
-
Watermelon
- Zandrone
- Posts: 1244
- Joined: Thu Jun 28, 2012 9:07 pm
- Location: Rwanda
RE: Requesting a timer
It'd probably be better if you did
(int ticAmount)
then in the for loop, change
for (int tics = ...)
to
for (int tics = ticAmount; ...)
(int ticAmount)
then in the for loop, change
for (int tics = ...)
to
for (int tics = ticAmount; ...)
- Vincent(PDP)
- Forum Regular
- Posts: 527
- Joined: Thu Mar 14, 2013 7:35 pm
- Location: Sweden
- Clan: My DOOM site
- Clan Tag: <MDS>
- Contact:
RE: Requesting a timer
Already made you a timer Mr.Man .-.Mr.Man wrote: That is awesome klofkac, but i have a change of mind (which is probably real dickerish)
I actually want it to support different amounts of time, because it seems allot more efficient, also for a mod i'm making.
EDIT: i might be able to do this myself do.
I just change script 1337 (void) to (int tics) and remove the tics info, dont i?
Why can't you trust the scripts i create? :L
You can change the delay too.
RE: Requesting a timer
Probably because this thread is almost a month old and i made this before you gave it. Look at the date.
- ibm5155
- Addicted to Zandronum
- Posts: 1641
- Joined: Tue Jun 05, 2012 9:32 pm
- Location: Somewhere, over the rainbow
RE: Requesting a timer
so it's the same as a pointer xD, hmm, doesn't int do the same thing?Watermelon wrote:That's because strings are indices so you can make functions that return thanks to StrParamibm5155 wrote: String function o.o i never knew this one :O
like int i="test";
print(s:i,s:" ",d:i);
it would show the string and the pointer right?
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">