Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 12th, 2010 | Syntax: None | Size: 28.72 KB | Hits: 47 | Expires: Never
Copy text to clipboard
  1. menu * {
  2.   Trivia:trivia
  3. }
  4. on *:load:{
  5.   write missed.txt Sorry guys, but you got it wrong!
  6.   write missed.txt Aww cmon guys!
  7.   write missed.txt You guys suck!
  8.   write missed.txt I can't believe you got it wrong!
  9.   write missed.txt You guys are miserable at this!
  10.   hadd -m trivia strivia ison
  11.   :start
  12.   var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
  13.   if (%x != $null) hadd -m trivia owner %x
  14.   else goto start
  15.   :chan
  16.   var %y = $input(What channel would you like trivia to be for?,qe,Trivia Channel)
  17.   if ($left(%y,1) == $chr(35)) hadd -m trivia chan %y
  18.   else goto chan
  19. }
  20. on *:unload:{
  21.   if ($isfile(reports.ini)) .remove -b reports.ini
  22.   if ($isfile(questions.ini)) .remove -b questions.ini
  23.   if ($isfile(scores.ini)) .remove -b scores.ini
  24.   if ($isfile(missed.txt)) .remove -b missed.txt
  25.   if ($hget(scores)) hfree $v1
  26.   if ($hget(reports)) hfree $v1
  27.   if ($hget(questions)) hfree $v1
  28.   unset %streak*
  29.   unset %wrong
  30.   if ($hget(trivia)) hfree $v1
  31.   .timertriv* off
  32. }
  33. on *:kick:#:{
  34.   if ($knick == $me && $chan == $hget(trivia,chan)) {
  35.     hadd -m trivia status off
  36.     hdel trivia answer
  37.     hdel trivia time
  38.     .timertriv* off
  39.     unset %streak*
  40.     unset %wrong
  41.   }
  42. }
  43. on *:start:{
  44.   if (!$hget(scores)) hmake scores
  45.   if (!$hget(reports)) hmake reports
  46.   if (!$hget(questions)) hmake questions
  47.   hload -i reports reports.ini
  48.   hload -i questions questions.ini
  49.   hload -i scores scores.ini
  50.   if (!$hget(trivia)) hmake trivia
  51.   hload -i trivia trivia.ini
  52.   if (!$hget(trivia,owner)) {
  53.     :start
  54.     var %x = $input(Who would you like to set as your owner?,qe,Bot Owner)
  55.     if (%x != $null) hadd -m trivia owner %x
  56.     else goto start
  57.   }
  58. }
  59. on *:join:#:{
  60.   if ($chan == $hget(trivia,chan) && $nick == $me) {
  61.     if ($dialog(trivia)) {
  62.       did -e trivia 9
  63.       did -b trivia 10
  64.     }
  65.   }
  66. }
  67. on *:part:#:{
  68.   if ($nick == $me && $chan == $hget(trivia,chan)) {
  69.     if ($dialog(trivia)) {
  70.       did -e trivia 9
  71.       did -b trivia 10,9
  72.     }
  73.     hadd -m trivia status off
  74.     hdel trivia answer
  75.     hdel trivia time
  76.     .timertriv* off
  77.     unset %streak*
  78.     unset %wrong
  79.   }
  80. }
  81. on *:exit:{
  82.   hsave -i trivia trivia.ini
  83.   hsave -i scores scores.ini
  84.   hsave -i reports reports.ini
  85.   hsave -i questions questions.ini
  86. }
  87. on *:connect: if ($dialog(trivia)) did -e trivia 9
  88. on *:disconnect:{
  89.   hadd -m trivia status off
  90.   hdel trivia answer
  91.   hdel trivia time
  92.   .timertriv* off
  93.   unset %streak*
  94.   unset %wrong
  95.   if ($dialog(trivia)) did -b trivia 10,9
  96. }
  97. on *:text:*:#:{
  98.   if ($chan == $hget(trivia,chan)) {
  99.     if ($regex($1,/^[!@.](?:trivia|start|triv(?:on|start))$/Si)) {
  100.       if ($hget(trivia,status) != on) {
  101.         hadd -m trivia status on
  102.         .msg $chan $+(03Trivia has been started by04 $nick,03!)
  103.         .timertrivnew 1 2 new
  104.         if ($dialog(trivia)) {
  105.           did -b trivia 9
  106.           did -e trivia 10
  107.         }
  108.       }
  109.       else .msg $chan 03Trivia is already04 on03 $+ !
  110.     }
  111.     if ($regex($1,/^[!@.](?:strivia|stop|triv(?:off|stop))$/Si)) {
  112.       if ($hget(trivia,status) == on) {
  113.         if ($nick $hgeT(trivia,strivia) $chan) {
  114.           hadd -m trivia status off
  115.           hdel trivia answer
  116.           hdel trivia time
  117.           .timertriv* off
  118.           unset %streak*
  119.           .msg $chan 03Trivia has been stopped by04 $nick $+ 03!
  120.           if ($dialog(trivia)) {
  121.             did -b trivia 10
  122.             did -e trivia 9
  123.           }
  124.         }
  125.         else .msg $chan you dont have access to that command
  126.       }
  127.       else .msg $chan 03Trivia is already04 off3 $+ !
  128.     }
  129.     if ($strip($1-) == $hget(trivia,answer)) {
  130.       unset %wrong
  131.       var %time = $calc($calc($ticks - $hget(trivia,time)) / 1000)
  132.       var %a = %streak [ $+ [ $nick ] ]
  133.       unset %streak*
  134.       set %streak [ $+ [ $nick ] ] $calc(%a + 1)
  135.       hdel trivia answer
  136.       .timertriv* off
  137.       hinc -m scores $nick
  138.       .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!
  139.       .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!)
  140.       if ($dialog(trivia) && $did(trivia,14).seltext == $nick) did -ra trivia 15 $hget(scores,$nick) Points
  141.       .timertrivrightnew 1 3 new
  142.     }
  143.     if ($regex($1,/^[!@.](?:top(ten|score(s)?|10)?|scores)$/Si)) top10
  144.     if ($1 == !score) {
  145.       if ($2) {
  146.         if (*has no rank yet !iswm $rank($2)) {
  147.           .msg $chan 04 $+ $2 03is ranked4 $rank($2) 03out of04 $hget(scores,0).item 03with4 $score($2) 03points!
  148.         }
  149.         else .msg $chan 4 $+ $2 3isn't currently ranked.
  150.       }
  151.       else {
  152.         if (*has no rank yet !iswm $rank($nick)) {
  153.           .msg $chan 04You03 are ranked04 $rank($nick) 03out of04 $hget(scores,0).item 03with04 $score($nick) 03points!
  154.         }
  155.         else .msg $chan 4You3 aren't currently ranked.
  156.       }
  157.     }
  158.     if ($1 == !report) {
  159.       if ($2 <= $hget(questions,0).item && $3) {
  160.         var %x = $hget(questions,$2)
  161.         var %y = 1
  162.         var %z = $hget(reports,1).item
  163.         while $hgeT(reports,%y).item {
  164.           if ($v1 > %z) var %z = $v1
  165.           inc %y
  166.         }
  167.         hadd -m reports $calc(%z + 1) $gettok(%x,1,1) $chr(1) $3-
  168.         .msg $chan 03Thanks04 $nick $+ 03 $+ $chr(44), 04 $hgeT(trivia,owner) 03will read your report shortly.
  169.         if ($dialog(trivia)) {
  170.           did -r trivia 51
  171.           var %x = 1
  172.           while $hget(reports,%x).item {
  173.             did -a trivia 51 $gettok($hget(reports,$v1),1,1)
  174.             inc %x
  175.           }
  176.           did -z trivia 51
  177.         }
  178.       }
  179.       else .msg $chan 12Syntax03: !report <04ques #03> <04problem03>
  180.     }
  181.     if ($1 == !questions) .msg $chan 03There are currently04 $hget(questions,0).item 03questions.
  182.     if ($1 == !give) {
  183.       if ($nick == $hget(trivia,owner)) {
  184.         if ($3 isnum) {
  185.           if (!$hget(scores,$2) && $dialog(trivia)) { did -a trivia 14 $2 | did -z trivia 14 }
  186.           hadd -m scores $2 $3
  187.           .msg $chan 04 $+ $2 03now has04 $score($2) 03points.
  188.           if ($dialog(trivia) && $did(trivia,14).seltext == $2) did -ra trivia 15 $3 Points
  189.         }
  190.         else .msg $chan 12Syntax: 03!give <4nick3> <4points3>
  191.       }
  192.       else .msg $chan 03I don't believe you're04 $hget(trivia,owner) $+ 03.
  193.     }
  194.     if ($regex($1,/^[!@.](?:triv(ia)?(?:help)|help)$/Si)) {
  195.       .notice $nick ~*~Trivia Commands~*~
  196.       .notice $nick !trivia ~ Starts trivia
  197.       .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)
  198.       .notice $nick !score ~ Returns your rank and score
  199.       .notice $nick !score <nick> ~ Returns <nick>'s rank and score
  200.       .notice $nick !report <ques #> <problem> ~ report a question
  201.       .notice $nick !trivhelp ~ Returns trivia help (this)
  202.       .notice $nick !questions ~ Returns tumber of trivia questions
  203.       .notice $nick !top10 ~ Returns top 10 scores
  204.       if ($nick == $hget(trivia,owner)) .notice $nick !give <nick> <points> ~ Give someone points
  205.     }
  206.   }
  207. }
  208. alias -l new {
  209.   var %chan = $hget(trivia,chan)
  210.   var %total = $hget(questions,0).item
  211.   var %number = $hget(questions,$r(1,%total)).item
  212.   noop $regex($hget(questions,%number),/^(.+)(.+)(.+)(.+)$/i)
  213.   hdel trivia answer
  214.   hadd -m trivia answer $regml(4)
  215.   .msg %chan $+(11~04*11~03Question04 %number,06/04,$hget(questions,0).item,11~04*11~)
  216.   .msg %chan 12 $+ $regml(1)
  217.   hadd -m trivia time $ticks
  218.   .timertrivhint1 1 2 .msg %chan 03Hint: $regml(2)
  219.   .timertrivhint2 1 15 .msg %chan 03Hint: $regml(3)
  220.   .timertrivwrong 1 30 wrong
  221. }
  222. alias wrong {
  223.   inc %wrong
  224.   if (%wrong >= $hget(trivia,wrong)) {
  225.     hadd -m trivia status off
  226.     hdel trivia answer
  227.     hdel trivia time
  228.     .timertriv* off
  229.     unset %streak*
  230.     .msg $hget(trivia,chan) 04 %wrong 10questions have gone by unanswered! Trivia has been stopped by04 $me $+ 10!
  231.     unset %wrong
  232.     if ($dialog(trivia)) {
  233.       did -b trivia 10
  234.       did -e trivia 9
  235.     }
  236.   }
  237.   else {
  238.     .msg $hget(trivia,chan) 10 $+ $read(missed.txt) Get ready for the next question...
  239.     ;if you want it to msg the answer, use the line below instead
  240.     ;.msg $hget(trivia,chan) 10The answer was04 $hget(trivia,answer) $+ 10! Get ready for the next question...
  241.     unset %streak*
  242.     .timertrivnewfromwrong 1 2 new
  243.   }
  244. }
  245. alias -l top10 {
  246.   var %d = 1, %w = @top10
  247.   window -hn %w
  248.   clear %w
  249.   while $hget(scores,%d).item {
  250.     aline %w $v1 $hget(scores,$v1)
  251.     inc %d
  252.   }
  253.   filter -cteuww 2 32 %w %w
  254.   var %k = 1, %k1
  255.   while %k <= 10  {
  256.     if ( $line(%w,%k) ) {
  257.       tokenize 32 $v1
  258.       if (%k == 1) var %x = $addtok(%x,04 $+ $1 ~ $hget(scores,$1),44)
  259.       if (%k == 2) var %x = $addtok(%x,12 $+ $1 ~ $hget(scores,$1),44)
  260.       if (%k == 3) var %x = $addtok(%x,03 $+ $1 ~ $hget(scores,$1),44)
  261.       elseif (%k isnum 4-10) var %x = $addtok(%x,06 $+ $1 ~ $hget(scores,$1),44)
  262.     }
  263.     inc %k
  264.   }
  265.   .msg $hget(trivia,chan) $iif($line(%w,1),$replace(%x,$chr(44),$chr(44) $chr(32))%x,3There are no high scores.)
  266. }
  267. alias -l rank {
  268.   var %d = 1, %w = @top10, %n = $$1
  269.   window -hn %w
  270.   clear %w
  271.   while $hget(scores,%d).item {
  272.     aline %w $v1 $hget(scores,$v1)
  273.     inc %d
  274.   }
  275.   filter -cteuww 2 32 %w %w
  276.   return $iif($fline(%w,%n *,1),$ord($v1),$1 has no rank yet)
  277. }
  278. alias -l score {
  279.   var %d = 1, %w = @top10, %n = $$1
  280.   window -hn %w
  281.   clear %w
  282.   while $hget(scores,%d).item {
  283.     aline %w $v1 $hget(scores,$v1)
  284.     inc %d
  285.   }
  286.   filter -cteuww 2 32 %w %w
  287.   return $iif($fline(%w,%n *,1),$gettok($line(%w,$v1),2,32),$1 has no score yet)
  288. }
  289. alias -l behind {
  290.   if ($isid) {
  291.     var %d = 1, %w = @top5, %n = $$1
  292.     window -hn %w
  293.     clear %w
  294.     while $hget(scores,%d).item {
  295.       aline %w $v1 $hget(scores,$v1)
  296.       inc %d
  297.     }
  298.     filter -cteuww 2 32 %w %w
  299.     return $iif($gettok($line(%w,$calc($fline(%w,%n *,1) - 1)),1,32) != 3,$v1,first)
  300.   }
  301. }
  302. alias -l first {
  303.   if ($isid) {
  304.     var %d = 1, %w = @top5
  305.     window -hn %w
  306.     clear %w
  307.     while $hget(scores,%d).item {
  308.       aline %w $v1 $hget(scores,$v1)
  309.       inc %d
  310.     }
  311.     filter -cteuww 2 32 %w %w
  312.     return $iif($line(%w,1),$gettok($line(%w,2),1,32),error)
  313.   }
  314. }
  315. dialog trivia {
  316.   title "Trivia"
  317.   size -1 -1 136 203
  318.   option dbu
  319.   tab "Settings", 1, 2 -1 132 201
  320.   box "!Strivia Command", 5, 7 52 58 60, tab 1
  321.   radio "Op", 6, 16 62 22 10, tab 1
  322.   radio "Voice", 7, 16 77 25 10, tab 1
  323.   radio "All Users", 8, 16 92 34 10, tab 1
  324.   button "Start Trivia", 9, 26 30 37 12, disable tab 1
  325.   button "Stop Trivia", 10, 65 30 37 12, disable tab 1
  326.   box "Trivia Status", 12, 23 20 83 26, tab 1
  327.   text "Owner:", 43, 10 125 19 8, tab 1
  328.   edit "", 44, 32 124 74 10, tab 1 read autohs
  329.   button "Edit", 45, 109 125 15 8, tab 1
  330.   text "Channel:", 46, 10 139 23 8, tab 1
  331.   edit "", 47, 32 138 74 10, tab 1 read autohs
  332.   button "Edit", 48, 109 139 15 8, tab 1
  333.   box "", 49, 7 117 121 35, tab 1
  334.   box "Stop After N Wrong", 54, 70 52 58 60, tab 1
  335.   radio "5 Questions", 55, 76 60 50 10, tab 1
  336.   radio "10 Questions", 56, 76 71 50 10, tab 1
  337.   radio "15 Questions", 57, 76 81 50 10, tab 1
  338.   radio "20 Questions", 58, 76 91 50 10, tab 1
  339.   radio "Unlimited", 59, 76 101 50 10, tab 1
  340.   edit "", 60, 10 165 98 10, tab 1
  341.   box "Add Missed Question Response", 62, 7 157 121 21, tab 1
  342.   button "Add", 61, 109 165 15 8, disable tab 1
  343.   tab "Reports", 2
  344.   edit "", 50, 7 121 123 10, tab 2 read autohs
  345.   list 51, 6 23 123 84, tab 2 sort size hsbar
  346.   box "Reported Questions", 52, 4 15 127 94, tab 2
  347.   box "Functions", 66, 16 144 98 20, tab 2
  348.   button "Clear", 67, 50 152 30 10, disable tab 2
  349.   button "Remove", 68, 20 152 30 10, disable tab 2
  350.   button "Fix", 22, 80 152 30 10, disable tab 2
  351.   box "Problem", 53, 5 113 127 20, tab 2
  352.   tab "Questions", 3
  353.   list 23, 6 23 123 84, tab 3 sort size hsbar
  354.   button "Add *.txt", 24, 7 169 30 10, tab 3
  355.   button "Add", 25, 37 169 30 10, tab 3
  356.   button "Clear", 26, 97 169 30 10, disable tab 3
  357.   button "Remove", 27, 67 169 30 10, disable tab 3
  358.   box "Functions", 28, 5 161 124 20, tab 3
  359.   box "Questions", 29, 4 15 127 94, tab 3
  360.   edit "", 30, 30 136 82 10, tab 3 read autohs
  361.   text "Hint 1:", 33, 6 126 18 8, tab 3
  362.   edit "", 32, 30 147 82 10, tab 3 read autohs
  363.   edit "", 31, 30 125 82 10, tab 3 read autohs
  364.   text "Hint 2:", 35, 6 138 18 8, tab 3
  365.   text "Answer:", 34, 6 148 22 8, tab 3
  366.   box "", 36, 4 109 127 50, tab 3
  367.   button "Edit", 37, 113 137 15 8, disable tab 3
  368.   button "Edit", 39, 113 148 15 8, disable tab 3
  369.   button "Edit", 38, 113 126 15 8, disable tab 3
  370.   text "Question:", 40, 6 115 25 8, tab 3
  371.   edit "", 41, 30 114 82 10, tab 3 read autohs
  372.   button "Edit", 42, 113 115 15 8, disable tab 3
  373.   tab "Scores", 4
  374.   box "Scores", 13, 6 17 53 155, tab 4
  375.   list 14, 9 25 47 144, tab 4 sort size hsbar
  376.   edit "", 15, 66 136 59 10, tab 4 read autohs
  377.   box "Score", 16, 64 128 64 21, tab 4
  378.   button "Edit", 17, 75 78 37 12, disable tab 4
  379.   button "Add", 18, 75 38 37 12, tab 4
  380.   button "Remove", 19, 75 58 37 12, disable tab 4
  381.   button "Clear", 20, 75 98 37 12, disable tab 4
  382.   box "Functions", 21, 72 27 44 88, tab 4
  383.   button "OK", 11, 48 185 37 12, ok cancel
  384. }
  385. alias trivia {
  386.   if ($dialog(trivia)) dialog -x trivia trivia
  387.   dialog -m trivia trivia
  388. }
  389. on *:dialog:trivia:*:*:{
  390.   var %chan = $hgeT(trivia,chan)
  391.   if ($devent == init) {
  392.     if ($hget(trivia,wrong) == 5) did -c trivia 55
  393.     if ($hget(trivia,wrong) == 10) did -c trivia 56
  394.     if ($hget(trivia,wrong) == 15) did -c trivia 57
  395.     if ($hget(trivia,wrong) == 20) did -c trivia 58
  396.     if ($hget(trivia,wrong) !isnum) did -c trivia 59
  397.     if ($hget(reports,1).item) did -e trivia 67
  398.     did -a trivia 44 $hget(trivia,owner)
  399.     if ($hget(reports)) {
  400.       var %asdf = 1
  401.       while $hget(reports,%asdf).item {
  402.         did -a trivia 51 $gettok($hget(reports,$v1),1,1)
  403.         inc %asdf
  404.       }
  405.       did -z trivia 51
  406.     }
  407.     did -a trivia 47 $hget(trivia,chan)
  408.     if ($hget(questions,1).item) did -e trivia 26
  409.     var %s = 1
  410.     while $hgeT(questions,%s).item {
  411.       did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  412.       inc %s
  413.     }
  414.     did -z trivia 23
  415.     if ($hget(trivia,status) == on) did -e trivia 10
  416.     else did -e trivia 9
  417.     var %x = 1
  418.     while $hget(scores,%x).item {
  419.       did -a trivia 14 $v1
  420.       inc %x
  421.     }
  422.     did -z trivia 14
  423.     if ($hgeT(scores)) did -e trivia 20
  424.     if (!$server) did -b trivia 9,10
  425.     if ($hget(trivia,strivia) == isvoice) did -c trivia 7
  426.     if ($hgeT(trivia,strivia) == isop) did -c trivia 6
  427.     if ($hget(trivia,strivia) == ison || !$v1) {
  428.       did -c trivia 8
  429.     }
  430.   }
  431.   if ($devent == sclick) {
  432.     if ($did == 9) {
  433.       if ($hget(trivia,status) != on) {
  434.         hadd -m trivia status on
  435.         did -b trivia 9
  436.         did -e trivia 10
  437.         .msg %chan $+(03Trivia has been started by04 $me,03!)
  438.         .timertrivnew 1 2 new
  439.       }
  440.     }
  441.     if ($did == 10) {
  442.       if ($hget(trivia,status) == on) {
  443.         hadd -m trivia status off
  444.         hdel trivia answer
  445.         hdel trivia time
  446.         did -e trivia 9
  447.         did -b trivia 10
  448.         .timertriv* off
  449.         unset %streak*
  450.         .msg %chan 03Trivia has been stopped by04 $me $+ 03!
  451.       }
  452.     }
  453.     if ($did == 14 && $diD(trivia,14).seltext != $null) {
  454.       did -ra trivia 15 $hget(scores,$did(trivia,14).seltext) Points
  455.       did -e trivia 19,17
  456.     }
  457.     if ($did isnum 6-8) {
  458.       if ($did == 6) hadd -m trivia strivia isop
  459.       if ($did == 7) hadd -m trivia strivia isvoice
  460.       if ($did == 8) hadd -m trivia strivia ison
  461.       if ($hget(trivia,wrong) == 5) did -c trivia 55
  462.       if ($hget(trivia,wrong) == 10) did -c trivia 56
  463.       if ($hget(trivia,wrong) == 15) did -c trivia 57
  464.       if ($hget(trivia,wrong) == 20) did -c trivia 58
  465.       if ($hget(trivia,wrong) !isnum) did -c trivia 59
  466.     }
  467.     if ($did == 20) {
  468.       var %x = $input(Are you sure you would like to erase all scores?,cy,Clear All Scores)
  469.       if (%x == $true) {
  470.         hfree scores
  471.         did -r trivia 14,15
  472.         did -b trivia 20,17,19
  473.         .msg %chan 4All03 scores cleared.
  474.       }
  475.     }
  476.     if ($did == 19) {
  477.       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)
  478.       if (%x == $true) {
  479.         .msg %chan 04 $+ $did(trivia,14).seltext $+ 's 3score has been 04cleared03.
  480.         hdel scores $did(trivia,14).seltext
  481.         did -r trivia 15,14
  482.         did -b trivia 17,19,20
  483.         var %y = 1
  484.         while $hgeT(scores,%y).item {
  485.           did -a trivia 14 $v1
  486.           inc %y
  487.         }
  488.         did -z trivia 14
  489.         if ($hget(scores,1).item) did -e trivia 20
  490.       }
  491.     }
  492.     if ($did == 18) {
  493.       var %x = $input(Who would you like to add to the score list?,qe,Adding Score)
  494.       if (%x != $null) {
  495.         if ($numtok(%x,32) == 1) {
  496.           var %y = $input(What would you like %x $+ 's score to be?,qe,%x $+ 's Score)
  497.           if (%y isnum && %y) {
  498.             hadd -m scores %x %y
  499.             .msg %chan 04 $+ %x 03now has 04 $+ %y 03points!
  500.             did -r trivia 15,14
  501.             did -b trivia 17,19
  502.             did -e trivia 20
  503.             var %a = 1
  504.             while $hget(scores,%a).item {
  505.               did -a trivia 14 $v1
  506.               inc %a
  507.             }
  508.             did -z trivia 14
  509.           }
  510.           else var %test = $input(The score must be a number!,ho,Error!)
  511.         }
  512.         else var %sos = $input(The name must be one word!,ho,Error!)
  513.       }
  514.       else var %asdf = $input(You must enter a name!,ho,Error!)
  515.     }
  516.     if ($did == 17) {
  517.       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))
  518.       if (%x isnum) {
  519.         hadd -m scores $did(trivia,14).seltext %x
  520.         .msg %chan 4 $+ $did(trivia,14).seltext 03now has04 %x 03points!
  521.         did -ra trivia 15 %x Points
  522.       }
  523.       else var %asdf = $input(The score must be a number!,ho,Error!)
  524.     }
  525.     if ($did == 24) dialog $iif($dialog(txt),-v,-m) txt txt
  526.     if ($did == 25) {
  527.       var %ques = $input(What question would you like to add?,qe,Question)
  528.       if (%ques != $null) {
  529.         var %hint1 = $input(What would you like the first hint to be?,qe,Hint 1)
  530.         if (%hint1 != $null) {
  531.           var %hint2 = $input(What would you like the second hint to be?,qe,Hint 2)
  532.           if (%hint2 != $null) {
  533.             var %ans = $input(What would you like the answer to be?,qe,Answer)
  534.             if (%ans != $null) {
  535.               did -r trivia 23,30,31,32,41
  536.               var %y = 1
  537.               var %z = $hget(questions,1).item
  538.               while $hget(questions,%y).item {
  539.                 if ($v1 > %z) var %z = $v1
  540.                 inc %y
  541.               }
  542.               hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
  543.               did -e trivia 26
  544.               var %b = 1
  545.               while $hget(questions,%b).item {
  546.                 did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  547.                 inc %b
  548.               }
  549.               did -z trivia 23
  550.               did -b trivia 27,37,38,39,42
  551.             }
  552.           }
  553.         }
  554.       }
  555.     }
  556.     if ($did == 26) {
  557.       var %x = $input(Are you sure you want to erase all questions?,cy,Remove All Questions)
  558.       if (%x == $true) {
  559.         did -r trivia 23,30,31,32,41
  560.         hfree questions
  561.         did -b trivia 26,27,37,38,39,42
  562.       }
  563.     }
  564.     if ($did == 23 && $did(trivia,23).seltext != $null) {
  565.       did -e trivia 27,37,38,39,42
  566.       var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
  567.       noop $regex($hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data),/^(.+)(.+)(.+)(.+)$/i)
  568.       did -ra trivia 31 $regml(2)
  569.       did -ra trivia 30 $regml(3)
  570.       did -ra trivia 32 $regml(4)
  571.       did -ra trivia 41 $regml(1)
  572.     }
  573.     if ($did == 27) {
  574.       var %x = $input(Are you sure you want to delete this question?,cy,Delete Question)
  575.       if (%x == $true) {
  576.         hdel questions %a $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
  577.         did -r trivia 23,30,31,32,41
  578.         var %y = 1
  579.         while $hget(questions,%y).item {
  580.           did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  581.           inc %y
  582.         }
  583.         did -b trivia 27,37,38,39,42
  584.         did -z trivia 23
  585.       }
  586.     }
  587.     if ($did == 38) {
  588.       var %x = $input(What would you like hint 1 to be?,qe,Hint 1,$did(trivia,31).text)
  589.       if (%x != $null) {
  590.         var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
  591.         var %a = $hget(questions,%y)
  592.         var %z = $replace(%a,$gettok(%a,2,1),%x)
  593.         hadd -m questions %y %z
  594.         did -ra trivia 31 %x
  595.       }
  596.     }
  597.     if ($did == 37) {
  598.       var %as = $input(What would you like Hint 2 to be?,qe,Hint 2,$did(trivia,30).text)
  599.       if (%as != $null) {
  600.         var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
  601.         var %a = $hget(questions,%y)
  602.         var %z = $replace(%a,$gettok(%a,3,1),%as)
  603.         hadd -m questions %y %z
  604.         did -ra trivia 30 %as
  605.       }
  606.     }
  607.     if ($did == 39) {
  608.       var %sa = $input(What would you like the answer to be?,qe,Answer,$did(trivia,32).text)
  609.       if (%sa != $null) {
  610.         var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
  611.         var %a = $hget(questions,%y)
  612.         var %z = $replace(%a,$gettok(%a,4,1),%sa)
  613.         hadd -m questions %y %z
  614.         did -ra trivia 32 %sa
  615.       }
  616.     }
  617.     if ($did == 42) {
  618.       var %sas = $input(What would you like to rename the question as?,qe,Question,$did(trivia,41).text)
  619.       if (%sas != $null) {
  620.         var %y = $hfind(questions,$did(trivia,23).seltext $+ *,1,w).data
  621.         var %a = $hget(questions,%y)
  622.         var %z = $replace(%a,$gettok(%a,1,1),%sas)
  623.         hadd -m questions %y %z
  624.         did -ra trivia 41 %sas
  625.         did -r trivia 23
  626.         var %lmn = 1
  627.         while $hget(questions,%lmn).item {
  628.           did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  629.           inc %lmn
  630.         }
  631.         did -c trivia 23 $didwm(trivia,23,%sas $+ *)
  632.         did -z trivia 23
  633.       }
  634.     }
  635.     if ($did == 45) {
  636.       var %x = $input(Who would you like to set as the owner?,qe,Owner,$hget(trivia,owner))
  637.       if (%x != $null) {
  638.         hadd -m trivia owner %x
  639.         did -ra trivia 44 %x
  640.       }
  641.     }
  642.     if ($did == 48) {
  643.       var %x = $input(What would you like to set as the trivia channel?,qe,Trivia Channel,$hget(trivia,chan))
  644.       if (%x != $null) {
  645.         if ($left(%x,1) == $chr(35)) {
  646.           hadd -m trivia chan %x
  647.           did -ra trivia 47 %x
  648.         }
  649.         else var %y = $input(The channel must begin with $chr(35),ho,Error!)
  650.       }
  651.     }
  652.     if ($did == 51 && $did(trivia,51).seltext != $null) {
  653.       did -ra trivia 50 $gettok($hget(reports,$hfind(reports,$did(trivia,51).seltext $+ *,1,w).data),2,1)
  654.       did -e trivia 68,22
  655.     }
  656.     if ($did == 22) {
  657.       did -c trivia 3
  658.       did -c trivia 23 $didwm(trivia,23,$did(trivia,51).seltext $+ *)
  659.       var %x = $hget(questions,$hfind(questions,$did(trivia,23).seltext $+ *,1,w).data)
  660.       did -ra trivia 31 $gettok(%x,2,1)
  661.       did -ra trivia 30 $gettok(%x,3,1)
  662.       did -ra trivia 32 $gettok(%x,4,1)
  663.       did -ra trivia 41 $gettok(%x,1,1)
  664.       did -e trivia 27,37,38,39,42
  665.     }
  666.     if ($did == 67) {
  667.       var %x = $input(Are you sure you would like to delete all reports?,cy,Erase All Reports)
  668.       if (%x == $true) {
  669.         did -r trivia 51,50
  670.         hfree reports
  671.       }
  672.     }
  673.     if ($did == 68) {
  674.       var %x = $input(Are you sure you would like to remove this report?,cy,Remove Report)
  675.       if (%x == $true) {
  676.         did -b trivia 22,67,68
  677.         hdel reports $hfind(reports,$did(trivia,51).seltext $+ *,1,w).data
  678.         var %x = 1
  679.         did -r trivia 51,50
  680.         while $hget(reports,%x).item {
  681.           did -a trivia 51 $gettok($hget(reports,$v1),1,1)
  682.           inc %x
  683.         }
  684.         did -z trivia 51
  685.         if ($hget(reports,1).data) did -e trivia 67
  686.       }
  687.     }
  688.     if ($did isnum 55-58) {
  689.       hadd -m trivia wrong $gettok($did(trivia,$did),1,32)
  690.       if ($hget(trivia,strivia) == ison) did -c trivia 8
  691.       if ($hget(trivia,strivia) == isvoice) did -c trivia 7
  692.       if ($hgeT(trivia,strivia) == isop) did -c trivia 6
  693.     }
  694.     if ($did == 59) {
  695.       hadd -m trivia wrong none
  696.       if ($hget(trivia,strivia) == ison) did -c trivia 8
  697.       if ($hget(trivia,strivia) == isvoice) did -c trivia 7
  698.       if ($hgeT(trivia,strivia) == isop) did -c trivia 6
  699.     }
  700.     if ($did == 61) {
  701.       write missed.txt $did(trivia,60).text
  702.       did -r trivia 60
  703.       did -b trivia 61
  704.       var %x = $input(Missed Question Response Added!,io,Response Added)
  705.     }
  706.   }
  707.   if ($devent == edit && $did == 60) {
  708.     if ($did(trivia,60).text != $null) did -e trivia 61
  709.     else did -b trivia 61
  710.   }
  711. }
  712. alias -l hash {
  713.   var %del = $$input(What delimeter seperates the question from the answer?,qe,Delimeter)
  714.   var %x = 1
  715.   unset %ques %ans
  716.   while $read($qt($$1-),%x) {
  717.     var %ques = $gettok($v1,1,%del)
  718.     var %ans = $gettok($v1,2,%del)
  719.     var %y = 1
  720.     unset %hint1 %hint2
  721.     while $gettok(%ans,%y,32) {
  722.       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)
  723.       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)
  724.       inc %y
  725.     }
  726.     var %z = 1
  727.     while $hget(questions,%z).item {
  728.       inc %z
  729.     }
  730.     hadd -m questions $calc(%z + 1) $+(%ques,$chr(1),%hint1,$chr(1),%hint2,$chr(1),%ans)
  731.     inc %x
  732.   }
  733.   did -r trivia 23
  734.   var %b = 1
  735.   while $hget(questions,%b).item {
  736.     did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  737.     inc %b
  738.   }
  739.   did -z trivia 23
  740.   did -e trivia 26
  741.   did -b trivia 27,38,37,39,42
  742. }
  743.  
  744. dialog -l txt {
  745.   title "Add *.txt"
  746.   size -1 -1 101 58
  747.   option dbu
  748.   button "...", 1, 84 6 11 10
  749.   edit "", 2, 7 6 74 10, autohs
  750.   radio "Question|Answer", 3, 7 30 53 10
  751.   radio "Question|Hint1|Hint2|Answer", 4, 7 20 84 10
  752.   button "OK", 5, 20 44 28 10, disable ok
  753.   button "Cancel", 6, 53 44 28 10, cancel
  754. }
  755.  
  756. on *:dialog:txt:*:*:{
  757.   if ($devent == sclick) {
  758.     if ($did == 1) {
  759.       :a
  760.       var %x = $$sfile($mircdir $+ *.txt,Select a .txt file,Select)
  761.       if ($right(%x,4) != .txt) {
  762.         var %y = $input(Please select a .txt file!,ho,Error!)
  763.         goto a
  764.       }
  765.       else did -ra txt 2 %x
  766.       if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
  767.         did -e txt 5
  768.       }
  769.       else did -b txt 5
  770.     }
  771.     if ($did == 3 || $did == 4) {
  772.       if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
  773.         did -e txt 5
  774.       }
  775.       else did -b txt 5
  776.     }
  777.     if ($did == 5) {
  778.       if ($isfile($did(txt,2))) {
  779.         if ($did(txt,3).state == 1) {
  780.           hash $did(txt,2)
  781.         }
  782.         elseif ($did(txt,4).state == 1) {
  783.           addtxt $did(txt,2)
  784.         }
  785.       }
  786.       else var %x = $input($did(txt,2) isn't a file!,ho,Error!)
  787.     }
  788.   }
  789.   if ($devent == edit) {
  790.     if (($did(txt,3).state == 1 || $did(txt,4).state == 1) && $right($did(txt,2),4) == .txt) {
  791.       did -e txt 5
  792.     }
  793.     else did -b txt 5
  794.   }
  795. }
  796. alias -l addtxt {
  797.   var %as = $$input(What is the delimeter that seperates the hints $+ $chr(44) questions $+ $chr(44) and answers?,qe,Delimeter)
  798.   if (%as isnum) {
  799.     var %x = $qt($$1-)
  800.     did -r trivia 23,30,31,32,41
  801.     var %y = 1
  802.     var %z = $hget(questions,1).item
  803.     while $hget(questions,%y).item {
  804.       if ($v1 > %z) var %z = $v1
  805.       inc %y
  806.     }
  807.     var %a = 1
  808.     while $read(%x,%a) {
  809.       hadd -m questions $calc(%z + 1) $replace($v1,$chr(%as),$chr(1))
  810.       inc %z
  811.       inc %a
  812.     }
  813.     var %b = 1
  814.     while $hget(questions,%b).item {
  815.       did -a trivia 23 $gettok($hget(questions,$v1),1,1)
  816.       inc %b
  817.     }
  818.     did -z trivia 23
  819.     did -e trivia 26
  820.     did -b trivia 27,38,37,39,42
  821.   }
  822.   else var %sumthin = $input(The delimeter must be a number!,ho,Error!)
  823. }