; ; Cosmoquiz v1.40 beta ; ; by Cosmos (cosmos_42@yahoo.com.au) ; ; Last modified 15/06/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: { ; Default options follow - change these variables to customise %cq_mirc_directory = $mircdir %cq_script_name = cosmoquiz.txt %cq_toggle_scoreboard = TRUE %cq_toggle_random = TRUE %cq_toggle_moderate = FALSE %cq_toggle_autoreset = TRUE %cq_toggle_warnreset = TRUE %cq_toggle_qvalue = FALSE %cq_toggle_notify = FALSE %cq_toggle_multi = FALSE %cq_toggle_autoaward = FALSE %cq_qvalue = 1 %cq_penalty = 0 %cq_target = 10 %cq_multi_number = 3 %cq_multi_qvalue = 3 %cq_multi_decrease = 1 ; End user customisable variables - do not touch the ones below :-) .ial on .disable #cq_answermode %cq_previewed = FALSE if ($version < 5.82) { echo 4 -a *** Sorry, this script requires mIRC v5.82 or later cq_unload } echo 4 -a *** Cosmoquiz loaded: type /cq to invoke dialog box } 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 } if ($dialog(cq_dialog_scores).title != $null) { dialog -x cq_dialog_scores cq_dialog_scores } echo 4 -a *** Cosmoquiz unloaded .ial off var %tounload = %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 ; if (%cq_toggle_warnreset == TRUE) { beep var %sure = $?!="Are you sure you want to reset scores?" } else { var %sure = $true } if (%sure == $true) { 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 ; if ($exists($1) == $true) { var %tempfile = $1 } else { var %tempfile = $$dir="Please select file to open" [ [ %cq_mirc_directory ] $+ ] *.txt } if (%tempfile != $null) { %cq_file_name = %tempfile 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_toggle_random == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) } } else { if ((%cq_pointer < 1) || (%cq_pointer >= %cq_file_questions)) { %cq_pointer = 1 } while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { inc %cq_pointer } } %cq_question_preview = $read -nl [ $+ [ $calc((%cq_pointer * 2)-1) ] ] %cq_file_name %cq_answer_preview = $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_preview ] echo 4 -a Answer : [ %cq_answer_preview ] } } } 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_preview = $read -nl [ $+ [ $calc((%cq_pointer * 2)-1) ] ] %cq_file_name %cq_answer_preview = $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_preview ] echo 4 -a Answer : [ %cq_answer_preview ] } } 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 (%cq_toggle_multi == TRUE) { %cq_qvalue_current = %cq_multi_qvalue } else { %cq_qvalue_current = %cq_qvalue } %cq_multi_answered = 0 %cq_multi_scorestring = $null 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_toggle_random == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) while (%cq_asked_ [ $+ [ %cq_pointer ] ] == TRUE) { %cq_pointer = $rand(1,%cq_file_questions) } } else { if ((%cq_pointer < 1) || (%cq_pointer >= %cq_file_questions)) { %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 } } else { %cq_question = %cq_question_preview %cq_answer = %cq_answer_preview } if (%cq_toggle_qvalue == TRUE) { var %points = ( $+ [ %cq_qvalue_current ] Pts) if (%cq_qvalue_current == 1) { %points = $left(%points, -2) $+ ) } } else { var %points = $null } describe $active [ %points ] 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 ; if (%cq_toggle_qvalue == TRUE) { var %points = ( $+ [ %cq_qvalue_current ] Pts) if (%cq_qvalue_current == 1) { %points = $left(%points, -2) $+ ) } } else { var %points = $null } describe $active [ %points ] Q: (Repeat) %cq_question } alias cq_hint { ; ; Alias to give players a hint ; ; Usage /cq_hint Hint ; dec %cq_qvalue_current %cq_penalty if (%cq_qvalue_current <= 0) { %cq_qvalue_current = 1 } if (%cq_toggle_qvalue == TRUE) { var %points = ( $+ [ %cq_qvalue_current ] Pts) if (%cq_qvalue_current == 1) { %points = $left(%points, -2) $+ ) } } else { var %points = $null } describe $active [ %points ] HINT: [ $1- ] } 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 if ($1 == $null) { describe $active The correct answer was: [ %cq_answer ] if (%cq_toggle_scoreboard == TRUE) { cq_scores } } elseif ($address($1, 3) == $null) { echo 4 -a *** Sorry, [ $1 ] is not in [ $active ] or has not spoken } else { if (%cq_toggle_qvalue == TRUE) { var %points = ( $+ [ %cq_qvalue_current ] Pts) if (%cq_qvalue_current == 1) { %points = $left(%points, -2) $+ ) } } else { var %points = $null } if (%cq_toggle_multi == TRUE) { %cq_multi_scorestring = [ %cq_multi_scorestring ] [ $ial($address($1, 3)).nick ] $+ < $+ [ %cq_qvalue_current ] $+ > $+ , } else { describe $active < [ $ial($address($1, 3)).nick ] > !!!!! [ %points ] Answer: [ %cq_answer ] } 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 ] = %cq_qvalue_current %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_qvalue_current %cq_player_ [ $+ [ %lookup_player ] $+ _nick ] = $ial($address($1, 3), 1).nick } if ((%cq_toggle_scoreboard == TRUE) && (%cq_toggle_multi == FALSE)) { cq_scores } } if (%cq_toggle_multi == FALSE) { cq_check_target } } alias cq_award { if (%cq_multi_answered == 0) { cq_ans } else { var %loop = 1 while (%loop <= %cq_multi_answered) { var %winner = $gettok($did(cq_dialog_answers,322,%loop).text, 1, 32) %cq_qvalue_current = $gettok($did(cq_dialog_answers,322,%loop).text, 2, 32) cq_ans %winner inc %loop } describe $active Well done [ $left(%cq_multi_scorestring,-1) ] !!!!! describe $active Answer: [ %cq_answer ] } if (%cq_toggle_scoreboard == TRUE) { cq_scores } .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 cq_check_target } alias cq_check_target { if ((%cq_toggle_notify == TRUE) && (%cq_player_target != TRUE)) { var %highscore = %cq_player_1_score var %highnick = %cq_player_1_nick if (%highscore >= %cq_target) { %cq_player_target = TRUE beep var %sure = $?!=" [ %highnick ] has reached target of [ %cq_target ] - show scores?" if (%sure == $true) { cq_scores_final } } } } alias cq_toggle { ; ; Alias to toggle various options TRUE/FALSE ; ; cq_toggle takes the option to toggle as an argument ; if (%cq_toggle_ [ $+ [ $1 ] ] == TRUE) { %cq_toggle_ [ $+ [ $1 ] ] = FALSE echo 4 -a *** [ $1 ] is now set to FALSE } else { %cq_toggle_ [ $+ [ $1 ] ] = TRUE echo 4 -a *** [ $1 ] is now set to TRUE } } 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_toggle_moderate == TRUE)) { mode $active +m var %mod_delay 1 } else { var %mod_delay 0 } .timer 1 %mod_delay describe $active ---- FINAL SCORES ---- 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 + 2) mode $active -m } if (%cq_toggle_autoreset == TRUE) { cq_scores_reset } } 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 } cq_check_target } 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_preview did -a cq_dialog 62 %cq_answer_preview did -c cq_dialog 61 1 did -c cq_dialog 62 1 } alias cq_update_answerstat { ; ; Alias to update data on answer dialog box ; did -r cq_dialog_answers 232 did -r cq_dialog_answers 234 did -r cq_dialog_answers 262 did -a cq_dialog_answers 232 %cq_question did -a cq_dialog_answers 234 %cq_answer did -a cq_dialog_answers 262 %cq_qvalue_current } ; 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.40 beta http://www.geocities.com/cosmos_42/" size 20 105 600 120 button "",1000, 0 0 0 0, ok button "",1001, 0 0 0 0, cancel box "",81, -5 68 610 10 text "Q:",47,75 79 15 15 edit %cq_question_preview,61,95 79 505 21, autohs text "A:",48,75 100 15 15 edit %cq_answer_preview,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,160 1 55 22 button "Answer",3,90 25 60 20 button "Jump...",4,90 2 60 20 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 button "More options...",14,310 52 107 22 text "Score Management",59, 305 1 140 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_toggle_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:1001:{ ; 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 } if ($dialog(cq_dialog_scores).title != $null) { dialog -x cq_dialog_scores cq_dialog_scores } } 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_preview = $did(cq_dialog, 61).text %cq_answer_preview = $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 -r cq_dialog_answers 321 did -r cq_dialog_answers 322 did -f cq_dialog_answers 261 } else { cq_update_answerstat did -r cq_dialog_answers 321 did -r cq_dialog_answers 322 } } } on *:dialog:cq_dialog:sclick:2:{ ; Triggered when "Load" button is pressed cq_loadfile cq_update_qfilestat did -r cq_dialog 61 did -r cq_dialog 62 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 cq_scores_reset did -f cq_dialog 1 } on *:dialog:cq_dialog:sclick:14:{ ; Triggered when "More options..." button is pressed under score management if ($dialog(cq_dialog_scores).title == $null) { dialog -m cq_dialog_scores cq_dialog_scores } else { dialog -x cq_dialog_scores cq_dialog_scores } } 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 430 180, vsbar list 322, 430 30 100 180 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 edit %cq_qvalue_current, 262, 573 34 25 25 text "Value", 236, 533 37 40 25 button "Award",201, 533 64 64 23 button "Clr Ans",202, 533 90 64 23 button "Clr Nick", 206, 533 116 64 23 button "Repeat Q:",203, 533 142 64 23 button "Give A:",204, 533 168 64 23 button "Give hint",205, 533 195 64 23 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) if (%cq_toggle_multi == FALSE) { 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 } elseif (%cq_multi_answered < %cq_multi_number) { var %loop2 = 1 var %answered = FALSE while (%loop2 <= %cq_multi_answered) { var %winner2 = $gettok($did(cq_dialog_answers,322,%loop2).text, 1, 32) if (%winner2 == %winner) { %answered = TRUE } inc %loop2 } if (%answered == FALSE) { did -a cq_dialog_answers 322 %winner %cq_qvalue_current inc %cq_multi_answered dec %cq_qvalue_current %cq_multi_decrease did -r cq_dialog_answers 262 did -a cq_dialog_answers 262 %cq_qvalue_current if ((%cq_toggle_autoaward == TRUE) && (%cq_multi_answered >= %cq_multi_number)) { cq_award } } } } on *:dialog:cq_dialog_answers:sclick:201:{ ; Triggered by clicking the "Award" button cq_award } on *:dialog:cq_dialog_answers:sclick:202:{ ; Triggered by clicking the "Clr Ans" 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:sclick:206:{ ; Triggered by clicking the "Clr Nick" button did -r cq_dialog_answers 322 %cq_multi_answered = 0 %cq_qvalue_current = %cq_multi_qvalue did -a cq_dialog_answers 206 %cq_qvalue_current } 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:edit:262:{ ; Triggered by changing value of current question if (($did(cq_dialog_answers, 262).text isnum 1-99) && ($did(cq_dialog_answers, 262).text >= %cq_penalty)) { %cq_qvalue_current = $did(cq_dialog_answers, 262).text } else { did -r cq_dialog_answers 262 } } on *:dialog:cq_dialog_answers:sclick:205:{ ; Triggered by clicking the hint button cq_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 cq_update_answerstat } ; 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 ] } ; More options Scoreboard Management dialog box ; Buttons 600-630 ; Text 631-660 ; Edit 661-680 ; Box 681-700 ; Checkbox 701-720 ; List 721-740 dialog cq_dialog_scores { title "More Scoreboard Options" size 138 255 324 220 button "",2902, 0 0 0 0, cancel button "",2903, 0 0 0 0, ok ; COLUMN 1------------------------------------- check "Show running scores",701,1 1 155 20 check "Moderate chan on final",702,1 20 155 20 check "Reset scores on final", 704, 1 40 155 20 check "Reset scores warning", 705, 1 60 155 20 box "",681,-10 75 330 10 edit %cq_qvalue, 661, 1 90 25 23 text "Initial value of Q:",631, 32 93 120 23 edit %cq_penalty, 662, 1 115 25 23 text "Hint penalty",632, 32 119 120 23 check "Show question value", 703, 1 142 150 20 box "",682,-10 155 330 10 check "Notify Target Score", 706, 1 170 155 20 edit %cq_target, 663, 1 193 30 23 text "Target Score",633, 35 196 120 23 box "", 683, 155 -10 2 240 ; COLUMN 2------------------------------------- check "Enable Multi-mode",710,165 1 155 20 check "Autoaward winners",711,165 25 155 20 edit %cq_multi_qvalue, 670, 165 95 25 23 text "Initial value of Q:", 640, 195 98 125 23 edit %cq_multi_decrease, 671, 165 125 25 23 text "Decrease Q: value", 641, 195 128 125 23 edit %cq_multi_number, 672, 165 180 25 23 text "Maximum winners", 642, 195 183 125 23 } ; Scoreboard more options events on *:dialog:cq_dialog_scores:init:0:{ if (%cq_toggle_scoreboard == TRUE) { did -c cq_dialog_scores 701 } if (%cq_toggle_moderate == TRUE) { did -c cq_dialog_scores 702 } if (%cq_toggle_qvalue == TRUE) { did -c cq_dialog_scores 703 } if (%cq_toggle_autoreset == TRUE) { did -c cq_dialog_scores 704 } if (%cq_toggle_warnreset == TRUE) { did -c cq_dialog_scores 705 } if (%cq_toggle_notify == TRUE) { did -c cq_dialog_scores 706 } if (%cq_toggle_multi == TRUE) { did -c cq_dialog_scores 710 did -b cq_dialog_scores 631,632,661,662,703 } else { did -b cq_dialog_scores 640,641,642,670,671,672,711 } if (%cq_toggle_autoaward == TRUE) { did -c cq_dialog_scores 711 } } on *:dialog:cq_dialog_scores:sclick:2902:{ ; Triggered when scores dialog box is shut via (X) button did -t cq_dialog 1 did -f cq_dialog 1 } on *:dialog:cq_dialog_scores:edit:661:{ ; Triggered by editing question value box if (($did(cq_dialog_scores, 661).text isnum 1-99) && ($did(cq_dialog_scores, 661).text >= %cq_penalty)) { %cq_qvalue = $did(cq_dialog_scores, 661).text } else { did -r cq_dialog_scores 661 } } on *:dialog:cq_dialog_scores:edit:662:{ ; Triggered by editing penalty box if (($did(cq_dialog_scores, 662).text isnum 0-99) && ($did(cq_dialog_scores, 662).text <= %cq_qvalue)) { %cq_penalty = $did(cq_dialog_scores, 662).text } else { did -r cq_dialog_scores 662 } } on *:dialog:cq_dialog_scores:edit:663:{ ; Triggered by editing target score if ($did(cq_dialog_scores, 663).text isnum 1-999) { %cq_target = $did(cq_dialog_scores, 663).text } else { did -r cq_dialog_scores 663 } } on *:dialog:cq_dialog_scores:edit:670:{ ; Triggered by changing multi-mode initial question value if (($did(cq_dialog_scores, 670).text isnum 1-99) && ($did(cq_dialog_scores, 670).text >= $calc(%cq_multi_decrease * %cq_multi_number))) { %cq_multi_qvalue = $did(cq_dialog_scores, 670).text } else { did -r cq_dialog_scores 670 } } on *:dialog:cq_dialog_scores:edit:671:{ ; Triggered by changing multi-mode decrease question value if (($did(cq_dialog_scores, 671).text isnum 0-99) && ($calc($did(cq_dialog_scores, 671).text * %cq_multi_number) <= %cq_multi_qvalue)) { %cq_multi_decrease = $did(cq_dialog_scores, 671).text } else { did -r cq_dialog_scores 671 } } on *:dialog:cq_dialog_scores:edit:672:{ ; Triggered by changing multi-mode max winners question value if (($did(cq_dialog_scores, 672).text isnum 2-9) && ($calc($did(cq_dialog_scores, 672).text * %cq_multi_decrease) <= %cq_multi_qvalue)) { %cq_multi_number = $did(cq_dialog_scores, 672).text } else { did -r cq_dialog_scores 672 } } on *:dialog:cq_dialog_scores:sclick:701:{ ; ; Triggered when "show running scores" checkbox is clicked ; cq_toggle scoreboard } on *:dialog:cq_dialog_scores:sclick:702:{ ; ; Triggered when "moderate chan on final" checkbox is clicked ; cq_toggle moderate } on *:dialog:cq_dialog_scores:sclick:703:{ ; ; Triggered when "show question value" checkbox is clicked ; cq_toggle qvalue } on *:dialog:cq_dialog_scores:sclick:704:{ ; ; Triggered when "reset scores on final" checkbox is clicked ; cq_toggle autoreset } on *:dialog:cq_dialog_scores:sclick:705:{ ; ; Triggered when "reset scores warning" checkbox is clicked ; cq_toggle warnreset } on *:dialog:cq_dialog_scores:sclick:706:{ ; ; Triggered when "Notify target score" checkbox is clicked ; cq_toggle notify } on *:dialog:cq_dialog_scores:sclick:710:{ ; ; Triggered when "Enable Multi-Mode" checkbox is clicked ; cq_toggle multi if (%cq_toggle_multi == TRUE) { did -e cq_dialog_scores 640,641,642,670,671,672,711 did -r cq_dialog_scores 662 %cq_penalty = 0 %cq_toggle_qvalue = FALSE did -u cq_dialog_scores 703 did -a cq_dialog_scores 662 0 did -b cq_dialog_scores 631,632,661,662,703 } else { did -b cq_dialog_scores 640,641,642,670,671,672,711 did -e cq_dialog_scores 631,632,661,662,703 } } on *:dialog:cq_dialog_scores:sclick:711:{ ; ; Triggered when "Autoaward" checkbox is clicked ; cq_toggle autoaward } ; 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_toggle_scoreboard- Display scoreboard after each question (TRUE/FALSE) ; %cq_toggle_autoreset - Reset scores automatically on final (TRUE/FALSE) ; %cq_toggle_warnreset - Warn operator before scores reset(TRUE/FALSE) ; %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_preview - current question being previewed ; %cq_answer_preview - answer to question being previewed ; %cq_question - current question ; %cq_answer - current answer ; %cq_previewed - has the next question been previewed? (TRUE/FALSE) ; %cq_toggle_random - randomly select question? (TRUE/FALSE) ; %cq_toggle_moderate - moderate channel on final scores if op(TRUE/FALSE) ; %cq_qvalue - Value of each question ; %cq_penalty - Penalty for each hint ; %cq_target - Value of target score (e.g. first to 10 questions) ; %cq_toggle_notify - Notify that player has reached target (TRUE/FALSE) ; %cq_qvalue_current - Value of current question ; %cq_toggle_qvalue - Display value of question with question/hint ; %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_player_target - has a player reached target (TRUE/FALSE) ; %cq_hostid_????? - ID number for player with hostmask ????? ; %cq_nickid_????? - ID number for player with nick ????? ; %cq_player_ial_?? - Has IAL 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_hint - give players a hint ; cq_ans - answer question (from file or from command line) ; cq_toggle - toggle various options TRUE/FALSE ; cq_toggle_moderate - toggle moderate on final scores if op TRUE/FALSE ; cq_toggle_random - toggle random question selection TRUE/FALSE ; cq_toggle_autoreset - toggle autoreset of scores on final TRUE/FALSE ; cq_toggle_warnreset - toggle warning user of score reset TRUE/FALSE ; cq_toggle_notify - toggle target score notification TRUE/FALSE ; cq_check_target - check whether any player has reached target ; 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