mIRC Homepage
This should be my last question, then I have all the functions that I want for my current bot (and then you are free of my stupid questions :p)!
I want to use a rating system for songs with my bot and I do have everything set up, but I do not have any experience with .ini files (used to store information).
Is it possible to read all the last values and get an average from that?

Kind of like this:

[In the end - Linkin Park]
Vijo - 3
Savian - 5
John - 4
[Other song - you don't know who]
Vijo - 2

(The average being 4 for the Song by LP and the number being the rating everyone gave the song)
I guess you could count the lines of the song with a certain command and then use $calc to get the average, but for that I need to retrieve the values/numbers of everyone for one song.

Is it possible to do this?

As always, thanks in advance!
be sure to use "=" in your ini file rather than "-"

INI (saved as songs.ini):
[In the end - Linkin Park]
[Other song - you don't know who]

alias songaverage {

  var %path songs.ini

  var %song $1-
  var %e 0
  var %avg 0
  var %tot $ini(%path,%song,0)
  while ( %e <= $ini(%path,%song,0) ) {
    var %value $readini(%path,%song,$ini(%path,%song,%e))
    var %avg $calc(%avg + %value)
    inc %e
  if ( %tot == 0 ) {
    return 0
  else {
    return $calc(%avg / %tot)

$songaverage(In the end - Linkin Park)

^ returns "4"
© mIRC Discussion Forums