mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
i made a simple trivia but i want it to be abit better
when someone gets a correct answer i set a var with
$ctime value and calculate how fast the users response was
with $duration($calc($ctime - %T.T)
%T.T = the time thw question started

and could u please help me with this and if u can make other things better that would be great thanks alot

smile

heres the code:


on *:TEXT:!Trivia:#: {
msg # Starting Trivia...
start.trivia
}
alias start.trivia {
var %chan = $1
tokenize 42 $read(Q.txt)
var %Q = $1
set %A $2
;Q = question A = Answer
msg %chan question: $1 $+ ?
set %T.T $ctime
.timerTRIVIA.timeout 1 60 chk.timeout %chan
}
alias chk.timeout {
msg $1 Trivia Time Up
msg $1 Answer %A
msg $1 Next Question
start.trivia $1
}
on *:TEXT:*:#: {
if ($timer(TRIVIA.timeout)) {
if ($1 == %A) {
timerTRIV* off
msg # $nick Got Answer %A in $duration($calc($ctime - %T.T))
msg # Next Question...
start.trivia #
}
}
}


i really need the time better cuz at the moment if you answer real fast you can get 0secs
and on other trivias its like 0.12 secs
so i want the really accurate times

thanks alot

smile

Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Instead of $ctime use $ticks, in both instances. Then the result of the subtraction will be in milliseconds, divide by 1000 with $calc to get it in seconds

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
I dont know if it was a typo or not, but you're missing $chan in the /start.trivia alias.

on *:TEXT:!Trivia:#: {
msg # Starting Trivia...
[color:blue]start.trivia
$chan
}
alias start.trivia {
var %chan = $1
[/color]

Zyzzyx smile

Edit: you could also make sure that a question doesn't get repeated until all the others have been made. I suggest a variable that contains $readn.

:read
var %ln = $read(Q.txt)
if ($istok(%read,$readn,44)) { goto read }
set %read $addtok(%read,$readn,44)
tokenize 42 %ln
var %Q = $1
set %A $2



Last edited by Zyzzyx26; 02/10/04 04:16 PM.

"All we are saying is give peace a chance" -- John Lennon
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
cool that you both smile
i got the checking to see if the question has been asked
but with $ticks ??
i really dont understand?

how do i make it say with a $duration like foramat
??

and 1 more question

i started making a stats part for it with an ini file and the stats dont seem to chage
is it possible to use /writini
to update the data
or would i have to use /remini and then /writeini to make
it work

thanks alot
smile

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
When the question is asked you set a variable with the value $ticks. Once the Q. is answered, you calculate the time in seconds. To do that use $calc(($ticks - %T.T)/1000)

Eg: %T.T = 12079492
$calc(($ticks - %T.T) / 1000) = 45.635 (seconds)


The whole point of using $ticks is not using $duration, since it gives you integer numbers, while $ticks gives you the time pretty accurately.

Hope this helps smile
Zyzzyx.

Edit: you can update an .ini file with /writeini. No need to remove it and then write it again.

Last edited by Zyzzyx26; 02/10/04 05:16 PM.

"All we are saying is give peace a chance" -- John Lennon
Joined: May 2004
Posts: 24
K
Ameglian cow
Offline
Ameglian cow
K
Joined: May 2004
Posts: 24
When you make a question, just set a variabile with $ticks value. (Eg. set %time $ticks)
Then, when someone answers, add a small calc ($calc($ticks - %time)) and you'll have elapsed time in ms.
If you want, divide the obtained value by 1000 to get time in secs (as Sigh previously said).

I hope u understand my huge english *gh*

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
cool thanks alot people
smile

i must of had a mistake somewhere in my writini cuz it wasnt working nvm

thanks alot

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
know how i can work out words per minute

thanks

smile


Link Copied to Clipboard