mIRC Home    About    Download    Register    News    Help

Print Thread
trivia top10 & hash #170052 02/02/07 03:13 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
Code:
alias trivia.answered {
  if ($1 == $null) { halt }
  else {
    set %trivia.week.add %trivia.week. [ $+ [ $1 ] ]
    set %trivia.month.add %trivia.month. [ $+ [ $1 ] ]
    set %trivia.week. [ $+ [ $1 ] ] $calc(%trivia.p + %trivia.week.add)
    set %trivia.month. [ $+ [ $1 ] ] $calc(%trivia.p + %trivia.month.add)
    msg %triviachan $1 2Answer:3 %trivia.a 2In: $+ 3 $duration($calc($ctime - %trivia.el)) $+ 14! 2Won: $+ 3 %trivia.p $+ Points. 2points this week: $+ 3 %trivia.week. [ $+ [ $1 ] ] 2points this month: $+ 3 %trivia.month. [ $+ [ $1 ] ]
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.1) {
      if ($readini(trivia.ini, week, 1) == $1) {
        set %trivia.week.1 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) {
        set %trivia.week.2 %trivia.week.1
        set %trivia.week.1 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 2 $readini(trivia.ini, week, 1)
        writeini -s trivia.ini week 1 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #1 P14layer!
        top5 week
        goto month
      }
    }
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.2) {
      if ($readini(trivia.ini, week, 2) == $1) {
        set %trivia.week.2 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) {
        set %trivia.week.3 %trivia.week.2
        set %trivia.week.2 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 3 $readini(trivia.ini, week, 2)
        writeini -s trivia.ini week 2 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #2 P14layer!
        top5 week
        goto month
      }
    }
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.3) {
      if ($readini(trivia.ini, week, 3) == $1) {
        set %trivia.week.3 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) && ($readini(trivia.ini, week, 3) !== $1) {
        set %trivia.week.4 %trivia.week.3
        set %trivia.week.3 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 4 $readini(trivia.ini, week, 3)
        writeini -s trivia.ini week 3 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #3 P14layer!
        top5 week
        goto month
      }
    }
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.4) {
      if ($readini(trivia.ini, week, 4) == $1) {
        set %trivia.week.4 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) && ($readini(trivia.ini, week, 3) !== $1) && ($readini(trivia.ini, week, 4) !== $1) {
        set %trivia.week.5 %trivia.week.4
        set %trivia.week.4 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 5 $readini(trivia.ini, week, 4)
        writeini -s trivia.ini week 4 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #4 P14layer!
        top5 week
        goto month
      }
    }
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.5) {
      if ($readini(trivia.ini, week, 5) == $1) {
        set %trivia.week.5 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) && ($readini(trivia.ini, week, 3) !== $1) && ($readini(trivia.ini, week, 4) !== $1) && ($readini(trivia.ini, week, 5) !== $1) {
        set %trivia.week.6 %trivia.week.5
        set %trivia.week.5 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 5 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #5 P14layer!
        top5 week
        goto month
      }
    }
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.6) {
      if ($readini(trivia.ini, week, 6) !== $1) {
        set %trivia.week.6 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) && ($readini(trivia.ini, week, 3) !== $1) && ($readini(trivia.ini, week, 4) !== $1) && ($readini(trivia.ini, week, 5) !== $1) && ($readini(trivia.ini, week, 6) !== $1) {
        set %trivia.week.6 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 6 $1
        goto month
      }
    }
    :month
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.1) {
      if ($readini(trivia.ini, month, 1) == $1) {
        set %trivia.month.1 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) {
        set %trivia.month.2 %trivia.month.1
        set %trivia.month.1 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 2 $readini(trivia.ini, month, 1)
        writeini -s trivia.ini month 1 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this months) $+ 2 #1 P14layer!
        top5 month
        halt
      }
    }
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.2) {
      if ($readini(trivia.ini, month, 2) == $1) {
        set %trivia.month.2 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) && ($readini(trivia.ini, month, 2) !== $1) {
        set %trivia.month.3 %trivia.month.2
        set %trivia.month.2 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 3 $readini(trivia.ini, month, 2)
        writeini -s trivia.ini month 2 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this months) $+ 2 #2 P14layer!
        top5 month
        halt
      }
    }
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.3) {
      if ($readini(trivia.ini, month, 3) == $1) {
        set %trivia.month.3 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) && ($readini(trivia.ini, month, 2) !== $1) && ($readini(trivia.ini, month, 3) !== $1) {
        set %trivia.month.4 %trivia.month.3
        set %trivia.month.3 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 4 $readini(trivia.ini, month, 3)
        writeini -s trivia.ini month 3 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this months) $+ 2 #3 P14layer!
        top5 month
        halt
      }
    }
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.4) {
      if ($readini(trivia.ini, month, 4) == $1) {
        set %trivia.month.4 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) && ($readini(trivia.ini, month, 2) !== $1) && ($readini(trivia.ini, month, 3) !== $1) && ($readini(trivia.ini, month, 4) !== $1) {
        set %trivia.month.5 %trivia.month.4
        set %trivia.month.4 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 5 $readini(trivia.ini, month, 4)
        writeini -s trivia.ini month 4 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this months) $+ 2 #4 P14layer!
        top5 month
        halt
      }
    }
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.5) {
      if ($readini(trivia.ini, month, 5) == $1) {
        set %trivia.month.5 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) && ($readini(trivia.ini, month, 2) !== $1) && ($readini(trivia.ini, month, 3) !== $1) && ($readini(trivia.ini, month, 4) !== $1) && ($readini(trivia.ini, month, 5) !== $1) {
        set %trivia.month.6 %trivia.month.5
        set %trivia.month.5 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 5 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this months) $+ 2 #5 P14layer!
        top5 month
        halt
      }
    }
    if (%trivia.month. [ $+ [ $1 ] ] > %trivia.month.6) {
      if ($readini(trivia.ini, month, 6) !== $1) {
        set %trivia.month.6 %trivia.month. [ $+ [ $1 ] ]
        halt
      }
      if ($readini(trivia.ini, month, 1) !== $1) && ($readini(trivia.ini, month, 2) !== $1) && ($readini(trivia.ini, month, 3) !== $1) && ($readini(trivia.ini, month, 4) !== $1) && ($readini(trivia.ini, month, 5) !== $1) && ($readini(trivia.ini, month, 6) !== $1) {
        set %trivia.month.6 %trivia.month. [ $+ [ $1 ] ]
        writeini -s trivia.ini month 6 $1
        halt
      }
    }
  }
}
alias top5 {
  if ($1 == week) {
    .timern1 1 1 .notice $nick $trivtalk(Top 5 players this week 1st:) $+ 2 $readini(trivia.ini, week, 1) %trivia.week. [ $+ [ $readini(trivia.ini, week, 1) ] ]
    .timern2 1 2 .notice $nick $trivtalk(2nd:) $+ 2 $readini(trivia.ini, week, 2) %trivia.week. [ $+ [ $readini(trivia.ini, week, 2) ] ]
    .timern3 1 3 .notice $nick $trivtalk(3rd:) $+ 2 $readini(trivia.ini, week, 3) %trivia.week. [ $+ [ $readini(trivia.ini, week, 3) ] ]
    .timern4 1 4 .notice $nick $trivtalk(4th:) $+ 2 $readini(trivia.ini, week, 4) %trivia.week. [ $+ [ $readini(trivia.ini, week, 4) ] ]
    .timern5 1 5 .notice $nick $trivtalk(5th:) $+ 2 $readini(trivia.ini, week, 5) %trivia.week. [ $+ [ $readini(trivia.ini, week, 5) ] ]
  }
  if ($1 == month) {
    .timernm1 1 1 .notice $nick $trivtalk(Top 5 players this month 1st:) $+ 2 $readini(trivia.ini, month, 1) %trivia.month. [ $+ [ $readini(trivia.ini, month, 1) ] ]
    .timernm2 1 2 .notice $nick $trivtalk(2nd:) $+ 2 $readini(trivia.ini, month, 2) %trivia.month. [ $+ [ $readini(trivia.ini, month, 2) ] ]
    .timernm3 1 3 .notice $nick $trivtalk(3rd:) $+ 2 $readini(trivia.ini, month, 3) %trivia.month. [ $+ [ $readini(trivia.ini, month, 3) ] ]
    .timernm4 1 4 .notice $nick $trivtalk(4th:) $+ 2 $readini(trivia.ini, month, 4) %trivia.month. [ $+ [ $readini(trivia.ini, month, 4) ] ]
    .timernm5 1 5 .notice $nick $trivtalk(5th:) $+ 2 $readini(trivia.ini, month, 5) %trivia.month. [ $+ [ $readini(trivia.ini, month, 5) ] ]
  }
}
alias reset {
  if ($1 == week) {
    unset %trivia.week.*
    set %trivia.week.1 0
    set %trivia.week.2 0
    set %trivia.week.3 0
    set %trivia.week.4 0
    set %trivia.week.5 0
    set %trivia.week.6 0
    writeini trivia.ini week 1 none
    writeini trivia.ini week 2 none
    writeini trivia.ini week 3 none
    writeini trivia.ini week 4 none
    writeini trivia.ini week 5 none
    writeini trivia.ini week 6 none
  }
  if ($1 == month) {
    unset %trivia.month.*
    set %trivia.month.1 0
    set %trivia.month.2 0
    set %trivia.month.3 0
    set %trivia.month.4 0
    set %trivia.month.5 0
    set %trivia.month.6 0
    writeini trivia.ini month 1 none
    writeini trivia.ini month 2 none
    writeini trivia.ini month 3 none
    writeini trivia.ini month 4 none
    writeini trivia.ini month 5 none
    writeini trivia.ini month 6 none
  }
}
on *:JOIN:%triviachan: {
  if (%trivia.month. [ $+ [ $nick ] ] <= 1) {
    msg # $trivtalk(welcome $nick $+ .)
  }
  elseif (%trivia.month. [ $+ [ $nick ] ] > 0) {
    msg # $trivtalk(welcome back $nick $+ . score) $+ 2 %trivia.week. [ $+ [ $nick ] ] $trivtalk(poinets this week. and) $+ 2 %trivia.month. [ $+ [ $nick ] ] $trivtalk(points this month.)
    if ($readini(trivia.ini, week, 1) == $nick) {
      mode # +v $nick
    }
    if ($readini(trivia.ini, week, 2) == $nick) {
      mode # +v $nick
    }
    if ($readini(trivia.ini, week, 3) == $nick) {
      mode # +v $nick
    }
    if ($readini(trivia.ini, week, 4) == $nick) {
      mode # +v $nick
    }
    if ($readini(trivia.ini, week, 5) == $nick) {
      mode # +v $nick
    }
  }
}


this is from a trivia script but it only saves up to 5 or top 5 players week/month what i want is if someone may

1.) make it up to top10 players monthly/weekly
2.) Saves on hash instead of sets coz sometimes if there are too many players the script just stop responding and starts to malfunction.


learn learn learn
Re: trivia top10 & hash [Re: learn3r] #170176 04/02/07 06:42 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
Hope someone can help me on this


learn learn learn
Re: trivia top10 & hash [Re: learn3r] #170194 04/02/07 04:55 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The problem is that changing the entire thing over to hash requires basically a complete rewrite of the entire question/answer parts of the script. That is why I don't change my trivia script to hash. It's more work than I'm willing to do right now.


Invision Support
#Invision on irc.irchighway.net
Re: trivia top10 & hash [Re: Riamus2] #170210 05/02/07 02:42 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
How about the top5 week/month
can it be top10 instead of 5 only?


learn learn learn
Re: trivia top10 & hash [Re: learn3r] #170222 05/02/07 02:08 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
To do that, just duplicate each set of lines and increment the numbers in them until you get to 10:

For example:

Code:
    if (%trivia.week. [ $+ [ $1 ] ] > %trivia.week.5) {
      if ($readini(trivia.ini, week, 5) == $1) {
        set %trivia.week.5 %trivia.week. [ $+ [ $1 ] ]
        goto month
      }
      if ($readini(trivia.ini, week, 1) !== $1) && ($readini(trivia.ini, week, 2) !== $1) && ($readini(trivia.ini, week, 3) !== $1) && ($readini(trivia.ini, week, 4) !== $1) && ($readini(trivia.ini, week, 5) !== $1) {
        set %trivia.week.6 %trivia.week.5
        set %trivia.week.5 %trivia.week. [ $+ [ $1 ] ]
        writeini -s trivia.ini week 5 $1
        msg %triviachan $trivtalk(Congrats!) $+ 2 $1 $trivtalk(is now this weeks) $+ 2 #5 P14layer!
        top5 week
        goto month
      }
    }


Everywhere there is a number following "week", increment it by 1 (not $1). And where you see the != $1 parts, add another in for the current check. Basically, everywhere you see something about "week.1" or "week 1" (up to 6), just repeat it until you get to 10 or 11. If it went up to 6 already, go to 11. If it just went up to 5, then go to 10. See what you come up with.


Invision Support
#Invision on irc.irchighway.net
Re: trivia top10 & hash [Re: Riamus2] #170232 05/02/07 04:09 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
ok bro i'll try what you said..


learn learn learn
Re: trivia top10 & hash [Re: Riamus2] #170314 07/02/07 01:40 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
pls. help can't get my code to work


learn learn learn
Re: trivia top10 & hash [Re: learn3r] #170338 07/02/07 02:07 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Display what you have.


Invision Support
#Invision on irc.irchighway.net