; ; Cosmoquiz v1.21 beta ; ; by Cosmos (cosmos_42@yahoo.com.au) ; ; Last modified 14/01/01 ; ; Requires mIRC v5.82 or later - will not function with earlier versions ; ; Question file must consist of alternating lines of questions and answers ; with no spaces or blank lines at the end. Failure to format question ; file correctly may cause script to behave unexpectedly ; ; If you change the filename of this script, you MUST change %cq_script_name ; ; After loading script, type /cq to invoke dialog box ; ; See end of script for reference information ; ; Script begins here: on *:start: { ; ; Commands to execute when mIRC starts ; if ($version < 5.82) { echo 4 -a *** Sorry, this script requires mIRC v5.82 or later } .ial on unset %cq* .disable #cq_answermode %cq_mirc_directory = $mircdir %cq_script_name = cosmoquiz.txt %cq_scoreboard = ON %cq_previewed = FALSE %cq_random = TRUE %cq_moderate = FALSE if ($version < 5.82) { echo 4 -a *** Sorry, this script requires mIRC v5.82 or later cq_unload } echo 4 -a *** Cosmoquiz loaded } alias cq_unload { ; ; Alias to completely unload script and all associated variables ; ; cq_unload takes no arguments ; if ($dialog(cq_dialog).title != $null) { dialog -x cq_dialog cq_dialog } if ($dialog(cq_dialog_answers).title != $null) { dialog -x cq_dialog_answers cq_dialog_answers } if ($dialog(cq_dialog_players).title != $null) { dialog -x cq_dialog_players cq_dialog_players } echo 4 -a *** Cosmoquiz unloaded .ial off var %tounload = %cq_mirc_directory $+ %cq_script_name unset %cq* unload -rs %tounload } alias cq_scores_reset { ; ; Alias to reset all scores, as at the end of a round ; ; cq_scores_reset takes no arguments ; unset %cq_player* unset %cq_hostid* unset %cq_nickid* unset %cq_total_players echo 4 -a *** Scores reset } alias cq_loadfile { ; Alias to load in a new question file ; ; Usage /cq_loadfile - bring up dialog box to pick file to load ; /cq_loadfile filename - immediately load filename ; var %oldfile = %cq_file_name if ($exists($1) == $true) { %cq_file_name = $1 } else { %cq_file_name = $$dir="Please select file to open" [ [ %cq_mirc_directory ] $+ ] *.txt } if (%cq_file_name != %oldfile) { unset %cq_asked* %cq_file_lines = $lines(%cq_file_name) %cq_file_questions = $calc(%cq_file_lines / 2) %cq_asked_total = 0 %cq_pointer = 0 %cq_previewed = FALSE if (2 // %cq_file_lines) { echo 4 -a -------------------------------------- echo 4 -a Loaded file [ %cq_file_name ] echo 4 -a File contains [ %cq_file_questions ] questions echo 4 -a -------------------------------------- } else { echo 4 -a *** Sorry, [ %cq_file_name ] has an uneven number of lines! unset %cq_file* } } } alias cq_preview { ; ; Alias to preview next question and answer ; ; cq_preview takes no arguments ; if ((%cq_asked_total >= %cq_file_questions) || ($exists(%cq_file_name) != $true)) { echo 4 -a *** Sorry, you are out of questions! } else { if (%cq_random == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) } } else { %cq_pointer = 1 while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { inc %cq_pointer } } %cq_question = $read -nl [ $+ [ $calc((%cq_pointer * 2)-1) ] ] %cq_file_name %cq_answer = $read -nl [ $+ [ $calc(%cq_pointer * 2) ] ] %cq_file_name %cq_previewed = TRUE if ($dialog(cq_dialog).title == $null) { echo 4 -a Next Q : [ %cq_question ] echo 4 -a Answer : [ %cq_answer ] } } } alias cq_jump { ; ; Alias to jump to a specific question number ; ; Usage /cq_jump # where # is the question number to jump to ; if ($1 isnum 1 - %cq_file_questions) { if (%cq_asked_ [ $+ [ $1 ] ] != TRUE) { %cq_pointer = $1 %cq_question = $read -nl [ $+ [ $calc((%cq_pointer * 2)-1) ] ] %cq_file_name %cq_answer = $read -nl [ $+ [ $calc(%cq_pointer * 2) ] ] %cq_file_name %cq_previewed = TRUE if ($dialog(cq_dialog).title == $null) { echo 4 -a Next Q : [ %cq_question ] echo 4 -a Answer : [ %cq_answer ] } } else { echo 4 -a *** Sorry, question [ $1 ] has already been asked } } else { echo 4 -a *** Sorry, that question number is invalid } } alias cq_skip { ; ; Alias to skip the current question permanently ; ; cq_skip takes no arguments ; if ((%cq_pointer != $null) && (%cq_asked_total <= %cq_file_questions)) { %cq_asked_ [ $+ [ %cq_pointer ] ] = TRUE inc %cq_asked_total %cq_previewed = FALSE cq_preview } } alias cq_ask { ; Alias to ask questions ; ; Usage /cq_ask - picks a random question from file ; /cq_ask Question - manually asks question ; if ($1 == $null) { if (%cq_previewed != TRUE) { if ((%cq_asked_total >= %cq_file_questions) || ($exists(%cq_file_name) != $true)) { echo 4 -a *** Sorry, you are out of questions! } else { if (%cq_random == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) } } else { %cq_pointer = 1 while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { inc %cq_pointer } } %cq_question = $read -nl [ $+ [ $calc((%cq_pointer * 2)-1) ] ] %cq_file_name %cq_answer = $read -nl [ $+ [ $calc(%cq_pointer * 2) ] ] %cq_file_name } } describe $active Q: [ %cq_question ] echo 4 -a Answer: [ %cq_answer ] %cq_asked_ [ $+ [ %cq_pointer ] ] = TRUE inc %cq_asked_total %cq_previewed = FALSE } else { %cq_question = $1- %cq_answer = $null describe $active Q: $1- } } alias cq_repeat { ; ; Alias to repeat the current question ; ; cq_repeat takes no arguments ; describe $active Q: (Repeat) %cq_question } alias cq_ans { ; Alias to answer a question ; ; Usage /cq_ans - display correct answer (award to nobody) ; /cq_ans Nick - award to nick, answer from file ; /cq_ans - award to nick, answer from command line if ($1 == $null) { describe $active The correct answer was: [ %cq_answer ] if (%cq_scoreboard == ON) { cq_scores } } elseif ($address($1, 3) == $null) { echo 4 -a *** Sorry, [ $1 ] is not in [ $active ] or has not spoken } else { if ($2- == $null) { var %answer_to_give = %cq_answer } else { var %answer_to_give = $2- } describe $active < [ $ial($address($1, 3)).nick ] > !!!!!!!! Answer: [ %answer_to_give ] var %lookup_player = %cq_hostid_ [ $+ [ $address($1, 3) ] ] if (%lookup_player == $null) { inc %cq_total_players %cq_player_ [ $+ [ %cq_total_players ] $+ _host ] = $address($1, 3) %cq_player_ [ $+ [ %cq_total_players ] $+ _nick ] = $ial($address($1, 3), 1).nick %cq_player_ [ $+ [ %cq_total_players ] $+ _score ] = 1 %cq_hostid_ [ $+ [ $address($1, 3) ] ] = %cq_total_players %cq_nickid_ [ $+ [ $ial($address($1, 3), 1).nick ] ] = %cq_total_players } else { inc %cq_player_ [ $+ [ %lookup_player ] $+ _score ] %cq_player_ [ $+ [ %lookup_player ] $+ _nick ] = $ial($address($1, 3), 1).nick } if (%cq_scoreboard == ON) { cq_scores } } } alias cq_toggle_random { ; ; Alias to toggle random question selection TRUE/FALSE ; ; cq_toggle_random takes no arguments ; if (%cq_random == TRUE) { %cq_random = FALSE echo 4 -a *** Random question selection disabled } else { %cq_random = TRUE echo 4 -a *** Random question selection enabled } } alias cq_toggle_moderate { ; ; Alias to toggle moderation of channel on final scores ; ; cq_toggle_moderate takes no arguments ; if (%cq_moderate == TRUE) { %cq_moderate = FALSE echo 4 -a *** Channel will NOT be moderated on final scoreboard } else { %cq_moderate = TRUE echo 4 -a *** Channel WILL be moderated on final scoreboard } } alias cq_toggle_scoreboard { ; ; Alias to toggle scoreboard ON/OFF ; ; cq_toggle_scoreboard takes no arguments ; if (%cq_scoreboard == ON) { %cq_scoreboard = OFF echo 4 -a *** Scoreboard is now OFF } else { %cq_scoreboard = ON echo 4 -a *** Scoreboard is now ON } } alias cq_scores { ; ; Alias to display simple (short-form) scoreboard ; ; cq_scores takes no arguments if (%cq_total_players > 0 ) { cq_sort var %loopcounter = 1 var %scorestring = Scores: while (%loopcounter <= %cq_total_players) { %scorestring = [ %scorestring ] %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] $+ ( $+ %cq_player_ [ $+ [ %loopcounter ] $+ _score ] $+ ), inc %loopcounter } describe $active [ $left(%scorestring, -1) ] $+ . } else { echo 4 -a *** The scoreboard is empty! } } alias cq_scores_final { ; ; Alias to display final scoreboard (usually at the end of a round) ; ; cq_scores_final takes no arguments ; if (%cq_total_players > 0) { if (($me isop $active) && (%cq_moderate == TRUE)) { mode $active +m var %mod_delay 2 } else { var %mod_delay 1 } .timer 1 $calc(%mod_delay - 1) describe $active FINAL SCORES .timer 1 %mod_delay describe $active ------------ cq_sort var %loopcounter = 0 var %placemarker = 0 while (%loopcounter < %cq_total_players) { inc %loopcounter inc %placemarker if ($right(%placemarker, 1) == 1) { var %placeid = st } elseif ($right(%placemarker, 1) == 2) { var %placeid = nd } elseif ($right(%placemarker, 1) == 3) { var %placeid = rd } else { var %placeid = th } if (%cq_player_ [ $+ [ %loopcounter ] $+ _score ] < 10) { var %leadingzero = 0 } else { var %leadingzero = $null } var %scorestring = [ %placemarker ] $+ %placeid - %leadingzero $+ [ %cq_player_ [ $+ [ %loopcounter ] $+ _score ] ] pts - [ %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] ] while (%cq_player_ [ $+ [ %loopcounter ] $+ _score ] == %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _score ] ) { inc %loopcounter %scorestring = [ %scorestring ] $+ , %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] } .timer 1 $calc(%placemarker + %mod_delay) describe $active [ %scorestring ] } if ($me isop $active) { .timer 1 $calc(%placemarker + 3) mode $active -m } } else { echo 4 -a *** The scoreboard is empty! } } alias cq_player_add { ; ; Alias to add one point to a player's score ; ; Usage /cq_player_add nick ; var %tempnickid = %cq_nickid_ [ $+ [ $1 ] ] if (%tempnickid == $null) { if ($address($1, 3) == $null) { if (($1 ison $active) && (%cq_player_ial_ [ $+ [ ($1) ] ] == $null ) ) { who $1 echo 4 -a *** [ $1 ] has not spoken - IAL updating, please wait... .timer 1 5 cq_player_add $1 %cq_player_ial_ [ $+ [ ($1) ] ] = TRUE } else { echo 4 -a *** Sorry, [ $1 ] is not in [ $active ] or is not responding unset %cq_player_ial* } } else { inc %cq_total_players %cq_player_ [ $+ [ %cq_total_players ] $+ _host ] = $address($1, 3) %cq_player_ [ $+ [ %cq_total_players ] $+ _nick ] = $ial($address($1, 3), 1).nick %cq_player_ [ $+ [ %cq_total_players ] $+ _score ] = 1 %cq_hostid_ [ $+ [ $address($1, 3) ] ] = %cq_total_players %cq_nickid_ [ $+ [ $ial($address($1, 3), 1).nick ] ] = %cq_total_players echo 4 -a *** 1 point added to $1 unset %cq_player_ial* } } else { inc %cq_player_ [ $+ [ %tempnickid ] $+ _score ] cq_sort echo 4 -a *** 1 point added to $1 } } alias cq_player_sub { ; ; Alias to substract one point from a player's score ; ; Will delete player from scoreboard if score decreased to 0 ; ; Usage /cq_player_sub nick var %tempnickid = %cq_nickid_ [ $+ [ $1 ] ] if (%tempnickid == $null) { echo 4 -a *** Sorry, [ $1 ] is not on the scoreboard } else { dec %cq_player_ [ $+ [ %tempnickid ] $+ _score ] cq_sort echo 4 -a 1 point subtracted from $1 if (%cq_player_ [ $+ [ %tempnickid ] $+ _score ] <= 0) { cq_player_delete $1 } } } alias cq_player_delete { ; ; Alias to delete a player from the scoreboard ; ; Usage /cq_player_delete nick ; var %tempnickid = %cq_nickid_ [ $+ [ $1 ] ] if (%tempnickid == $null) { echo 4 -a *** Sorry, [ $1 ] is not on the scoreboard } else { var %tempnick = %cq_player_ [ $+ [ %tempnickid ] $+ _nick ] var %temphost = %cq_player_ [ $+ [ %tempnickid ] $+ _host ] %cq_player_ [ $+ [ %tempnickid ] $+ _score ] = -1000 cq_sort unset %cq_player_ [ $+ [ %cq_total_players ] $+ _ ] $+ * unset %cq_hostid_ [ $+ [ %temphost ] ] unset %cq_nickid_ [ $+ [ %tempnick ] ] dec %cq_total_players echo 4 -a *** [ %tempnick ] removed from scoreboard } } alias cq_sort { ; ; Bubblesort routine to sort scoreboard ; var %swapflag = TRUE var %loopcounter2 = 0 while (%swapflag == TRUE) { var %swapflag == FALSE var %loopcounter = 1 inc %loopcounter2 while (%loopcounter <= $calc(%cq_total_players - %loopcounter2)) { if ( %cq_player_ [ $+ [ %loopcounter ] $+ _score ] < %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _score ] ) { var %tempnick1 = %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] var %temphost1 = %cq_player_ [ $+ [ %loopcounter ] $+ _host ] var %tempscore1 = %cq_player_ [ $+ [ %loopcounter ] $+ _score ] var %tempid1 = %cq_hostid_ [ $+ [ %temphost1 ] ] var %tempnickid1 = %cq_nickid_ [ $+ [ %tempnick1 ] ] var %tempnick2 = %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _nick ] var %temphost2 = %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _host ] var %tempscore2 = %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _score ] var %tempid2 = %cq_hostid_ [ $+ [ %temphost2 ] ] var %tempnickid2 = %cq_nickid_ [ $+ [ %tempnick2 ] ] %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] = %tempnick2 %cq_player_ [ $+ [ %loopcounter ] $+ _host ] = %temphost2 %cq_player_ [ $+ [ %loopcounter ] $+ _score ] = %tempscore2 %cq_hostid_ [ $+ [ %temphost1 ] ] = %tempid2 %cq_nickid_ [ $+ [ %tempnick1 ] ] = %tempnickid2 %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _nick ] = %tempnick1 %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _host ] = %temphost1 %cq_player_ [ $+ [ $calc(%loopcounter + 1) ] $+ _score ] = %tempscore1 %cq_hostid_ [ $+ [ %temphost2 ] ] = %tempid1 %cq_nickid_ [ $+ [ %tempnick2 ] ] = %tempnickid1 %swapflag = TRUE } inc %loopcounter } } } on *:NICK:{ ; ; Triggered when a player changes their nick ; var %temphostid = %cq_hostid_ [ $+ [ $address($newnick, 3) ] ] if (%temphostid != $null ) { %cq_player_ [ $+ [ %temphostid ] $+ _nick ] = $newnick unset %cq_nickid_ [ $+ [ $nick ] ] %cq_nickid_ [ $+ [ $newnick ] ] = %temphostid } } alias cq { ; ; Alias to open/close dialog box interface ; if ($dialog(cq_dialog).table == $null ) { dialog -m cq_dialog_answers cq_dialog_answers dialog -s cq_dialog_answers 10000 10000 0 0 dialog -m cq_dialog cq_dialog } else { dialog -x cq_dialog cq_dialog if ($dialog(cq_dialog_answers).title != $null) { dialog -x cq_dialog_answers cq_dialog_answers .disable #cq_answermode } } } alias cq_update_qfilestat { ; ; Alias to update data on current question file ; did -r cq_dialog 33,35,36,38, 41 did -a cq_dialog 33 %cq_pointer did -a cq_dialog 35 %cq_file_questions did -a cq_dialog 36 $calc(%cq_file_questions - %cq_asked_total) did -a cq_dialog 38 %cq_file_name did -a cq_dialog 41 %cq_asked_total } alias cq_update_preview { ; ; Alias to update question preview on main dialog box ; did -r cq_dialog 61,62 did -a cq_dialog 61 %cq_question did -a cq_dialog 62 %cq_answer } alias cq_update_answerstat { ; ; Alias to update data on answer dialog box ; did -r cq_dialog_answers 321 did -r cq_dialog_answers 232 did -r cq_dialog_answers 234 did -r cq_dialog_answers 237 did -a cq_dialog_answers 232 %cq_question did -a cq_dialog_answers 234 %cq_answer did -a cq_dialog_answers 237 $upper($group(#cq_answermode)) } ; Main Dialog box - invoke with /cq ; Buttons 1-30 ; Text 31-60 ; Edit 61-80 ; Box 81-100 ; Checkbox 101-120 dialog cq_dialog { title "Cosmoquiz v1.21 beta - by Cosmos " size 20 105 600 120 button "",1000, 0 0 0 0, ok button "",500, 0 0 0 0, cancel box "",81, -5 68 610 10 text "Q:",47,75 79 15 15 edit %cq_question,61,95 79 505 21, autohs text "A:",48,75 100 15 15 edit %cq_answer,62,95 100 505 21, autohs text "Q:",32,1 45 60 20 text %cq_pointer,33, 25 45 35 20,right text "/",34, 60 45 5 20 text %cq_file_questions,35, 65 45 35 20,left text "Used: ",40, 120 45 35 20 text $calc(%cq_file_questions - %cq_asked_total),41, 165 45 35 20,left text "Left: ",42, 205 45 30 20 text $calc(%cq_file_questions - %cq_asked_total),36, 235 45 35 20,right text %cq_file_name,38, 1 60 270 15 button "A S K ",1,0 0 85 45 button "Load...",2,90 0 60 22 button "Answer",3,90 25 60 20 button "Jump...",4,160 1 55 22 button "Unload",5,220 1 55 22 button "Preview",6,1 80 60 20 button "Skip",7,1 101 60 20 check "Random Q:",101, 160 23 114 22 box "",85, 280 -10 1 88 button "Show",11,290 23 45 25 button "Final",12,340 23 45 25 button "Reset",13,390 23 45 25 text "Score Management",59, 305 1 140 20 check "Score",111,290 55 60 20 check "Moderate",112,360 55 80 20 box "",91, 445 -10 1 88 button "Add",21,455 23 45 25 button "Sub",22,505 23 45 25 button "Del",23,555 23 45 25 button "List",24,555 50 45 25 text "Player Management",60, 465 1 140 20 edit "",71, 455 50 100 25 } ; Main Dialog box events on *:dialog:cq_dialog:init:0:{ ; Triggered when dialog box is opened if (%cq_scoreboard == ON) { did -c cq_dialog 111 } if (%cq_moderate == TRUE) { did -c cq_dialog 112 } if (%cq_random == TRUE) { did -c cq_dialog 101 } cq_update_qfilestat did -t cq_dialog 2 did -f cq_dialog 2 } on *:dialog:cq_dialog:sclick:500:{ ; Triggered when main dialog box is shut via (X) button if ($dialog(cq_dialog_answers).title != $null) { dialog -x cq_dialog_answers cq_dialog_answers .disable #cq_answermode } if ($dialog(cq_dialog_players).title != $null) { dialog -x cq_dialog_players cq_dialog_players } } on *:dialog:cq_dialog:sclick:1:{ ; Triggered by clicking the "Ask" button %cq_active_channel = $active if ((%cq_asked_total >= %cq_file_questions) || ($exists(%cq_file_name) != $true)) { echo 4 -a *** Sorry, you are out of questions! } else { if ($dialog(cq_dialog_answers).title == $null) { dialog -m cq_dialog_answers cq_dialog_answers dialog -s cq_dialog_answers 20 210 600 220 } %cq_question = $did(cq_dialog, 61).text %cq_answer = $did(cq_dialog, 62).text cq_ask cq_update_qfilestat did -r cq_dialog_answers 261 did -b cq_dialog 1 .enable #cq_answermode if ( $dialog(cq_dialog_answers).x == 10000 ) { dialog -s cq_dialog_answers 20 210 600 220 cq_update_answerstat did -f cq_dialog_answers 261 } else { cq_update_answerstat did -r cq_dialog_answer 321 } } } on *:dialog:cq_dialog:sclick:2:{ ; Triggered when "Load" button is pressed cq_loadfile cq_update_qfilestat did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog:sclick:3:{ ; Triggered when "Answer" button is pressed if ($dialog(cq_dialog_answers).title == $null) { dialog -m cq_dialog_answers cq_dialog_answers dialog -s cq_dialog_answers 20 210 600 220 cq_update_answerstat } else { if ( $dialog(cq_dialog_answers).x == 10000 ) { dialog -s cq_dialog_answers 20 210 600 220 did -f cq_dialog_answers 261 } else { dialog -s cq_dialog_answers 10000 10000 0 0 } } } on *:dialog:cq_dialog:edit:61:{ ; Triggered when text is entered in "Load" edit box did -t cq_dialog 2 } on *:dialog:cq_dialog:sclick:4:{ ; Triggered when the "Jump..." button is clicked var %jumpto = $?="Jump to which question?" cq_jump %jumpto cq_update_preview cq_update_qfilestat did -f cq_dialog 1 } on *:dialog:cq_dialog:sclick:5:{ ; Triggered when "Unload Script" button is pressed beep var %sure = $?!="Are you sure you want to unload Cosmoquiz?" if (%sure == $true) { cq_unload } } on *:dialog:cq_dialog:sclick:6:{ ; Triggered when "preview" button is pressed cq_preview cq_update_preview cq_update_qfilestat } on *:dialog:cq_dialog:sclick:7:{ ; Triggered when "Skip" button is pressed cq_skip cq_update_qfilestat cq_update_preview } on *:dialog:cq_dialog:sclick:11:{ ; Triggered when "show scoreboard" button is pressed cq_scores } on *:dialog:cq_dialog:sclick:12:{ ; Triggered when "Final scoreboard" button is pressed cq_scores_final } on *:dialog:cq_dialog:sclick:13:{ ; Triggered when "Reset scoreboard" button is clicked beep var %sure = $?!="Are you sure you want to reset scores?" if (%sure == $true) { cq_scores_reset } } on *:dialog:cq_dialog:sclick:21:{ ; ; Triggered when "Add" button is pressed ; if ($dialog(cq_dialog_players).title != $null) { if ($did(cq_dialog_players,521).seltext != $null) { var %nick = %cq_player_ [ $+ [ $did(cq_dialog_players,521).sel ] $+ _nick ] cq_player_add %nick cq_update_players var %newid = %cq_nickid_ [ $+ [ %nick ] ] did -f cq_dialog_players 521 did -c cq_dialog_players 521 %newid } else { cq_player_add $did(cq_dialog, 71).text cq_update_players } } else { cq_player_add $did(cq_dialog, 71).text } } on *:dialog:cq_dialog:sclick:22:{ ; ; Triggered when "Sub" button is pressed ; if ($dialog(cq_dialog_players).title != $null) { if ($did(cq_dialog_players,521).seltext != $null) { var %nick = %cq_player_ [ $+ [ $did(cq_dialog_players,521).sel ] $+ _nick ] cq_player_sub %nick cq_update_players var %newid = %cq_nickid_ [ $+ [ %nick ] ] did -f cq_dialog_players 521 if (%newid != $null) { did -c cq_dialog_players 521 %newid } else { did -r cq_dialog 71 did -f cq_dialog 71 } } else { cq_player_sub $did(cq_dialog, 71).text cq_update_players } } else { cq_player_sub $did(cq_dialog, 71).text } } on *:dialog:cq_dialog:sclick:23:{ ; ; Triggered when "Del" button is pressed ; if ($dialog(cq_dialog_players).title != $null) { if ($did(cq_dialog_players,521).seltext != $null) { var %nick = %cq_player_ [ $+ [ $did(cq_dialog_players,521).sel ] $+ _nick ] cq_player_delete %nick cq_update_players did -r cq_dialog 71 did -f cq_dialog 71 } else { cq_player_delete $did(cq_dialog, 71).text cq_update_players } } else { cq_player_delete $did(cq_dialog, 71).text } } on *:dialog:cq_dialog:sclick:24:{ ; Triggered when "List" button is pressed if ($dialog(cq_dialog_players).title == $null) { dialog -m cq_dialog_players cq_dialog_players cq_update_players } else { dialog -x cq_dialog_players cq_dialog_players } } on *:dialog:cq_dialog:sclick:101:{ ; ; Triggered when "random questions" checkbox is clicked ; cq_toggle_random } on *:dialog:cq_dialog:sclick:111:{ ; ; Triggered when "score" checkbox is clicked ; cq_toggle_scoreboard } on *:dialog:cq_dialog:sclick:112:{ ; ; Triggered when "moderate" checkbox is clicked ; cq_toggle_moderate } ; Answer mode dialog box ; Buttons 201-230 ; Text 231-260 ; Edit 261-280 ; Box 281-300 ; Checkbox 301-320 ; List 321-340 dialog cq_dialog_answers { title "Answer Mode - Double click to award answer" size 20 190 600 220 button "",1500, 0 0 0 0, cancel button "",2000, 0 0 0 0, ok button "",2500, 0 0 0 0, default list 321, 0 30 530 180, vsbar text "Q:" ,231, 5 1 15 15 text %cq_question,232, 20 1 510 15 text "A:",233, 5 15 15 15 text %cq_answer,234, 20 15 510 15 text "HINT:",235, 2 199 40 20 text "Logging",236, 539 28 60 20 text $upper($group(#cq_answermode)),237, 550 47 40 20 button "Logging",201, 533 64 64 25 button "Clear",202, 533 94 64 25 button "Repeat Q:",203, 533 124 64 25 button "Give A:",204, 533 155 64 25 button "Give hint",205, 533 187 64 25 edit "",261,40 197 490 21, autohs } ; Answer mode dialog box events #cq_answermode off on *:text:*:%cq_active_channel:{ did -a cq_dialog_answers 321 $nick > $1- } #cq_answermode end on *:dialog:cq_dialog_answers:sclick:1500:{ ; Triggered when answer dialog box is shut via (X) button did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog_answers:dclick:321:{ ; Triggered by double clicking player's response var %winner = $gettok($did(cq_dialog_answers, 321).seltext, 1, 32) cq_ans %winner .disable #cq_answermode dialog -s cq_dialog_answers 10000 10000 0 0 cq_update_answerstat cq_preview cq_update_preview cq_update_qfilestat did -e cq_dialog 1 did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog_answers:sclick:201:{ ; Triggered by clicking the "Logging button" if ($group(#cq_answermode) == on) { .disable #cq_answermode did -r cq_dialog_answers 237 did -a cq_dialog_answers 237 $upper($group(#cq_answermode)) } else { .enable #cq_answermode did -r cq_dialog_answers 237 did -a cq_dialog_answers 237 $upper($group(#cq_answermode)) } } on *:dialog:cq_dialog_answers:sclick:202:{ ; Triggered by clicking the "Clear" button did -r cq_dialog_answers 321 } on *:dialog:cq_dialog_answers:sclick:203:{ ; Triggered by clicking the "Repeat Q:" button cq_repeat did -f cq_dialog_answers 261 did -c cq_dialog_answers 261 1 1 $did(cq_dialog_answers,261).len } on *:dialog:cq_dialog_answers:sclick:204:{ ; Triggered by clicking the "Give A:" button cq_ans dialog -s cq_dialog_answers 10000 10000 0 0 cq_preview cq_update_preview cq_update_qfilestat did -e cq_dialog 1 did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog_answers:edit:261:{ ; Triggered by entering text into hint box did -t cq_dialog_answers 205 } on *:dialog:cq_dialog_answers:sclick:205:{ ; Triggered by clicking the hint button describe $active HINT: $did(cq_dialog_answers,261).text did -f cq_dialog_answers 261 did -c cq_dialog_answers 261 1 1 $did(cq_dialog_answers,261).len } ; Player Management dialog box ; Buttons 401-430 ; Text 431-460 ; Edit 461-480 ; Box 481-500 ; Checkbox 501-520 ; List 521-540 dialog cq_dialog_players { title "Player List" size 468 255 152 220 button "",2900, 0 0 0 0, cancel button "",2901, 0 0 0 0, ok list 521, 3 3 147 235, vsbar } alias cq_update_players { ; Alias to update player management box ; ; cq_update_players takes no arguments ; if ($dialog(cq_dialog_players).title != $null) { did -r cq_dialog_players 521 var %loopcounter = 1 while (%loopcounter <= %cq_total_players) { var %nick = %cq_player_ [ $+ [ %loopcounter ] $+ _nick ] var %score = %cq_player_ [ $+ [ %loopcounter ] $+ _score ] if (%score < 10) { var %leadingzero = 0 } else { var %leadingzero = $null } did -a cq_dialog_players 521 %leadingzero $+ %score - %nick inc %loopcounter } } } ; Player list dialog box events on *:dialog:cq_dialog_players:sclick:2900:{ ; Triggered when players dialog box is shut via (X) button did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog_players:sclick:521:{ ; Triggered by clicking player management listbox did -r cq_dialog 71 did -a cq_dialog 71 %cq_player_ [ $+ [ $did(cq_dialog_players,521).sel ] $+ _nick ] } ; Reference information ; Variables ; --------- ; %cq_active_channel - channel in which questions are being asked ; %cq_mirc_directory - your mIRC directory ; %cq_script_name - file name of script (cosmoquiz.txt by default) ; %cq_file_name - path and file name of current question file ; %cq_file_lines - number of lines in current question file ; %cq_file_questions - number of questions in current question file ; %cq_scoreboard - Display scoreboard after each question (ON/OFF) ; %cq_asked_total - total number of questions asked from question file ; %cq_total_players - total players with a score ; %cq_asked_# - has question # been asked? (TRUE/FALSE) ; %cq_pointer - current question number ; %cq_question - current question ; %cq_answer - current answer ; %cq_previewed - has the next question been previewed? (TRUE/FALSE) ; %cq_random - randomly select question? (TRUE/FALSE) ; %cq_moderate - moderate channel on final scoreboard if op? (TRUE/FALSE) ; %cq_player_#_host - hostmask for player with ID = # ; %cq_player_#_nick - nickname for player with ID = # ; %cq_player_#_score - current score for player ID = # ; %cq_hostid_????? - ID number for player with hostmask ????? ; %cq_nickid_????? - ID number for player with nick ????? ; %cq_player_ial_?? - Has IAL been updated for player with nick ?? (TRUE/FALSE) ; ; ; Aliases ; ------- ; cq_unload - clear all variables, unload from memory ; cq_loadfile - load in a question file (dialog or command line) ; cq_preview - previews the next question to be asked ; cq_jump - jumps to a specific question number ; cq_skip - skip the current question permanently ; cq_ask - ask a question (from file or from command line) ; cq_repeat - repeat the current question ; cq_ans - answer question (from file or from command line) ; cq_toggle_scoreboard - toggle %cq_scoreboard ON/OFF ; cq_toggle_moderate - toggle moderate on final scores if op ON/OFF ; cq_toggle_random - toggle random question selection ON/OFF ; cq_scores - display simple scoreboard (called from cq_ans) ; cq_scores_final - display final scores at end of round ; cq_scores_reset - reset scores (as at end of a round) ; cq_player_add - add 1 point to a player's score ; cq_player_sub - subtract 1 point from a player's score ; cq_player_delete - remove a player from the scoreboard ; cq_sort - simple bubble sort routine to order scoreboard ; cq - open/close dialog box interface ; cq_update_qfilestat - update question parameters on main dialog box ; cq_update_preview - update question preview on main dialog box ; cq_update_answerstat - update parameters on answer dialog box ; cq_update_players - update player management box