mIRC Home    About    Download    Register    News    Help

Topic Options
#95291 - 23/08/04 05:21 PM can anyone please help....
ssc Offline
Nutrimatic drinks dispenser

Registered: 26/05/04
Posts: 7
when you answered a trivia question, it will appear something like 'you got the correct answer in x.xxx seconds'
how to make the x.xxx seconds thing?

Thanks!

Top
#95292 - 23/08/04 05:41 PM Re: can anyone please help....
Sigh Offline
Fjord artisan

Registered: 28/08/03
Posts: 314
When the script messages a question it should store the value of $ticks somewhere, doesn't matter where. When an answer is received simply subtract this stored value from the current value of $ticks and you will have the approximate value for how long it took to answer in milliseconds allowing you to divide by 1000 and $round to whatever degree of accuracy you want to yield seconds

Top
#95293 - 23/08/04 10:08 PM Re: can anyone please help....
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
I'm just "translating" what Sigh said into code - I hope you don't mind smile
Code:
[color:green]; Insert this in the bot's code.
; Assuming that the question is asked in a channel...[/color]
set %q. [ $+ [ $chan ] ] $ticks
[color:green] ; The bot now asks the question. I won't put that on the code, though..[/color]

Once the person answered correctly..
Code:
[color:green] ; On TEXT event for getting the answer goes, then the following:[/color]
 var %ticks = $ticks, %oldticks = %q. [ $+ [ $chan ] ]
.msg $chan $nick got the correct answer in $calc((%ticks - %oldticks)/1000) seconds!
 unset %q. [ $+ [ $chan ] ]
[color:green] ; The rest of the code continues..[/color]

I have never actually seen a Trivia bot code, but I'm guessing that, if you add these it can work smile

Zyzzyx.
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#95294 - 23/08/04 10:25 PM Re: can anyone please help....
dr_Eamer Offline
Vogon poet

Registered: 22/08/04
Posts: 101
Loc: Athens, Greece
It seems you really got into using $ticks after fixing your ping/lag check eh? wink :tongue:

Anyway I was thinking of something else...
Usually trivia's have a timer that makes the question expire after some time. The timer is turned off if someone answers correctly before the time expires, so you can very easily calculate the time it took him with %expire_time - $timer(...).secs before you turn it off...

The problem is you only get .secs property so you can only calculate seconds which isn't good enough.

So here's a question:
Is there a property for milisecond timers (-m) to show the miliseconds remaining?
_________________________
Maybe I wake up one day to notice that all my life was just a dream!

Top
#95295 - 23/08/04 11:55 PM Re: can anyone please help....
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
lol :P I like using $ticks in variables names and such, but don't really sue 'em for anything else (so far smile)

I don't think there is the miliseconds property on $timer (at least it isnt shown on the help file) but I've tried something here and, as far as I know - I'm not very good at maths so please confirm it for me - that doing this might get the result in miliseconds.. am I right? ---> $calc($timer(name).secs / 1000)

Testing it here I got it to echo "miliseconds like" numbers, such as 0.045 and 0.014. Again, not sure if they are really miliseconds values or just my bad maths :P

Not mattering the result, the %expire_time - $timer is a good idea smile

Zyzzyx.
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#95296 - 24/08/04 12:02 AM Re: can anyone please help....
dr_Eamer Offline
Vogon poet

Registered: 22/08/04
Posts: 101
Loc: Athens, Greece
No I'm afraid it's not that simple...
2 seconds are 2000 miliseconds but the next value you'll get is 3 seconds (3000 miliseconds). So if someone does 2500 miliseconds to answer there's no way of knowing it, except of course if there's a hidden property...
_________________________
Maybe I wake up one day to notice that all my life was just a dream!

Top
#95297 - 24/08/04 12:07 AM Re: can anyone please help....
Zyzzyx26 Offline
Hoopy frood

Registered: 15/02/04
Posts: 714
Loc: Brasil
It was too easy to be true :P
_________________________
"All we are saying is give peace a chance" -- John Lennon

Top
#95298 - 24/08/04 03:35 AM Re: can anyone please help....
ssc Offline
Nutrimatic drinks dispenser

Registered: 26/05/04
Posts: 7
Thanks you guys!
I didnt know $ticks before :tongue:

Top