Enigma Bot — File Browser

EnigmaBotv1.4 / EnigmaBotv1.4 / Enigma versione1_4 / Trivia2.mrc

Trivia2.mrc — 34.19 KB — Download this file

;;;Trivia by SlipknoT aka StonedStoner;;; 
;Trivia modificato da sonoio
;aggiunto nuovi giochi e aiuti in sequenza

on *:JOIN:%game_channel: {
  if (%trivia == on) {
    var %f2r = 8,4 $nick $+ 's 
    var %f0 = 0,12 Il tuo posto in classifica:
    var %f1 = 4,8 Oggi:
    var %f2 = 0,12 $iif($triv_read(scoresday, $nick) != $NULL,$triv_read(scoresday, $nick),0) Punti
    var %s1 = 4,8 Questa Settimana:
    var %s2 = 0,12 $iif($triv_read(scoresweek, $nick) != $NULL,$triv_read(scoresweek, $nick),0) Punti
    var %m1 = 4,8 Questo Mese:
    var %m2 = 0,12 $iif($triv_read(scoresmonth, $nick) != $NULL,$triv_read(scoresmonth, $nick),0) Punti
    var %all1 = 4,8 Classifica Generale
    var %all2 = 0,12 $iif($triv_read(scoresall, $nick) != $NULL,$triv_read(scoresall, $nick),0) Punti 
    .notice $nick %f2r %f0 %f1 %f2 %s1 %s2 %m1 %m2 %all1 %all2 
  }
}

on *:TEXT:*:%game_channel: {
  set %triv.text $strip($1-,c)
  if (%triv.text == !via) {
    trivia 0
  } 

  if (%triv.text == ^autori) {
    /notice $nick Il creatore di questo BOT e' sonoio e ilaria79
  } 

  if (%triv.text == !ferma) {
    trivia_off
  }
  if (%triv.text == ^) {
    var %c, %d = $regsub(%trivia.a,/([adglmpsZ347])/ig,*,%c)
    /notice $nick 4 %c
    return %c 
  } 

  if (%triv.text == ^versione) {
    /notice $nick la versione del bot e' Enigma 1.4 
  }
  if (%triv.text == %trivia.a) {
    if (%answered == yes) {
      halt
    }

    set %answered yes
    .timer 1 %tempodomanda  trivia.next
    trivia.answered $nick
    unset %trivia.a
    set %trivia.qn $calc(%trivia.qn + 1)
  } 
  if ($1 == !classifica) {
    if ($2 == day) { triviascoreday }
    elseif ($2 == week) { trivscoresweek | trivscoresweek20 }
    elseif ($2 == month) { trivscoresmonth | trivscoresmonth20 }
    elseif ($2 == all) { trivscoresall | trivscoresall20 }
  }
  if ($1 == !punti) {
    punteggio $2
  } 
}
alias trivia_off { .timerhint* off | set %trivia off | msg %game_channel $trivtalk(Fine Della Partita! Trivia Fermato.) } 

;alias avvisi {
;  if (%counta_a == 10 ) { .timer_avv 1 3 triviascoreday }
;  elseif ( %counta_a == 20 ) { .timer_avv 1 3 trivscoresweek }
;  elseif ( %counta_a == 30 ) { .timer_avv 1 3 trivscoresweek20 }
;  elseif ( %counta_a == 40 ) { .timer_avv 1 3 trivscoresmonth }
;  elseif ( %counta_a == 50 ) { .timer_avv 1 3 trivscoresmonth20 }
;  elseif ( %counta_a == 60 ) { .timer_avv 1 3 trivscoresall }
;  elseif ( %counta_a == 70 ) { .timer_avv 1 3 trivscoresall20 }
;  elseif ( %counta_a > 70 ) { set %counta_a 0 }
;}




alias avvisi {
  if ( %counta_a == 10 ) { .timer_avv 1 3  msg %game_channel 9I comandi : trivscoresweek !quiz - !fermaquiz - Per il punteggio : !classifica all - !classifica week - !classifica day  }
  elseif (%counta_a == 20 ) { .timer_avv 1 3 triviascoreday }
  elseif ( %counta_a == 30 ) { .timer_avv 1 3 trivscoresweek }
  elseif ( %counta_a == 40 ) { .timer_avv 1 3 msg %game_channel 9I comandi : !quiz - !fermaquiz - Per il punteggio : !classifica all - !classifica week - !classifica day  }
  elseif ( %counta_a == 50 ) { .timer_avv 1 3 trivscoresmonth }
  elseif ( %counta_a == 60 ) { .timer_avv 1 3 msg %game_channel 9I comandi : !quiz - !fermaquiz - Per il punteggio : !classifica all  - !classifica week - !classifica day }
  elseif ( %counta_a == 70 ) { .timer_avv 1 3 trivscoresall }
  elseif ( %counta_a == 80 ) { .timer_avv 1 3 msg %game_channel 9I comandi : !quiz - !fermaquiz - Per il punteggio : !classifica all - !classifica week - !classifica day }
  elseif ( %counta_a > 80 ) { set %counta_a 0 }
}



alias trivia.answered { 
  if ($1 == $null) { halt } 
  else { 
    var %temp = $triv_read(settings, utonto) 
    if (%temp == $1) {
      var %temp = $triv_read(settings, consecutive)
      inc %temp
      triv_write settings consecutive %temp

      if (%temp == $triv_read(settings, consbonus1cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus1punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Sempre piu' in altooOOoo!! )  
        inc %trivia.p $triv_read(settings, consbonus1punti)
      }
      elseif (%temp == $triv_read(settings, consbonus2cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus2punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Molto bene!! )  
        inc %trivia.p $triv_read(settings, consbonus2punti)
      }
      elseif (%temp == $triv_read(settings, consbonus3cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus3punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Complimenti!! )  
        inc %trivia.p $triv_read(settings, consbonus3punti)
      }
      elseif (%temp == $triv_read(settings, consbonus4cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus4punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Olèèèè!! )  
        inc %trivia.p $triv_read(settings, consbonus4punti)
      }
      elseif (%temp == $triv_read(settings, consbonus5cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus5punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Benissimoooo!! )  
        inc %trivia.p $triv_read(settings, consbonus5punti)
      }
      elseif (%temp == $triv_read(settings, consbonus6cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus6punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Fantasticooo!! )  
        inc %trivia.p $triv_read(settings, consbonus6punti)
      }
      elseif (%temp == $triv_read(settings, consbonus7cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus7punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! `O.o´ Forteeee!! )  
        inc %trivia.p $triv_read(settings, consbonus7punti)
      }
      elseif (%temp == $triv_read(settings, consbonus8cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus8punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Meravigliosoo!! )  
        inc %trivia.p $triv_read(settings, consbonus8punti)
      }
      elseif (%temp == $triv_read(settings, consbonus9cons)) {
        .timerhintcons 1 1 msg %game_channel $1 $trivtalk(Vince un Bonus Di) $triv_read(settings, consbonus9punti) $trivtalk(Punti Per) %temp $trivtalk(Risposte consecutive! Wooowwww !! )  
        inc %trivia.p $triv_read(settings, consbonus9punti)
      }
    }
    else { triv_write settings consecutive 1
      triv_write settings utonto $1
    }
    .timerhintrisp -m 1 1 msg %game_channel 9 $+ $esatto -7 $1 $trivtalk(Ha dato la risposta:) $+ 4 %trivia.a $trivtalk(In) $+ 7 $duration($calc($ctime - %trivia.el)) $trivtalk(E Guadagna) $+ 4 %trivia.p $trivtalk(Punti.) $trivtalk(Risposte consecutive:) $+ 9 $triv_read(settings, consecutive)
    var %temp = $calc($triv_read(scoresday, $1) + %trivia.p)
    triv_write scoresday $1 %temp
    var %temp = $calc($triv_read(Scoresweek, $1) + %trivia.p)
    triv_write scoresweek $1 %temp
    var %temp = $calc($triv_read(Scoresmonth, $1) + %trivia.p)
    triv_write scoresmonth $1 %temp
    var %temp = $calc($triv_read(Scoresall, $1) + %trivia.p)
    triv_write scoresall $1 %temp 
    .timerhintanswered -m 1 500 msg %game_channel $trivtalk(Totale Punti Di:) $trivtalk(Oggi:) $+ 3 $triv_read(scoresday, $1) $trivtalk(punti <> in Questa Settimana:) $+ 3 $triv_read(Scoresweek, $1) $trivtalk(punti <> in Questo Mese:) $+  3 $triv_read(Scoresmonth, $1) $trivtalk(punti <> In classifica generale:) $+  3 $triv_read(scoresall, $1) $trivtalk(punti.) 


    trivpos20 $1
    $avvisi 


  }
}
alias esatto { goto $rand(1,9)
  :1 | return OLèèè | goto end
  :2 | return SIIIIIIIIIIII | goto end
  :3 | return OPPeBBaCCo Esatto!! | goto end
  :4 | return YeP ^^ | goto end
  :5 | return Incredible aSd!! | goto end
  :6 | return Yeahhh... modestamente!! | goto end
  :7 | return PaZZeSCo..Complimenti !! | goto end
  :8 | return Eccuu Fantastico!! | goto end
  :9 | return Che (_!_).. | goto end
  :end
}
alias trivia { 
  if (!$exists( " $+ $mircdir $+ triviascores.ini $+ " )) {
    triv_write settings daytime 1257634800
    triv_write settings weektime 1257116400
    triv_write settings monthtime 1259622000
  }
  if (%trivia == on) { HALT } 
  else { 
    if ($1 == 0) { 
      msg %game_channel $trivtalk(Trivia Avviato! Partirà tra %tempodomanda secondi... State Pronti!)
      set %counta_a 0
      set %trivia.max un 
      set %trivia on 
      set %question-bonus $rand(50,100)
      .timerhinta 1 %tempodomanda trivia.next 
    } 
  }
}
alias trivia.next {
  inc %maxi.p
  reset_times
  if (%trivia = off) {
    halt
  }
  else { 
    inc %avvia.zigzag_start
    if ( %avvia.zigzag_start >= 30 ) { zigzag_start | unset %avvia.zigzag_start | halt }
    else {
      inc %avvia.sillaba_start
      if ( %avvia.sillaba_start >= 25 ) { sillaba_start | unset %avvia.sillaba_start | halt }
      else {
        inc %avvia.numero_mania
        if ( %avvia.numero_mania >= 8 ) { numero_mania | unset %avvia.numero_mania | halt }
        else {
          inc %avvia.kaos
          if ( %avvia.kaos >= 14 ) { kaos | unset %avvia.kaos | halt }
          else {
            inc %counta_a
            set %trivia.rand $rand(1,$lines(trivia.txt)) 
            set %trivia.n $read(trivia.txt,%trivia.rand) 
            set %trivia.q $gettok($read(trivia.txt,%trivia.rand),1,42) 
            set %trivia.a $gettok($read(trivia.txt,%trivia.rand),2,42) 
            set %trivia.hmio $trivhint(%trivia.a,0,*)
            set %trivia.h1 $trivhint(%trivia.a,1,*) 
            set %trivia.h2 $trivhint(%trivia.a,2,*)
            set %trivia.h3 $trivhint(%trivia.a,3,*) 
            ;      set %trivia.h4 $trivhint(%trivia.a,4,*) 
            if (%maxi.p >= %random1) {
              bonus1
              unset %trivia.n
              msg %game_channel 8¤¤¤¤¤JackPot¤¤¤¤¤ 9 %trivia.q 7 Risposta Da 8 %trivia.p 8Punti
              echo %game_channel Private Answer:4 %trivia.a 
              msg %game_channel 9Lettere:  %trivia.hmio
              set %trivia.el $ctime 
              unset %answered
              unset %maxi.p
              set %random1 $rand(30,55)
            }
            else {
              set %trivia.p $rand(3000,7000)
              unset %trivia.n
              echo %game_channel Private Answer:4 %trivia.a


              ;originale
              msg %game_channel  $+ %c1 — [ %trivia.qn $+  $+ %c1 ] —] 0,1 $+ %trivia.q $+  [—     $+ $trivtalk(Risposta Da)  $+ 4 %trivia.p  $trivtalk(Punti)  


              msg %game_channel   $trivtalk(Lettere:)  %trivia.hmio
              set %trivia.el $ctime
              unset %answered
            }
            .timerhint1 1 %tempoaiuto hint1
            .timerhint2 1 $calc((%tempoaiuto)*2) hint2
            .timerhint3 1 $calc((%tempoaiuto)*3) hint3
            .timerq 1 $calc((%tempoaiuto)*4) trivia.unanswered
          } 
        }
      }
    }
  }
}

;alias bonus1 { goto $rand(1,9)
alias bonus1 { goto $rand(1,9)
  :1 | set %trivia.p 50000 | goto end
  :2 | set %trivia.p 55000 | goto end
  :3 | set %trivia.p 60000 | goto end
  :4 | set %trivia.p 65000 | goto end
  :5 | set %trivia.p 80000 | goto end
  :6 | set %trivia.p 85000 | goto end
  :7 | set %trivia.p 90000 | goto end
  :8 | set %trivia.p 95000 | goto end
  :9 | set %trivia.p 100000 | goto end
  :end
}

alias trivia.unanswered {
  if (%answered == yes) {
    halt
  }
  msg %game_channel  $trivtalk(La Risposta Era:)  %trivia.a 
  set %trivia.qn $calc(%trivia.qn + 1)
  set %trivia.a ambarabacciccco
  triv_rem settings consecutive
  triv_rem settings utonto
  $avvisi
  .timer 1 %tempodomanda trivia.next
}

alias trivhint { 
  var %a, %b = $regsub($1,/(?<=\S{ $+ $2})\S/g,$replace($$3,\,\\,$,\$),%a) 
  return %a 
}


alias hint1 {
  if (%answered == yes) {
    halt
  }
  else {
    ;set %trivia.h1 $aiuto-b()
    set %trivia.h1 $trivhint(%trivia.a,1,•) 

    set %trivia.p $int($calc((%trivia.p)-100))
    msg %game_channel  $trivtalk(Primo Aiuto:)  %trivia.h1 14-7 $calc((%tempoaiuto)*2) $trivtalk(secondi per rispondere) 14&4 %trivia.p $trivtalk(Punti) 
  }
}

alias hint2 {
  if (%answered == yes) {
    halt
  }
  else {
    ;set %trivia.h2 $aiuto-b()
    set %trivia.h2 $trivhint(%trivia.a,2,•)

    set %trivia.p $int($calc((%trivia.p)-500))
    msg %game_channel  $trivtalk(Secondo Aiuto:)  %trivia.h2 14-7 $calc((%tempoaiuto)*2) $trivtalk(secondi per rispondere) 14&4 %trivia.p $trivtalk(Punti) 
  }
}
alias hint3 {
  if (%answered == yes) {
    halt
  }
  else { 

    ;set %trivia.h4 $aiuto-c()
    set %trivia.h4 $trivhint(%trivia.a,4,•) 

    set %trivia.p $int($calc((%trivia.p)-1400))
    msg %game_channel  $trivtalk(Terzo Aiuto:)  %trivia.h4 14-7 %tempoaiuto $trivtalk(secondi per rispondere) 14&4 %trivia.p $trivtalk(Punti) 
  }
}

;$+ %c1 $+ 

on *:dialog:stre.bot:sclick:154: { 
  triv_resetweek
}

on *:dialog:stre.bot:sclick:155: { 
  triv_resetmonth
}

;did not make this talker;
;not sure where i got it but if someone knows tell me and i will give credit;

on *:disconnect: {
  set %trivia off
}
on *:exit: {
  set %trivia off
}

;====================Classifiche Varie=================
alias punteggio {
  if (%trivia = on) {
    var %f2r = 8,4 $nick $+ 's 
    var %f0 = 0,12 Il tuo posto in classifica:
    var %f1 = 4,8 Oggi:
    var %f2 = 0,12 $iif($triv_read(scoresday, $nick) != $NULL,$triv_read(scoresday, $nick),0) Punti
    var %s1 = 4,8 Questa Settimana:
    var %s2 = 0,12 $iif($triv_read(scoresweek, $nick) != $NULL,$triv_read(scoresweek, $nick),0) Punti
    var %m1 = 4,8 Questo Mese:
    var %m2 = 0,12 $iif($triv_read(scoresmonth, $nick) != $NULL,$triv_read(scoresmonth, $nick),0) Punti
    var %all1 = 4,8 Classifica Generale
    var %all2 = 0,12 $iif($triv_read(scoresall, $nick) != $NULL,$triv_read(scoresall, $nick),0) Punti 
    notice $nick %f2r %f0 %f1 %f2 %s1 %s2 %m1 %m2 %all1 %all2 
  }
}
;==================Reset Classifiche=================
alias reset_times {
  if ($ctime > $triv_read(settings, daytime)) || ($ctime > $calc($triv_read(settings, daytime) + 86400)) { trivresetday }
  if ($ctime > $triv_read(settings, monthtime)) || ($ctime > $calc($triv_read(settings, weektime) + 604800)) {
    if ($ctime > $triv_read(settings, monthtime)) {
      trivia_off
      trivresetmonth
    }
    if ($ctime > $calc($triv_read(settings, weektime) + 604800)) {
      trivia_off
      trivresetweek
    }
  }
}
;=================Reset tutte le classifiche==========
alias resetall {
  triv_resetday
  triv_resetweek
  triv_resetmonth
  triv_resetalltop 
}
;=================Reset I top dei top =================
alias triv_resetalltop {
  triv_rem scoresall
}
;========================
alias triviaregolamese {
  var %mon = $asctime($ctime,m)
  var %year = $asctime($ctime,yy)
  inc %mon
  if (%mon == 13) { %mon = 1 | inc %year }
  var %time = $ctime(1/ $+ %mon $+ / $+ %year)
  triv_write settings monthtime %time
}
;========================
alias trivresetmonth {
  triviaregolamese
  m
  triv_rem scoresmonth
  .timer_avv 1 2 trivia 0
}

alias triv_resetmonth {

  triv_rem scoresmonth
}
;========================
alias trivresetday {
  triv_rem scoresday

  var %addonday = $calc($triv_read(settings, daytime) + 86400)
  triv_write Settings daytime %addonday
  .timer_avv 1 2 trivia 0
}

alias triv_resetday {
  triv_rem scoresday
}
;========================
alias trivresetweek {
  triv_rem scoresweek

  var %addoneweek = $calc($triv_read(settings, weektime) + 604800)
  triv_write Settings weektime %addoneweek
  .timer_avv 1 2 trivia 0
}

alias triv_resetweek {

  triv_rem scoresweek
}
;====================Top 20===================== 
alias trivpos20 {
  var %nick = $1
  var %score = $triv_read(Scoresall, %nick)
  var %scores = $str(0 $+ $chr(32),20) 0
  var %nicks = $str(A $+ $chr(32),20) A
  var %totalplayers = $triv_readgetall(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $triv_readgetall(%index)
    var %thisscore = $triv_read(Scoresall, %thisnick)
    var %index2 = 1
    while (%index2 <= 20) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        ;echo -a $len($instok(%nicks,%thisnick,%index2,32)) 
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,21,32)
        var %nicks = $deltok(%nicks,21,32)
        var %index2 = 21
      }
      inc %index2
    }
    inc %index
  }
  var %pos = $findtok(%scores,%score,1,32)
  if (%pos == 1) {
    .timerhintanswered_a 1 1 msg %game_channel 4 %nick $trivtalk(E' in) $+ 4 #1 $trivtalk(Posizione.) 
  }
  elseif (%pos == $NULL) {
    var %thisscore = $triv_read(Scoresall, %nick)
    if (%thisscore == $NULL) { %thisscore = 0 }
    var %last = $findtok(%nicks,A,1,32)
    if (%last == $NULL) { %last = 21 }
    dec %last
    var %lastnick = $gettok(%nicks,%last,32)
    var %lastscore = $gettok(%scores,%last,32)
    .timerhintanswered_b 1 1 msg %game_channel $trivtalk(Ti Occorrono) $+ 7 $calc(%lastscore - %thisscore) $chr(3) $+ $trivtalk(Punti Per Superare il nick) $+ 7  $trivtalk(Che Occupa La) $+ 4 $chr(35) $+ %last $trivtalk(Posizione.) 
  }
  else {
    var %last = $calc(%pos - 1)
    var %lastnick = $gettok(%nicks,%last,32)
    var %lastscore = $gettok(%scores,%last,32)
    var %thisscore = $triv_read(Scoresall, %nick)
    .timerhintanswered_c 1 1 msg %game_channel $trivtalk(Ti Occorrono) $+ 7 $calc(%lastscore - %thisscore) $trivtalk(Punti Per Superare il nick) $+ 7  $trivtalk(Che Occupa La) $+ 4 $chr(35) $+ %last $trivtalk(Posizione.) 





    .timerhintanswered_d1 1 1 notice %nick $trivtalk(> Ti Occorrono) $+ 7 $calc(%lastscore - %thisscore) $trivtalk(Punti Per Superare) $+ 7 %lastnick $trivtalk(Che Occupa La) $+ 4 $chr(35) $+ %last $trivtalk(Posizione.) 






  }
}

;================Classifica Giorno
alias trivia_getday {
  return $ini(" $+ $scriptdir $+ triviascores $+ .ini $+ ", scoresday,$1)
}
alias triviascoreday {
  var %scores = 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $trivia_getday(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $trivia_getday(%index)
    var %thisscore = $triv_read(scoresday, %thisnick)
    var %index2 = 1
    while (%index2 <= 10) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,11,32)
        var %nicks = $deltok(%nicks,11,32)
        var %index2 = 11
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1
  var %c1a = $chr(3) $+ 0,6
  var %cl2b = $chr(3) $+ 0,10

  var %msg = %c1a I Top 10 di Oggi: %cl2b #1 %c1a $gettok(%nicks,1,32) $gettok(%scores,1,32) %cl2b #2 %c1a $gettok(%nicks,2,32) $gettok(%scores,2,32) %cl2b #3 %c1a $gettok(%nicks,3,32) $gettok(%scores,3,32) %cl2b #4 %c1a $gettok(%nicks,4,32) $gettok(%scores,4,32) %cl2b #5 %c1a $gettok(%nicks,5,32) $gettok(%scores,5,32) %cl2b #6 %c1a $gettok(%nicks,6,32) $gettok(%scores,6,32) %cl2b #7 %c1a $gettok(%nicks,7,32) $gettok(%scores,7,32) %cl2b #8 %c1a $gettok(%nicks,8,32) $gettok(%scores,8,32) %cl2b #9 %c1a $gettok(%nicks,9,32) $gettok(%scores,9,32) %cl2b #10 %c1a $gettok(%nicks,10,32) $gettok(%scores,10,32) 
  msg %game_channel %msg
}

;================Classifica Settimana
alias trivia_getweek {
  return $ini(" $+ $scriptdir $+ triviascores $+ .ini $+ ", scoresweek,$1)
}
alias trivscoresweek {
  var %scores = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $trivia_getweek(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $trivia_getweek(%index)
    var %thisscore = $triv_read(scoresweek, %thisnick)
    var %index2 = 1
    while (%index2 <= 20) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,21,32)
        var %nicks = $deltok(%nicks,21,32)
        var %index2 = 21
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1
  var %c1a = $chr(3) $+ 0,3
  var %cl2b = $chr(3) $+ 0,6

  var %msg = %cl2b I Top 10 di Questa Settimana: %c1a #1 %cl2b $gettok(%nicks,1,32) $gettok(%scores,1,32) %c1a #2 %cl2b $gettok(%nicks,2,32) $gettok(%scores,2,32) %c1a #3 %cl2b $gettok(%nicks,3,32) $gettok(%scores,3,32) %c1a #4 %cl2b $gettok(%nicks,4,32) $gettok(%scores,4,32) %c1a #5 %cl2b $gettok(%nicks,5,32) $gettok(%scores,5,32) %c1a #6 %cl2b $gettok(%nicks,6,32) $gettok(%scores,6,32) %c1a #7 %cl2b $gettok(%nicks,7,32) $gettok(%scores,7,32) %c1a #8 %cl2b $gettok(%nicks,8,32) $gettok(%scores,8,32) %c1a #9 %cl2b $gettok(%nicks,9,32) $gettok(%scores,9,32) %c1a #10 %cl2b $gettok(%nicks,10,32) $gettok(%scores,10,32) 
  msg %game_channel %msg
}

alias trivscoresweek20 {
  var %scores = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $trivia_getweek(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $trivia_getweek(%index)
    var %thisscore = $triv_read(scoresweek, %thisnick)
    var %index2 = 1
    while (%index2 <= 20) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,21,32)
        var %nicks = $deltok(%nicks,21,32)
        var %index2 = 21
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1
  var %c1a = $chr(3) $+ 0,6
  var %cl2b = $chr(3) $+ 0,3

  var %msg = %cl2b I Top 11-20 di Questa Settimana: %c1a #11 %cl2b $gettok(%nicks,11,32) $gettok(%scores,11,32) %c1a #12 %cl2b $gettok(%nicks,12,32) $gettok(%scores,12,32) %c1a #13 %cl2b $gettok(%nicks,13,32) $gettok(%scores,13,32) %c1a #14 %cl2b $gettok(%nicks,14,32) $gettok(%scores,14,32) %c1a #15 %cl2b $gettok(%nicks,15,32) $gettok(%scores,15,32) %c1a #16 %cl2b $gettok(%nicks,16,32) $gettok(%scores,16,32) %c1a #17 %cl2b $gettok(%nicks,17,32) $gettok(%scores,17,32) %c1a #18 %cl2b $gettok(%nicks,18,32) $gettok(%scores,18,32) %c1a #19 %cl2b $gettok(%nicks,19,32) $gettok(%scores,19,32) %c1a #20 %cl2b $gettok(%nicks,20,32) $gettok(%scores,20,32) 
  msg %game_channel %msg
}

;================Classifica Mese
alias triv_readgetmonth {
  return $ini(" $+ $scriptdir $+ triviascores $+ .ini $+ ", scoresmonth,$1)
}

alias trivscoresmonth {
  var %scores = 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $triv_readgetmonth(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $triv_readgetmonth(%index)
    var %thisscore = $triv_read(scoresmonth, %thisnick)
    var %index2 = 1
    while (%index2 <= 10) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,11,32)
        var %nicks = $deltok(%nicks,11,32)
        var %index2 = 11
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1

  var %c1a = $chr(3) $+ 12,8
  var %cl2b = $chr(3) $+ 0,12
  var %msg = %cl2b I Top 1-10 di Questo Mese: %c1a #1 %cl2b $gettok(%nicks,1,32) $gettok(%scores,1,32) %c1a #2 %cl2b $gettok(%nicks,2,32) $gettok(%scores,2,32) %c1a #3 %cl2b $gettok(%nicks,3,32) $gettok(%scores,3,32) %c1a #4 %cl2b $gettok(%nicks,4,32) $gettok(%scores,4,32) %c1a #5 %cl2b $gettok(%nicks,5,32) $gettok(%scores,5,32) %c1a #6 %cl2b $gettok(%nicks,6,32) $gettok(%scores,6,32) %c1a #7 %cl2b $gettok(%nicks,7,32) $gettok(%scores,7,32) %c1a #8 %cl2b $gettok(%nicks,8,32) $gettok(%scores,8,32) %c1a #9 %cl2b $gettok(%nicks,9,32) $gettok(%scores,9,32) %c1a #10 %cl2b $gettok(%nicks,10,32) $gettok(%scores,10,32) 
  msg %game_channel %msg
}

alias trivscoresmonth20 {
  var %scores = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $triv_readgetmonth(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $triv_readgetmonth(%index)
    var %thisscore = $triv_read(scoresmonth, %thisnick)
    var %index2 = 1
    while (%index2 <= 20) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,21,32)
        var %nicks = $deltok(%nicks,21,32)
        var %index2 = 21
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1
  var %c1a = $chr(3) $+ 12,8
  var %cl2b = $chr(3) $+ 0,12
  var %msg = %cl2b I Top 11-20 di Questo Mese: %c1a #11 %cl2b $gettok(%nicks,11,32) $gettok(%scores,11,32) %c1a #12 %cl2b $gettok(%nicks,12,32) $gettok(%scores,12,32) %c1a #13 %cl2b $gettok(%nicks,13,32) $gettok(%scores,13,32) %c1a #14 %cl2b $gettok(%nicks,14,32) $gettok(%scores,14,32) %c1a #15 %cl2b $gettok(%nicks,15,32) $gettok(%scores,15,32) %c1a #16 %cl2b $gettok(%nicks,16,32) $gettok(%scores,16,32) %c1a #17 %cl2b $gettok(%nicks,17,32) $gettok(%scores,17,32) %c1a #18 %cl2b $gettok(%nicks,18,32) $gettok(%scores,18,32) %c1a #19 %cl2b $gettok(%nicks,19,32) $gettok(%scores,19,32) %c1a #20 %cl2b $gettok(%nicks,20,32) $gettok(%scores,20,32) 
  msg %game_channel %msg
}

;================Classifica Generale
alias triv_readgetall {
  return $ini(" $+ $scriptdir $+ triviascores $+ .ini $+ ", scoresall,$1)
}

alias trivscoresall {
  var %scores = 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $triv_readgetall(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $triv_readgetall(%index)
    var %thisscore = $triv_read(scoresall, %thisnick)
    var %index2 = 1
    while (%index2 <= 10) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,11,32)
        var %nicks = $deltok(%nicks,11,32)
        var %index2 = 11
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1

  var %c1a = $chr(3) $+ 12,8
  var %cl2b = $chr(3) $+ 0,12
  var %msg = %cl2b I Top 1-10 dei Top: %c1a #1 %cl2b $gettok(%nicks,1,32) $gettok(%scores,1,32) %c1a #2 %cl2b $gettok(%nicks,2,32) $gettok(%scores,2,32) %c1a #3 %cl2b $gettok(%nicks,3,32) $gettok(%scores,3,32) %c1a #4 %cl2b $gettok(%nicks,4,32) $gettok(%scores,4,32) %c1a #5 %cl2b $gettok(%nicks,5,32) $gettok(%scores,5,32) %c1a #6 %cl2b $gettok(%nicks,6,32) $gettok(%scores,6,32) %c1a #7 %cl2b $gettok(%nicks,7,32) $gettok(%scores,7,32) %c1a #8 %cl2b $gettok(%nicks,8,32) $gettok(%scores,8,32) %c1a #9 %cl2b $gettok(%nicks,9,32) $gettok(%scores,9,32) %c1a #10 %cl2b $gettok(%nicks,10,32) $gettok(%scores,10,32) 
  msg %game_channel %msg
}

alias trivscoresall20 {
  var %scores = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  var %nicks = --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
  var %totalplayers = $triv_readgetall(0)

  var %index = 1
  while (%index <= %totalplayers) {
    var %thisnick = $triv_readgetall(%index)
    var %thisscore = $triv_read(scoresall, %thisnick)
    var %index2 = 1
    while (%index2 <= 20) {
      var %scoresget = $gettok(%scores,%index2,32)
      if (%thisscore > %scoresget) {
        var %scores = $instok(%scores,%thisscore,%index2,32)
        var %nicks = $instok(%nicks,%thisnick,%index2,32)
        var %scores = $deltok(%scores,21,32)
        var %nicks = $deltok(%nicks,21,32)
        var %index2 = 21
      }
      inc %index2
    }
    inc %index
  }
  var %index = 1
  var %c1a = $chr(3) $+ 12,8
  var %cl2b = $chr(3) $+ 0,12
  var %msg = %cl2b I Top 11-20 dei Top: %c1a #11 %cl2b $gettok(%nicks,11,32) $gettok(%scores,11,32) %c1a #12 %cl2b $gettok(%nicks,12,32) $gettok(%scores,12,32) %c1a #13 %cl2b $gettok(%nicks,13,32) $gettok(%scores,13,32) %c1a #14 %cl2b $gettok(%nicks,14,32) $gettok(%scores,14,32) %c1a #15 %cl2b $gettok(%nicks,15,32) $gettok(%scores,15,32) %c1a #16 %cl2b $gettok(%nicks,16,32) $gettok(%scores,16,32) %c1a #17 %cl2b $gettok(%nicks,17,32) $gettok(%scores,17,32) %c1a #18 %cl2b $gettok(%nicks,18,32) $gettok(%scores,18,32) %c1a #19 %cl2b $gettok(%nicks,19,32) $gettok(%scores,19,32) %c1a #20 %cl2b $gettok(%nicks,20,32) $gettok(%scores,20,32) 
  msg %game_channel %msg
}
;=====================
alias triv_read {
  return $readini " $+ $scriptdir $+ triviascores $+ .ini $+ " $1 $2
}
;=====================
alias triv_write {
  writeini " $+ $scriptdir $+ triviascores $+ .ini $+ " $1 $2 $3- 
}
;=====================
alias triv_rem {
  remini " $+ $scriptdir $+ triviascores $+ .ini $+ " $1 $2
}
;=================menù=====================
menu channel {
  -
  Giochi
  .Trivia
  ..Settaggi:dialog -m trivia2 trivia2
  ..Start :/trivia 0
  ..Stop :trivia_off
  ..-
  ..Top Del Giorno:triviascoreday
  ..-
  ..Top 10 Della Settimana:trivscoresweek
  ..Top 20 Della Settimana:trivscoresweek20
  ..-
  ..Top 10 Del Mese:trivscoresmonth
  ..Top 20 Del Mese:trivscoresmonth20 
  ..-
  ..Top 10 Di Sempre:trivscoresall
  ..Top 20 Di Sempre:trivscoresall20
  ..-
  ..Resetta Giorno:$iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica del Giorno?",triv_resetday,halt) 
  ..Resetta Settimana:$iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica della Settimana?",triv_resetweek,halt) 
  ..Resetta Mese:$iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica del Mese?",triv_resetmonth,halt)
  ..Resetta I Top dei Top:$iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica Top dei Top?",triv_resetalltop,halt)
  ..Resetta Tutte Le Classifiche:$iif($?!="Certo di voler eliminare $crlf $+ i records di tutte le classifiche?",resetall,halt)
}
;;==========Dialog di Controllo==========
dialog trivia2 {
  title "Trivia2"
  size -1 -1 245 344
  option pixels
  button "1/10", 2, 5 74 35 20
  button "11/20", 3, 42 154 35 20
  button "11/20", 4, 42 74 35 20
  button "1/10", 5, 5 115 35 20
  button "1/10", 6, 6 154 35 20
  button "11/20", 7, 42 115 35 20
  button "1/10", 8, 5 34 35 20
  box "Giornaliera ", 9, 3 18 113 40
  box "Settimanale", 10, 3 58 113 40
  box "Mensile", 11, 3 99 113 40
  box "Generale", 12, 3 138 113 40
  box "Classifiche ", 13, 3 3 120 215
  button "Reset", 14, 79 34 35 20
  box "Avvio di Trivia2", 15, 3 219 120 93
  button "Reset", 16, 79 74 35 20
  button "Reset", 17, 79 115 35 20
  button "Reset", 18, 79 154 35 20
  button "Elimina Classifiche", 19, 7 194 105 20
  button "Avvia", 20, 7 260 50 45
  button "Ferma", 21, 68 260 50 45
  edit %c1 , 1, 125 271 25 20
  edit %c2 , 22, 125 291 25 20
  edit %tempoaiuto , 23, 125 51 25 20
  edit %tempodomanda , 24, 125 71 25 20
  edit %game_channel , 25, 125 140 113 20
  edit %game_password , 26, 125 207 113 20
  box "Reset All", 27, 3 178 113 40
  box "Canale Trivia", 28, 123 92 120 69
  text "Inserire il canale mettendo anche #", 29, 126 110 100 27
  box "Paasword", 30, 123 161 120 67
  text "Inserire password (facoltativo)", 31, 127 176 105 28
  box "Set colori testo", 32, 123 229 120 83
  text " Primo colore", 33, 151 272 74 17
  text " Secondo colore", 34, 152 292 78 17
  box "Set Tempi", 35, 123 3 120 88
  text "Inserire i tempi espressi in secondi", 36, 127 21 105 29
  text "Tempo Aiuti", 37, 155 53 61 17
  text "Tempo Domanda", 38, 155 71 80 17
  text "Inserire il numero del colore desiderato", 39, 127 245 104 26
  text "Avvia e Ferma il trivia", 40, 6 241 111 16
  button "&Ok", 41, 13 314 65 25, ok
  button "&Applica", 42, 93 314 65 25
  button "&Cancella", 43, 169 314 65 25, cancel
}

on *:DIALOG:trivia2:sclick:2: { .trivscoresweek }
on *:DIALOG:trivia2:sclick:3: { .trivscoresall20 }
on *:DIALOG:trivia2:sclick:4: { .trivscoresweek20 }
on *:DIALOG:trivia2:sclick:5: { .trivscoresmonth }
on *:DIALOG:trivia2:sclick:6: { .trivscoresall }
on *:DIALOG:trivia2:sclick:7: { .trivscoresmonth20 }
on *:DIALOG:trivia2:sclick:8: { .triviascoreday }
on *:DIALOG:trivia2:sclick:14: { $iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica del Giorno?",triv_resetday,halt) }
on *:DIALOG:trivia2:sclick:16: { $iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica della Settimana?",triv_resetweek,halt) }
on *:DIALOG:trivia2:sclick:17: { $iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica del Mese?",triv_resetmonth,halt) }
on *:DIALOG:trivia2:sclick:18: { $iif($?!="Certo di voler eliminare i Records $crlf $+ della classifica Top dei Top?",triv_resetalltop,halt) }
on *:DIALOG:trivia2:sclick:19: { $iif($?!="Certo di voler eliminare $crlf $+ i records di tutte le classifiche?",resetall,halt) }
on *:DIALOG:trivia2:sclick:20: { /trivia 0 }
on *:DIALOG:trivia2:sclick:21: { .trivia_off }
on *:dialog:trivia2:sclick:41: {
  set %c1 $did(trivia2,1)
  set %c2 $did(trivia2,22)
  set %tempoaiuto $did(trivia2,23)
  set %tempodomanda $did(trivia2,24)
  set %game_channel $did(trivia2,25)
  set %Game_Password $did(trivia2,26)
}
on *:dialog:trivia2:sclick:42: {
  set %c1 $did(trivia2,1)
  set %c2 $did(trivia2,22)
  set %tempoaiuto $did(trivia2,23)
  set %tempodomanda $did(trivia2,24)
  set %game_channel $did(trivia2,25)
  set %Game_Password $did(trivia2,26)
}