mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2014
Posts: 13
O
Pikka bird
OP Offline
Pikka bird
O
Joined: May 2014
Posts: 13
I've been working on a script which allows people to bet points they have accumulated by being in a twitch chat for things the streamer starts, and can't seem to get it to work. The point system itself works fine, and the betting system works well up until the end, where it doesn't actually give people the points they have won.
Here's what I have for just the bet portion of the entire point system
Code:
on *:TEXT:!bet*:#omegazeron: {
  if ($nick == omegazeron) {
    if (%bet != 1) {
      set %bet 1
      if ($0 == 3) {
        set %options 2
        set %voters 0
        set %voters1 0
        set %voters2 0
      }
      if ($0 == 4) {
        set %options 3
        set %voters 0
        set %voters1 0
        set %voters2 0
        set %voters3 0
      }
      if ($0 == 5) {
        set %options 4
        set %voters 0
        set %voters1 0
        set %voters2 0
        set %voters3 0
        set %voters4 0
      }
      if (%options == 2) {
        set %option1 $$2
        set %option2 $$3
        msg $chan { A bet has been called! Options are $$2 and $$3 $+ ! Type "!vote option" to place your bet! Betting costs 13 waifus. }
      }
      if (%options == 3) {
        set %option1 $$2
        set %option2 $$3
        set %option3 $$4
        msg $chan { A bet has been called! Options are $$2 $+ , $$3 $+ , and $$4 $+ ! Type "!vote option" to place your bet! Betting costs 13 waifus. }
      }
      if (%options == 4) {
        set %option1 $$2
        set %option2 $$3
        set %option3 $$4
        set %option4 $$5
        msg $chan { A bet has been called! Options are $$2 $+ , $$3 $+ , $$4 $+ , and $$5 $+ ! Type "!vote option" to place your bet! Betting costs 13 waifus. }
      }
    }
  }
}
on *:TEXT:!vote*:#omegazeron: {
  if (%bet.join.repeat. [ $+ [ $nick ] ] == 1) { halt }
  set %bet.join.repeat. [ $+ [ $nick ] ] 1
  if ($readini(Points.ini,$+(#,.,$nick),Points) >= 13) {
    if (%options == 2) {
      if ($2 == %option1) {
        write txt\betoption1.txt $nick
        inc %voters
        inc %voters1
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option2) {
        write txt\betoption2.txt $nick
        inc %voters
        inc %voters2
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
    }
    if (%options == 3) {
      if ($2 == %option1) {
        write txt\betoption1.txt $nick
        inc %voters
        inc %voters1
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option2) {
        write txt\betoption2.txt $nick
        inc %voters
        inc %voters2
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option3) {
        write txt\betoption3.txt $nick
        inc %voters
        inc %voters3
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
    }
    if (%options === 4) {
      if ($2 == %option1) {
        write txt\betoption1.txt $nick
        inc %voters
        inc %voters1
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option2) {
        write txt\betoption2.txt $nick
        inc %voters
        inc %voters2
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option3) {
        write txt\betoption3.txt $nick
        inc %voters
        inc %voters3
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
      if ($2 == %option4) {
        write txt\betoption4.txt $nick
        inc %voters
        inc %voters4
        writeini -n Points.ini $+(#,.,$nick) Points $calc($readini(Points.ini,$+(#,.,$nick),Points) $iif($1 == !vote,-) 13)
      }
    }
  }
}



on *:TEXT:!end*:#omegazeron: {
  if ($nick == omegazeron) {
    if (%options == 2) {
      if ($2 == %option1) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters1))) waifus.
        var %x = %voters1
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption1.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption1.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters1))))
          dec %x
        }
      }
      if ($2 == %option2) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters2))) waifus.
        var %x = %voters2
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption2.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption2.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters2))))
          dec %x
        }
      }
    }
    if (%options == 3) {
      if ($2 == %option1) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters1))) waifus.
        var %x = %voters1
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\!betoption1.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\!betoption1.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters1))))
          dec %x
        }
      }
      if ($2 == %option2) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters2))) waifus.
        var %x = %voters2
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption2.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption2.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters2))))
          dec %x
        }
      }
      if ($2 == %option3) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters3))) waifus.
        var %x = %voters3
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption3.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption3.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters3))))
          dec %x
        }
      }
    }
    if (%options == 4) {
      if ($2 == %option1) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters1))) waifus.
        var %x = %voters1
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption1.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption1.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters1))))
          dec %x
        }
      }
      if ($2 == %option2) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters2))) waifus.
        var %x = %voters2
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption2.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\!etoption2.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters2))))
          dec %x
        }
      }
      if ($2 == %option3) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters3))) waifus.
        var %x = %voters3
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption3.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption3.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters3))))
          dec %x
        }
      }
      if ($2 == %option4) {
        msg $chan The winning option was $$2 $+ ! All winners of the bet will recieve $ceil($calc(((%voters)*13)/(%voters4))) waifus.
        var %x = %voters4
        while (%x) {
          writeini -n Points.ini $+(#,.,$read(txt\betoption4.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption4.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters4))))
          dec %x
        }
      }
    }
  }
}

At the end I know I should have unset lines for the variables, but I left them out for testing purposes to see exactly what happened.

Last edited by OmegaZeron; 18/04/15 04:03 PM.
Joined: May 2014
Posts: 13
O
Pikka bird
OP Offline
Pikka bird
O
Joined: May 2014
Posts: 13
Basically only the end has the problem, I just posted the whole thing so all of the variables made sense. As far as I know the only problem is with this line I had tested before while not with the point system
Code:
var %x = %voters1
while (%x) {
  writeini -n Points.ini $+(#,.,$read(txt\betoption1.txt, %x)) Points $calc($readini(Points.ini,$+(#,.,$read(txt\betoption1.txt, %x)),Points) $iif($1 == !end,+) $ceil($calc(((%voters)*13)/(%voters1))))
  dec %x
}

This is what my test was, with two people in the txt file, and it worked
Code:
var %x = %voters1
while (%x) {
  msg $chan $read(txt\betoption1.txt, %x)
  dec %x
}


Link Copied to Clipboard