Trivia

Platform:  mIRC
Published  Jul 19, 2007
Updated  Jul 09, 2008
~*~*~Mountaindew's Trivia~*~*~
~*~*~ReadMe~*~*~


*Open mIRC
*Go to remotes, alt+r, and paste the script
*Enter the owner and channel when it asks you
*Dialog will pop up on load
*Go to questions tab and add questions
*To open the dialog in the future, right click anywhere � Trivia OR type /trivia


�Trivia Commands�

*!trivia ~ Starts Trivia
*!strivia ~ Stops Trivia (all, op, or voice)
*!report <ques> ~ Reports Question
*!score ~ Returns your rank and score
*!score <nick> ~ Returns someone's rank and score
*!trivhelp ~ Returns Trivia commands
*!questions ~ Returns number of trivia questions
*!give <nick> <points> ~ Gives someone points (owner)
*!top10 ~ Returns top 10 scores


�Trivia Dialog�

*Settings

*Stop after N questions
*Privledge for !strivia command
*Start/Stop Trivia
*Set Owner
*Set Channel
*Add missed question response

*Reports

*View Reported Questions
*Fix Reported Questions
*Remove Reported Question
*Clear All Reported Questions
*View whats wrong w/ reported question

*Questions

*View all questions
*Add a question
*Remove a question
*Clear All Questions
*Edit question, hint1, hint2, and answer of a question
*Add a txt file full of questions in question|answer format or question|hint1|hint2|answer format

*Scores

*View all scores
*Add Score
*Remove Score
*Edit Someone's Score
*Clear all scores


When someone gets the answer, it will say the time, rank, score,
answer, streak, and person behind you/in front of you's rank and score

Ex:

<Terrance> You got it mountaindew! The answer was sais! You got it in 2.609 seconds! Your streak is 3 question!
<Terrance> You are ranked 2nd out of 3 with 501 points! You are behind thrall with 560 points!

OR

<Terrance> Wahoo thrall! The answer was seventy-two! You got it in 17.359 seconds! Your streak is 2 questions!
<Terrance> You are ranked 1st out of 3 with 561 points! mountaindew is trailing behind you with 501 points!

Also, the on text's interact with the dialog. So if you type !give mountaindew 20, and the points tab is up with mountaindew's score, it will edit the dialog! Same goes with the !trivia and !strivia, it will enable/disable the start/stop trivia buttons. :)

Here's some screens of the dialog:



Thanks for using my trivia script!

Let me know of any problems/comments/suggestions


�~� MountainDew �~� menu * {
Trivia:trivia
}
on *:load:{
write missed.txt Sorry guys, but you got it wrong!
write missed.txt Aww cmon guys!
write missed.txt You guys suck!
write missed.txt I can't believe you got it wrong!
write missed.txt You guys are miserable at this!
hadd -m trivia strivia ison
:start
var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
if (%x != $null) hadd -m trivia owner %x
else goto start
:chan
var %y = $input(What channel would you like trivia to be for?,qe,Trivia Channel)
if ($left(%y,1) == $chr(35)) hadd -m trivia chan %y
else goto chan
}
on *:unload:{
if ($isfile(reports.ini)) .remove -b reports.ini
if ($isfile(questions.ini)) .remove -b questions.ini
if ($isfile(scores.ini)) .remove -b scores.ini
if ($isfile(missed.txt)) .remove -b missed.txt
if ($hget(scores)) hfree $v1
if ($hget(reports)) hfree $v1
if ($hget(questions)) hfree $v1
unset %streak*
unset %wrong
if ($hget(trivia)) hfree $v1
.timertriv* off
}
on *:kick:#:{
if ($knick == $me && $chan == $hget(trivia,chan)) {
hadd -m trivia status off
hdel trivia answer
hdel trivia time
.timertriv* off
unset %streak*
unset %wrong
}
}
on *:start:{
if (!$hget(scores)) hmake scores
if (!$hget(reports)) hmake reports
if (!$hget(questions)) hmake questions
hload -i reports reports.ini
hload -i questions questions.ini
hload -i scores scores.ini
if (!$hget(trivia)) hmake trivia
hload -i trivia trivia.ini
if (!$hget(trivia,owner)) {
:start
var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
if (%x != $null) hadd -m trivia owner %x
else goto start
}
}
on *:join:#:{
if ($chan == $hget(trivia,chan) && $nick == $me) {
if ($dialog(trivia)) {
did -e trivia 9
did -b trivia 10
}
}
}
on *:part:#:{
if ($nick == $me && $chan == $hget(trivia,chan)) {
if ($dialog(trivia)) {
did -e trivia 9
did -b trivia 10,9
}
hadd -m trivia status off
hdel trivia answer
hdel trivia time
.timertriv* off
unset %streak*
unset %wrong
}
}
on *:exit:{
hsave -i trivia trivia.ini
hsave -i scores scores.ini
hsave -i reports reports.ini
hsave -i questions questions.ini
}
on *:connect: if ($dialog(trivia)) did -e trivia 9
on *:disconnect:{
hadd -m trivia status off
hdel trivia answer
hdel trivia time
.timertriv* off
unset %streak*
unset %wrong
if ($dialog(trivia)) did -b trivia 10,9
}
on *:text:*:#:{
if ($chan == $hget(trivia,chan)) {
if ($regex($1,/^[!@.](?:trivia|start|triv(?:on|start))$/Si)) {
if ($hget(trivia,status) != on) {
hadd -m trivia status on
.msg $chan $+(03Trivia has been started by04 $nick,03!)
.timertrivnew 1 2 new
if ($dialog(trivia)) {
did -b trivia 9
did -e trivia 10
}
}
else .msg $chan 03Trivia is already04 on03 $+ !
}
if ($regex($1,/^[!@.](?:strivia|stop|triv(?:off|stop))$/Si)) {
if ($hget(trivia,status) == on) {
if ($nick $hgeT(trivia,strivia) $chan) {
hadd -m trivia status off
hdel trivia answer
hdel trivia time
.timertriv* off
unset %streak*
.msg $chan 03Trivia has been stopped by04 $nick $+ 03!
if ($dialog(trivia)) {
did -b trivia 10
did -e trivia 9
}
}
else .msg $chan you dont have access to that command
}
else .msg $chan 03Trivia is already04 off3 $+ !
}
if ($strip($1-) == $hget(trivia,answer)) {
unset %wrong
var %time = $calc($calc($ticks - $hget(trivia,time)) / 1000)
var %a = %streak [ $+ [ $nick ] ]
unset %streak*
set %streak [ $+ [ $nick ] ] $calc(%a + 1)
hdel trivia answer
.timertriv* off
hinc -m scores $nick
.msg $chan $+(06,$gettok(Way to go|That's the way|Wahoo|You got it,$r(1,4),124),$chr(32),04,$nick,06!) The answer was04 $strip($1-) $+ 06! You got it in04 %time 06seconds! Your streak is4 %streak [ $+ [ $nick ] ] 6questions!
.msg $chan 06You are ranked4 $rank($nick) 06out of04 $hget(scores,0).item 06with04 $score($nick) 06points! $iif($hget(scores,0).item > 1,$iif(1st* !iswm $rank($nick),06You are behind04 $behind($nick) 06with04 $score($behind($nick)) 06points!,04 $+ $first 06is trailing behind you with04 $score($first) 06points!),You are the first one to score!)
if ($dialog(trivia) && $did(trivia,14).seltext == $nick) did -ra trivia 15 $hget(scores,$nick) Points
.timertrivrightnew 1 3 new
}
if ($regex($1,/^[!@.](?:top(ten|score(s)?|10)?|scores)$/Si)) top10
if ($1 == !score) {
if ($2) {
if (*has no rank yet !iswm $rank($2)) {
.msg $chan 04 $+ $2 03is ranked4 $rank($2) 03out of04 $hget(scores,0).item 03with4 $score($2) 03points!
}
else .msg $chan 4 $+ $2 3isn't currently ranked.
}
else {
if (*has no rank yet !iswm $rank($nick)) {
.msg $chan 04You03 are ranked04 $rank($nick) 03out of04 $hget(scores,0).item 03with04 $score($nick) 03points!
}
else .msg $chan 4You3 aren't currently ranked.
}
}
if ($1 == !report) {
if ($2 <= $hget(questions,0).item && $3) {
var %x = $hget(questions,$2)
var %y = 1
var %z = $hget(reports,1).item
while $hgeT(reports,%y).item {
if ($v1 > %z) var %z = $v1
inc %y
}
hadd -m reports $calc(%z + 1) $gettok(%x,1,1) $chr(1) $3-
.msg $chan 03Thanks04 $nick $+ 03 $+ $chr(44), 04 $hgeT(trivia,owner) 03will read your report shortly.
if ($dialog(trivia)) {
did -r trivia 51
var %x = 1
while $hget(reports,%x).item {
did -a trivia 51 $gettok($hget(reports,$v1),1,1)
inc %x
}
did -z trivia 51
}
}
else .msg $chan 12Syntax03: !report <04ques #03> <04problem03>
}
if ($1 == !questions) .msg $chan 03There are currently04 $hget(questions,0).item 03questions.
if ($1 == !give) {
if ($nick == $hget(trivia,owner)) {
if ($3 isnum) {
if (!$hget(scores,$2) && $dialog(trivia)) { did -a trivia 14 $2 | did -z trivia 14 }
hadd -m scores $2 $3
.msg $chan 04 $+ $2 03now has04 $score($2) 03points.
if ($dialog(trivia) && $did(trivia,14).seltext == $2) did -ra trivia 15 $3 Points
}
else .msg $chan 12Syntax: 03!give <4nick3> <4points3>
}
else .msg $chan 03I don't believe you're04 $hget(trivia,owner) $+ 03.
}
if ($regex($1,/^[!@.](?:triv(ia)?(?:help)|help)$/Si)) {
.notice $nick ~*~Trivia Commands~*~
.notice $nick !trivia ~ Starts trivia
.notice $nick !strivia ~ Stops trivia $iif($hget(trivia,strivia) != ison,if you are) $iif($hget(trivia,strivia) == isop,op'd) $iif($hget(trivia,strivia) == isvoice,voiced)
.notice $nick !score ~ Returns your rank and score
.notice $nick !score <nick> ~ Returns <nick>'s rank and score
.notice $nick !report <ques #> <problem> ~ report a question
.notice $nick !trivhelp ~ Returns trivia help (this)
.notice $nick !questions ~ Returns tumber of trivia questions
.notice $nick !top10 ~ Returns top 10 scores
if ($nick == $hget(trivia,owner)) .notice $nick !give <nick> <points> ~ Give someone points
}
}
}
alias -l new {
var %chan = $hget(trivia,chan)
var %total = $hget(questions,0).item
var %number = $hget(questions,$r(1,%total)).item
noop $regex($hget(questions,%number),/^(.+)(.+)(.+)(.+)$/i)
hdel trivia answer
hadd -m trivia answer $regml(4)
.msg %chan $+(11~04*11~03Question04 %number,06/04,$hget(questions,0).item,11~04*11~)
.msg %chan 12 $+ $regml(1)
hadd -m trivia time $ticks
.timertrivhint1 1 2 .msg %chan 03Hint: $regml(2)
.timertrivhint2 1 15 .msg %chan 03Hint: $regml(3)
.timertrivwrong 1 30 wrong
}
alias wrong {
inc %wrong
if (%wrong >= $hget(trivia,wrong)) {
hadd -m trivia status off
hdel trivia answer
hdel trivia time
.timertriv* off
unset %streak*
.msg $hget(trivia,chan) 04 %wrong 10questions have gone by unanswered! Trivia has been stopped by04 $me $+ 10!
unset %wrong
if ($dialog(trivia)) {
did -b trivia 10
did -e trivia 9
}
}
else {
.msg $hget(trivia,chan) 10 $+ $read(missed.txt) Get ready for the next question...
;if you want it to msg the answer, use the line below instead
;.msg $hget(trivia,chan) 10The answer was04 $hget(trivia,answer) $+ 10! Get ready for the next question...
unset %streak*
.timertrivnewfromwrong 1 2 new
}
}
alias -l top10 {
var %d = 1, %w = @top10
window -hn %w
clear %w
while $hget(scores,%d).item {
aline %w $v1 $hget(scores,$v1)
inc %d
}
filter -cteuww 2 32 %w %w
var %k = 1, %k1
while %k <= 10 {
if ( $line(%w,%k) ) {
tokenize 32 $v1
if (%k == 1) var %x = $addtok(%x,04 $+ $1 ~ $hget(scores,$1),44)
if (%k == 2) var %x = $addtok(%x,12 $+ $1 ~ $hget(scores,$1),44)
if (%k == 3) var %x = $addtok(%x,03 $+ $1 ~ $hget(scores,$1),44)
elseif (%k isnum 4-10) var %x = $addtok(%x,06 $+ $1 ~ $hget(scores,$1),44)
}
inc %k
}
.msg $hget(trivia,chan) $iif($line(%w,1),$replace(%x,$chr(44),$chr(44) $chr(32))%x,3There are no high scores.)
}
alias -l rank {
var %d = 1, %w = @top10, %n = $$1
window -hn %w
clear %w
while $hget(scores,%d).item {
aline %w $v1 $hget(scores,$v1)
inc %d
}
filter -cteuww 2 32 %w %w
return $iif($fline(%w,%n *,1),$ord($v1),$1 has no rank yet)
}
alias -l score {
var %d = 1, %w = @top10, %n = $$1
window -hn %w
clear %w
while $hget(scores,%d).item {
aline %w $v1 $hget(scores,$v1)
inc %d
}
filter -cteuww 2 32 %w %w
return $iif($fline(%w,%n *,1),$gettok($line(%w,$v1),2,32),$1 has no score yet)
}
alias -l behind {
if ($isid) {
var %d = 1, %w = @top5, %n = $$1
window -hn %w
clear %w
while $hget(scores,%d).item {
aline %w $v1 $hget(scores,$v1)
inc %d
}
filter -cteuww 2 32 %w %w
return $iif($gettok($line(%w,$calc($fline(%w,%n *,1) - 1)),1,32) != 3,$v1,first)
}
}
alias -l first {
if ($isid) {
var %d = 1, %w = @top5
window -hn %w
clear %w
while $hget(scores,%d).item {
aline %w $v1 $hget(scores,$v1)
inc %d
}
filter -cteuww 2 32 %w %w
return $iif($line(%w,1),$gettok($line(%w,2),1,32),error)
}
}
dialog trivia {
title "Trivia"
size -1 -1 136 203
option dbu
tab "Settings", 1, 2 -1 132 201
box "!Strivia Command", 5, 7 52 58 60, tab 1
radio "Op", 6, 16 62 22 10, tab 1
radio "Voice", 7, 16 77 25 10, tab 1
radio "All Users", 8, 16 92 34 10, tab 1
button "Start Trivia", 9, 26 30 37 12, disable tab 1
button "Stop Trivia", 10, 65 30 37 12, disable tab 1
box "Trivia Status", 12, 23 20 83 26, tab 1
text "Owner:", 43, 10 125 19 8, tab 1
edit "", 44, 32 124 74 10, tab 1 read autohs
button "Edit", 45, 109 125 15 8, tab 1
text "Channel:", 46, 10 139 23 8, tab 1
edit "", 47, 32 138 74 10, tab 1 read autohs
button "Edit", 48, 109 139 15 8, tab 1
box "", 49, 7 117 121 35, tab 1
box "Stop After N Wrong", 54, 70 52 58 60, tab 1
radio "5 Questions", 55, 76 60 50 10, tab 1
radio "10 Questions", 56, 76 71 50 10, tab 1
radio "15 Questions", 57, 76 81 50 10, tab 1
radio "20 Questions", 58, 76 91 50 10, tab 1
radio "Unlimited", 59, 76 101 50 10, tab 1
edit "", 60, 10 165 98 10, tab 1
box "Add Missed Question Response", 62, 7 157 121 21, tab 1
button "Add", 61, 109 165 15 8, disable tab 1
tab "Reports", 2
edit "", 50, 7 121 123 10, tab 2 read autohs
list 51, 6 23 123 84, tab 2 sort size hsbar
box "Reported Questions", 52, 4 15 127 94, tab 2
box "Functions", 66, 16 144 98 20, tab 2
button "Clear", 67, 50 152 30 10, disable tab 2
button "Remove", 68, 20 152 30 10, disable tab 2
button "Fix", 22, 80 152 30 10, disable tab 2
box "Problem", 53, 5 113 127 20, tab 2
tab "Questions", 3
list 23, 6 23 123 84, tab 3 sort size hsbar
button "Add *.txt", 24, 7 169 30 10, tab 3
button "Add", 25, 37 169 30 10, tab 3
button "Clear", 26, 97 169 30 10, disable tab 3
button "Remove", 27, 67 169 30 10, disable tab 3
box "Functions", 28, 5 161 124 20, tab 3
box "Questions", 29, 4 15 127 94, tab 3
edit "", 30, 30 136 82 10, tab 3 read autohs
text "Hint 1:", 33, 6 126 18 8, tab 3
edit "", 32, 30 147 82 10, tab 3 read autohs
edit "", 31, 30 125 82 10, tab 3 read autohs
text "Hint 2:", 35, 6 138 18 8, tab 3
text "Answer:", 34, 6 148 22 8, tab 3
box "", 36, 4 109 127 50, tab 3
button "Edit", 37, 113 137 15 8, disable tab 3
button "Edit", 39, 113 148 15 8, disable tab 3
button "Edit", 38, 113 126 15 8, disable tab 3
text "Question:", 40, 6 115 25 8, tab 3
edit "", 41, 30 114 82 10, tab 3 read autohs
button "Edit", 42, 113 115 15 8, disable tab 3
tab "Scores", 4
box "Scores", 13, 6 17 53 155, tab 4
list 14, 9 25 47 144, tab 4 sort size hsbar
edit "", 15, 66 136 59 10, tab 4 read autohs
box "Score", 16, 64 128 64 21, tab 4
button "Edit", 17, 75 78 37 12, disable tab 4
button "Add", 18, 75 38 37 12, tab 4
button "Remove", 19, 75 58 37 12, disable tab 4
button "Clear", 20, 75 98 37 12, disable tab 4
box "Functions", 21, 72 27 44 88, tab 4
button "OK", 11, 48 185 37 12, ok cancel
}
alias trivia {
if ($dialog(trivia)) dialog -x trivia trivia
dialog -m trivia trivia
}
on *:dialog:trivia:*:*:{
var %chan = $hgeT(trivia,chan)
if ($devent == init) {
if ($hget(trivia,wrong) == 5) did -c trivia 55
if ($hget(trivia,wrong) == 10) did -c trivia 56
if ($hget(trivia,wrong) == 15) did -c trivia 57
if ($hget(trivia,wrong) == 20) did -c trivia 58
if ($hget(trivia,wrong) !isnum) did -c trivia 59
if ($hget(reports,1).item) did -e trivia 67
did -a trivia 44 $hget(trivia,owner)
if ($hget(reports)) {
var %asdf = 1
while $hget(reports,%asdf).item {
did -a trivia 51 $gettok($hget(reports,$v1),1,1)
inc %asdf
}
did -z trivia 51
}
did -a trivia 47 $hget(trivia,chan)
if ($hget(questions,1).item) did -e trivia 26
var %s = 1
while $hgeT(questions,%s).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %s
}
did -z trivia 23
if ($hget(trivia,status) == on) did -e trivia 10
else did -e trivia 9
var %x = 1
while $hget(scores,%x).item {
did -a trivia 14 $v1
inc %x
}
did -z trivia 14
if ($hgeT(scores)) did -e trivia 20
if (!$server) did -b trivia 9,10
if ($hget(trivia,strivia) == isvoice) did -c trivia 7
if ($hgeT(trivia,strivia) == isop) did -c trivia 6
if ($hget(trivia,strivia) == ison || !$v1) {
did -c trivia 8
}
}
if ($devent == sclick) {
if ($did == 9) {
if ($hget(trivia,status) != on) {
hadd -m trivia status on
did -b trivia 9
did -e trivia 10
.msg %chan $+(03Trivia has been started by04 $me,03!)
.timertrivnew 1 2 new
}
}
if ($did == 10) {
if ($hget(trivia,status) == on) {
hadd -m trivia status off
hdel trivia answer
hdel trivia time
did -e trivia 9
did -b trivia 10
.timertriv* off
unset %streak*
.msg %chan 03Trivia has been stopped by04 $me $+ 03!
}
}
if ($did == 14 && $diD(trivia,14).seltext != $null) {
did -ra trivia 15 $hget(scores,$did(trivia,14).seltext) Points
did -e trivia 19,17
}
if ($did isnum 6-8) {
if ($did == 6) hadd -m trivia strivia isop
if ($did == 7) hadd -m trivia strivia isvoice
if ($did == 8) hadd -m trivia strivia ison
if ($hget(trivia,wrong) == 5) did -c trivia 55
if ($hget(trivia,wrong) == 10) did -c trivia 56
if ($hget(trivia,wrong) == 15) did -c trivia 57
if ($hget(trivia,wrong) == 20) did -c trivia 58
if ($hget(trivia,wrong) !isnum) did -c trivia 59
}
if ($did == 20) {
var %x = $input(Are you sure you would like to erase all scores?,cy,Clear All Scores)
if (%x == $true) {
hfree scores
did -r trivia 14,15
did -b trivia 20,17,19
.msg %chan 4All03 scores cleared.
}
}
if ($did == 19) {
var %x = $input(Are you sure you would like to erase $did(trivia,14).seltext $+ 's score?,cy,Clear $did(trivia,14).seltext $+ 's Score)
if (%x == $true) {
.msg %chan 04 $+ $did(trivia,14).seltext $+ 's 3score has been 04cleared03.
hdel scores $did(trivia,14).seltext
did -r trivia 15,14
did -b trivia 17,19,20
var %y = 1
while $hgeT(scores,%y).item {
did -a trivia 14 $v1
inc %y
}
did -z trivia 14
if ($hget(scores,1).item) did -e trivia 20
}
}
if ($did == 18) {
var %x = $input(Who would you like to add to the score list?,qe,Adding Score)
if (%x != $null) {
if ($numtok(%x,32) == 1) {
var %y = $input(What would you like %x $+ 's score to be?,qe,%x $+ 's Score)
if (%y isnum && %y) {
hadd -m scores %x %y
.msg %chan 04 $+ %x 03now has 04 $+ %y 03points!
did -r trivia 15,14
did -b trivia 17,19
did -e trivia 20
var %a = 1
while $hget(scores,%a).item {
did -a trivia 14 $v1
inc %a
}
did -z trivia 14
}
else var %test = $input(The score must be a number!,ho,Error!)
}
else var %sos = $input(The name must be one word!,ho,Error!)
}
else var %asdf = $input(You must enter a name!,ho,Error!)
}
if ($did == 17) {
var %x = $input(What would you like $did(trivia,14).seltext $+ 's new score to be?,qe,$did(trivia,14).seltext $+ 's Score,$hget(scores,$did(trivia,14).seltext))
if (%x isnum) {
hadd -m scores $did(trivia,14).seltext %x
.msg %chan 4 $+ $did(trivia,14).seltext 03now has04 %x 03points!
did -ra trivia 15 %x Points
}
else var %asdf = $input(The score must be a number!,ho,Error!)
}
if ($did == 24) dialog $iif($dialog(txt),-v,-m) txt txt
if ($did == 25) {
var %ques = $input(What question would you like to add?,qe,Question)
if (%ques != $null) {
var %hint1 = $input(What would you like the first hint to be?,qe,Hint 1)
if (%hint1 != $null) {
var %hint2 = $input(What would you like the second hint to be?,qe,Hint 2)
if (%hint2 != $null) {
var %ans = $input(What would you like the answer to be?,qe,Answer)
if (%ans != $null) {
did -r trivia 23,30,31,32,41
var %y = 1
var %z = $hget(questions,1).item
while $hget(questions,%y).item {
if ($v1 > %z) var %z = $v1
inc %y
}
hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
did -e trivia 26
var %b = 1
while $hget(questions,%b).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %b
}
did -z trivia 23
did -b trivia 27,37,38,39,42
}
}
}
}
}
if ($did == 26) {
var %x = $input(Are you sure you want to erase all questions?,cy,Remove All Questions)
if (%x == $true) {
did -r trivia 23,30,31,32,41
hfree questions
did -b trivia 26,27,37,38,39,42
}
}
if ($did == 23 && $did(trivia,23).seltext != $null) {
did -e trivia 27,37,38,39,42
var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
noop $regex($hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data),/^(.+)(.+)(.+)(.+)$/i)
did -ra trivia 31 $regml(2)
did -ra trivia 30 $regml(3)
did -ra trivia 32 $regml(4)
did -ra trivia 41 $regml(1)
}
if ($did == 27) {
var %x = $input(Are you sure you want to delete this question?,cy,Delete Question)
if (%x == $true) {
hdel questions %a $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
did -r trivia 23,30,31,32,41
var %y = 1
while $hget(questions,%y).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %y
}
did -b trivia 27,37,38,39,42
did -z trivia 23
}
}
if ($did == 38) {
var %x = $input(What would you like hint 1 to be?,qe,Hint 1,$did(trivia,31).text)
if (%x != $null) {
var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
var %a = $hget(questions,%y)
var %z = $replace(%a,$gettok(%a,2,1),%x)
hadd -m questions %y %z
did -ra trivia 31 %x
}
}
if ($did == 37) {
var %as = $input(What would you like Hint 2 to be?,qe,Hint 2,$did(trivia,30).text)
if (%as != $null) {
var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
var %a = $hget(questions,%y)
var %z = $replace(%a,$gettok(%a,3,1),%as)
hadd -m questions %y %z
did -ra trivia 30 %as
}
}
if ($did == 39) {
var %sa = $input(What would you like the answer to be?,qe,Answer,$did(trivia,32).text)
if (%sa != $null) {
var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
var %a = $hget(questions,%y)
var %z = $replace(%a,$gettok(%a,4,1),%sa)
hadd -m questions %y %z
did -ra trivia 32 %sa
}
}
if ($did == 42) {
var %sas = $input(What would you like to rename the question as?,qe,Question,$did(trivia,41).text)
if (%sas != $null) {
var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
var %a = $hget(questions,%y)
var %z = $replace(%a,$gettok(%a,1,1),%sas)
hadd -m questions %y %z
did -ra trivia 41 %sas
did -r trivia 23
var %lmn = 1
while $hget(questions,%lmn).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %lmn
}
did -c trivia 23 $didwm(trivia,23,%sas $+ *)
did -z trivia 23
}
}
if ($did == 45) {
var %x = $input(Who would you like to set as the owner?,qe,Owner,$hget(trivia,owner))
if (%x != $null) {
hadd -m trivia owner %x
did -ra trivia 44 %x
}
}
if ($did == 48) {
var %x = $input(What would you like to set as the trivia channel?,qe,Trivia Channel,$hget(trivia,chan))
if (%x != $null) {
if ($left(%x,1) == $chr(35)) {
hadd -m trivia chan %x
did -ra trivia 47 %x
}
else var %y = $input(The channel must begin with $chr(35),ho,Error!)
}
}
if ($did == 51 && $did(trivia,51).seltext != $null) {
did -ra trivia 50 $gettok($hget(reports,$hfind(reports,$did(trivia,51).seltext $+ *,1,w).data),2,1)
did -e trivia 68,22
}
if ($did == 22) {
did -c trivia 3
did -c trivia 23 $didwm(trivia,23,$did(trivia,51).seltext $+ *)
var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
did -ra trivia 31 $gettok(%x,2,1)
did -ra trivia 30 $gettok(%x,3,1)
did -ra trivia 32 $gettok(%x,4,1)
did -ra trivia 41 $gettok(%x,1,1)
did -e trivia 27,37,38,39,42
}
if ($did == 67) {
var %x = $input(Are you sure you would like to delete all reports?,cy,Erase All Reports)
if (%x == $true) {
did -r trivia 51,50
hfree reports
}
}
if ($did == 68) {
var %x = $input(Are you sure you would like to remove this report?,cy,Remove Report)
if (%x == $true) {
did -b trivia 22,67,68
hdel reports $hfind(reports,$did(trivia,51).seltext $+ *,1,w).data
var %x = 1
did -r trivia 51,50
while $hget(reports,%x).item {
did -a trivia 51 $gettok($hget(reports,$v1),1,1)
inc %x
}
did -z trivia 51
if ($hget(reports,1).data) did -e trivia 67
}
}
if ($did isnum 55-58) {
hadd -m trivia wrong $gettok($did(trivia,$did),1,32)
if ($hget(trivia,strivia) == ison) did -c trivia 8
if ($hget(trivia,strivia) == isvoice) did -c trivia 7
if ($hgeT(trivia,strivia) == isop) did -c trivia 6
}
if ($did == 59) {
hadd -m trivia wrong none
if ($hget(trivia,strivia) == ison) did -c trivia 8
if ($hget(trivia,strivia) == isvoice) did -c trivia 7
if ($hgeT(trivia,strivia) == isop) did -c trivia 6
}
if ($did == 61) {
write missed.txt $did(trivia,60).text
did -r trivia 60
did -b trivia 61
var %x = $input(Missed Question Response Added!,io,Response Added)
}
}
if ($devent == edit && $did == 60) {
if ($did(trivia,60).text != $null) did -e trivia 61
else did -b trivia 61
}
}
alias -l hash {
var %del = $$input(What delimeter seperates the question from the answer?,qe,Delimeter)
var %x = 1
unset %ques %ans
while $read($qt($$1-),%x) {
var %ques = $gettok($v1,1,%del)
var %ans = $gettok($v1,2,%del)
var %y = 1
unset %hint1 %hint2
while $gettok(%ans,%y,32) {
var %hint1 = $addtok(%hint1,$chr(32) $+ $replace($v1,a,_,b,_,c,_,d,_,e,_,f,_,g,_,h,_,i,_,j,_,k,_,l,_,m,_,n,_,o,_,p,_,q,_,r,_,s,_,t,_,u,_,v,_,w,_,x,_,y,_,z,_,1,_,2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,0,_),32)
var %hint2 = $addtok(%hint2,$chr(32) $+ $left($v1,1) $+ $replace($mid($v1,2),a,_,b,_,c,_,d,_,e,_,f,_,g,_,h,_,i,_,j,_,k,_,l,_,m,_,n,_,o,_,p,_,q,_,r,_,s,_,t,_,u,_,v,_,w,_,x,_,y,_,z,_,1,_,2,_,3,_,4,_,5,_,6,_,7,_,8,_,9,_,0,_),32)
inc %y
}
var %z = 1
while $hget(questions,%z).item {
inc %z
}
hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
inc %x
}
did -r trivia 23
var %b = 1
while $hget(questions,%b).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %b
}
did -z trivia 23
did -e trivia 26
did -b trivia 27,38,37,39,42
}

dialog -l txt {
title "Add *.txt"
size -1 -1 101 58
option dbu
button "...", 1, 84 6 11 10
edit "", 2, 7 6 74 10, autohs
radio "Question|Answer", 3, 7 30 53 10
radio "Question|Hint1|Hint2|Answer", 4, 7 20 84 10
button "OK", 5, 20 44 28 10, disable ok
button "Cancel", 6, 53 44 28 10, cancel
}

on *:dialog:txt:*:*:{
if ($devent == sclick) {
if ($did == 1) {
:a
var %x = $$sfile($mircdir $+ *.txt,Select a .txt file,Select)
if ($right(%x,4) != .txt) {
var %y = $input(Please select a .txt file!,ho,Error!)
goto a
}
else did -ra txt 2 %x
if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
did -e txt 5
}
else did -b txt 5
}
if ($did == 3 || $did == 4) {
if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
did -e txt 5
}
else did -b txt 5
}
if ($did == 5) {
if ($isfile($did(txt,2))) {
if ($did(txt,3).state == 1) {
hash $did(txt,2)
}
elseif ($did(txt,4).state == 1) {
addtxt $did(txt,2)
}
}
else var %x = $input($did(txt,2) isn't a file!,ho,Error!)
}
}
if ($devent == edit) {
if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
did -e txt 5
}
else did -b txt 5
}
}
alias -l addtxt {
var %as = $$input(What is the delimeter that seperates the hints $+ $chr(44) questions $+ $chr(44) and answers?,qe,Delimeter)
if (%as isnum) {
var %x = $qt($$1-)
did -r trivia 23,30,31,32,41
var %y = 1
var %z = $hget(questions,1).item
while $hget(questions,%y).item {
if ($v1 > %z) var %z = $v1
inc %y
}
var %a = 1
while $read(%x,%a) {
hadd -m questions $calc(%z + 1) $replace($v1,$chr(%as),$chr(1))
inc %z
inc %a
}
var %b = 1
while $hget(questions,%b).item {
did -a trivia 23 $gettok($hget(questions,$v1),1,1)
inc %b
}
did -z trivia 23
did -e trivia 26
did -b trivia 27,38,37,39,42
}
else var %sumthin = $input(The delimeter must be a number!,ho,Error!)
}

Comments

Sign in to comment.
promusic   -  Apr 29, 2013
can someone post a question list in the format Question|Hint1|Hint2|Answer ? That i can download. Couldnt find any on the internet.
 Respond  
duckz   -  Dec 28, 2012
IS this a bug or just my installation? "space and enter" is some sort of backdoor to trivia - it starts asking questions but its not actually started!
 Respond  
duckz   -  Dec 11, 2012
FIXED!
 Respond  
zelic   -  Jun 26, 2012
Test making your own .txt
just put in a few Question|Hint1|Hint2|Answer
Like:

What colour is my house?|B---|B-u-|Blue

then start trivia,
click "Questions"
"Add *.txt "
Find out parameter.
I use the " | " ,which is parameter : 124 .
Then go back to "Settings" and click "Start Trivia"

This should work.
Now you just need to find a nice quiz that is built the way you need. With the: Question|Hint1|Hint2|Answer
and do the same with that .txt

btw, if u open the qbig.txt - how does it look? Is it written that way?
 Respond  
darklord328   -  Jun 25, 2012
i have qbig.zip/rar. now i put it in my mIRC. Help out.
 Respond  
darklord328   -  Jun 25, 2012
won't work, try somethings else man. i do have the trivia answer/questions. and their in my question.txt.
 Respond  
zelic   -  Jun 24, 2012
Seems u have the wrong parameter if it doesnt reed questions properly.
Write:
//echo -a $asc(|)
to get correct parameter number for " | "
or whatever parameter u use.
Simply download a sheet full of questions where it already is Question|hint1|hint2|answer.
Sometimes its Question*hint1*hint2*answer, and then u need correct parameter for * .
//echo -a $asc(*) for finding correct parameter.
 Respond  
darklord328   -  Jun 24, 2012
http://i.imgur.com/DVdsL.png
http://i.imgur.com/KvhmO.png
http://i.imgur.com/GTezY.png
http://i.imgur.com/yK13I.png
<------------- 4 pictures all grayed out and i need someone to help me out with... Thank you!
 Respond  
darklord328   -  Jun 24, 2012
i'll be waiting.
 Respond  
darklord328   -  Jun 24, 2012
do i have to do the question in the notepad? cause everything is like grayed out, help out please, Thanks..
 Respond  
kersh   -  May 30, 2012
Anyone still around here? and can help, i imported a .txt question file and used * as the delimiter for the Question | Answer format and it's not taking it. the questions dont seem to parse correctly, and the question is blank when the bot asks them.. Can anyone help???
 Respond  
kggr001   -  May 17, 2012
@pope When i type !trivia it says you do not have the proper access to start
but iam the owner of the channel.
 Respond  
pope   -  May 17, 2012
@kggr001 I assume that you are attempting to initiate the script from the same bot that is running it, and that bot does not have ops on the channel that it is running on. I edited my original comment with an altered code that should work.

Reply if it doesn't. There are other ways, but I think this is the simplest given how the script was designed.
 Respond  
kggr001   -  May 17, 2012
@pope I tried what you sayed but it still doesnt work.
when i try to start trivia it doesnt start it.

This is what i did:

line 100 if ($hget(trivia,status) != on) {
line 101 if ($nick isreg $chan) or ($nick isvoice $chan) { msg $chan You do not have the proper access to start Trivia.
line 102 halt
line 103 }
line 104 hadd -m trivia status on
line 105 .msg $chan $+(03Dragonball Z Trivia has been started by04 $nick,03!)
line 106 .timertrivnew 1 2 new
line 107 if ($dialog(trivia)) {
line 108 did -b trivia 9
line 109 did -e trivia 10
 Respond  
pope   -  May 16, 2012
@kggr001: Don't use @2:, as all that tells the script to do is only run if you have ops on the channel.
Because of the broad way that *:on:text is used, just add this code BETWEEN line 100 and line 101:

OLD CODE:
Line 100: if ($hget(trivia,status) != on) {
Line 101: hadd -m trivia status on

NEW CODE:
Line 100: if ($hget(trivia,status) != on) {
Line 101: if ($nick isreg $chan) or ($nick isvoice $chan) && ($nick != $me) {
Line 102: msg $chan You do not have the proper access to start Trivia.
Line 103: halt
Line 104 }
Line 105: hadd -m trivia status on

There is probably a shorter way, but I haven't scripted in years so I'm a bit rusty. This should meet your needs, but reply if it doesn't.
 Respond  
kggr001   -  May 16, 2012
I did what you sayed but now the script doesnt work. xD
 Respond  
cofvempire   -  May 16, 2012
change every on *:start: ; on *:load: etc. to on @2:start: on @2:load: etc ...
 Respond  
kggr001   -  May 15, 2012
How do i change the script?
i want that only op can start trivia.
 Respond  
sc0tsman   -  Sep 14, 2011
Is this available for Wordpress?
 Respond  
Sachit Reddy   -  Sep 14, 2011
need help man can u add questions in the script by yourself
 Respond  
Taz0rized   -  Sep 05, 2011
i am commenting on this, as it looks like it would be a fun project for me to remake into DCX. very great script here very nice user friendly dialog, just wanna see what it would look like under dcx maybe mdx dunno, just feel like doing something challenging

overall Great Job
 Respond  
duckz   -  Sep 02, 2011
Been using this for quite some time now - it really is fun for our members.... However, I still have not been able to dissallow answers after the times up warning. How can I refuse to count answers that come in after the timer is up?
 Respond  
xbox_gamer1   -  Jun 24, 2011
@sethw

you may haft to remove the colors out of the code

 Respond  
SethW   -  Jun 22, 2011
@irchainscriptz, i tried that file and used * as the delimiter for the Question | Answer format and it's not taking it. the questions dont seem to parse correctly, and the question is blank when the bot asks them, here is the output:

[18:45] <@Ana> Trivia has been started by Seth!
[18:46] <@Ana> ~*~Question 27/39~*~
[18:46] <@Ana>
[18:46] <@Ana> Hint:
[18:46] <@Ana> Hint:
[18:45] <@Ana> ~*~Question 8/39~*~
[18:45] <@Ana>
[18:45] <@Ana> Hint:

any other clues?
 Respond  
irchainscriptz   -  May 05, 2011
SethW   -  May 03, 2011
anyone have links to some question files in the correct format? google wasnt helpful, closest i could get is the download on: http://www.imatowns.com/xelagot/xlgtopictrivia.html which is not very useful for mirc.
 Respond  
zelic   -  Mar 05, 2011
And is it possible to add a feature that let others to add questions by some command like:
!addquestion question|hint1hint2|answer
 Respond  
zelic   -  Mar 05, 2011
still have the problem with the same questions coming again and again.. anyway to stop that?
 Respond  
zelic   -  Mar 05, 2011
Fantastic, that was it! thanks alot.
now next question: can I find .txt documents already full with questions built up that way ?
Question|hint1|hint2|answer
 Respond  
Weldon   -  Mar 02, 2011
the reason why its doing
<TheBot> ~*~Question 29/57~*~
<TheBot>
<TheBot> Hint:
<TheBot> Hint:
i found out is because i had a blank line in the txt document, mine was at the bottom of it.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.