mIRC Home    About    Download    Register    News    Help

Print Thread
#95291 23/08/04 04:21 PM
Joined: May 2004
Posts: 7
S
ssc Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: May 2004
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!

Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
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

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
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
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
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!
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
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
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
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!
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
It was too easy to be true :P


"All we are saying is give peace a chance" -- John Lennon
Joined: May 2004
Posts: 7
S
ssc Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: May 2004
Posts: 7
Thanks you guys!
I didnt know $ticks before :tongue:


Link Copied to Clipboard