Need help creating a Rank system for Twitch bot! Please Help!

By TabbyCakes on May 12, 2014

This is for a bot I'm creating for my Twitch chat-
I used this script i found and altered it to be where it is now: every 5 mins. watching viewers earn 1 coin and the coins are saved and displayed when typing !coins. All this is fine but what I'm trying to figure out now is how to make a !rank command so if the viewer is in a certain range of coins ie. 10-19,20-29,30-39, etc., they have a certain corresponding rank that appears when they type !rank. I tried to mess around with some ideas of a simple way of coding it but don't know exactly how because I'm new to this program. My Twitch is http://www.twitch.tv/tabbycakes/profile

///Coins///
on *:text:!help:#: { 
msg $chan Every 5 minutes you will earn 1 coin. To view your Coins type "!Coins" }

on $*:text:/!Coins (spend)/Si:#: {
  if ($0 < 3) { msg # Insufficient parameters: Use !Coins spend <user> [number] | return }
  writeini -n Coins.ini $+(#,.,$3) Coins $calc($readini(Coins.ini,$+(#,.,$3),Coins) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
  { msg $chan $3 now has $readini(Coins.ini,$+(#,.,$3),Coins) total Coins. }
}

alias -l addCoins {
  if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
  var %topic $+($chan,.,$nick)
  var %Coins $calc($readini(Coins.ini,%topic,Coins) + $1)
  writeini -n Coins.ini %topic Coins %Coins
  return %Coins
}

alias -l lookUpCoins {
  var %topic $+($chan,.,$nick)
  var %Coins $readini(Coins.ini,%topic,Coins)
  return %Coins
}
alias doaddCoins {
  if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
  var %topic $+($1,.,$2)
  var %Coins $calc($readini(Coins.ini,%topic,Coins) + $3)
  writeini -n Coins.ini %topic Coins %Coins
  echo -a Added Coins for %topic
}

alias doremCoins {
  var %topic $+($1,.,$2)
  if (%Coins !0) { echo 2-st You do not have that many Coins }
  remini -n Coins.ini %topic Coins
  echo -a Removed Coins for %topic
}

on *:text:!Coins:#:{
  if ((%floodCoins) || ($($+(%,floodCoins.,$nick),2))) { return }
  set -u10 %floodCoins On
  set -u30 %floodCoins. $+ $nick On
  msg # $nick has $readini(Coins.ini,$+(#,.,$nick),Coins) total Coins.
}

on $*:text:/!Coins (add|remove)/Si:#:{
  if ($nick isop #) {
    if ($0 < 3) { msg # Insufficient parameters: Use !Coins <add|remove> <user> [number] | return }
    writeini -n Coins.ini $+(#,.,$3) Coins $calc($readini(Coins.ini,$+(#,.,$3),Coins) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Coins.ini,$+(#,.,$3),Coins) total Coins. }
  }
  else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
  $+(.timerCoins.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
  msg $chan Welcome $nick to the stream! Your now earning Coins, to learn more type "!help".
}
on !*:part:#:$+(.timerCoins.,#,.,$nick) off
alias -l add.pts {
  writeini -n Coins.ini $1 Coins $calc($readini(Coins.ini,$1,Coins) + 1)
}

on *:text:!ranks:#: { 
  msg $chan Ranks comming Soon
}

This next script is an idea of how i want to have it but i don't know how to code this idea in some way to work with viewer coins.

on *:TEXT:!rank:#: {

  if ($1 == 9) msg $chan rank1
  if ($10 == 19) msg $chan rank2
  if ($20 == 29) msg $chan rank3
  if ($30 == 39) msg $chan rank4
  if ($40 == 49) msg $chan rank5
  if ($50 == 59) msg $chan rank6
  if ($60 == 69) msg $chan rank7
  if ($70 == 79) msg $chan rank8
  if ($80 == 89) msg $chan rank9
if ($90 == 99) msg $chan rank10 }
}   

Comments

Sign in to comment.
Kingc44   -  May 13, 2014

Maybe Something like this

on *:text:!rank:#:{
  if ($readini(Coins.ini,$nick,Coins) <= 9) { msg # $nick you are rank1 with $readini(Coins.ini,$nick,Coins) Coin. Earn $calc(10 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank2 }
  if ($readini(Coins.ini,$nick,Coins) > 9) && ($readini(Coins.ini,$nick,Coins) <= 19) { msg # $nick you are rank2 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 20 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank3 }
  if ($readini(Coins.ini,$nick,Coins) > 19) && ($readini(Coins.ini,$nick,Coins) <= 29) { msg # $nick you are rank3 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 30 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank4 }
  if ($readini(Coins.ini,$nick,Coins) > 29) && ($readini(Coins.ini,$nick,Coins) <= 39) { msg # $nick you are rank4 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 40 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank5 }
  if ($readini(Coins.ini,$nick,Coins) > 39) && ($readini(Coins.ini,$nick,Coins) <= 49) { msg # $nick you are rank5 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 50 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank6 }
  if ($readini(Coins.ini,$nick,Coins) > 49) && ($readini(Coins.ini,$nick,Coins) <= 59) { msg # $nick you are rank6 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 60 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank7 }
  if ($readini(Coins.ini,$nick,Coins) > 59) && ($readini(Coins.ini,$nick,Coins) <= 69) { msg # $nick you are rank7 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 70 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank8 }
  if ($readini(Coins.ini,$nick,Coins) > 69) && ($readini(Coins.ini,$nick,Coins) <= 79) { msg # $nick you are rank8 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 80 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank9 }
  if ($readini(Coins.ini,$nick,Coins) > 79) && ($readini(Coins.ini,$nick,Coins) <= 89) { msg # $nick you are rank9 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 90 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Rank10 }
  if ($readini(Coins.ini,$nick,Coins) > 89) && ($readini(Coins.ini,$nick,Coins) <= 99) { msg # $nick you are rank10 with $readini(Coins.ini,$nick,Coins) Coins. Earn $calc( 100 - $readini(Coins.ini,$nick,Coins)) More Coins To Become a Ran11 }
}
TabbyCakes  -  May 13, 2014

Yes! This is exactly what i needed and better! I like how its very easy to understand. Thank you very much Kingc44!

Kingc44  -  May 14, 2014

No problem... Glad i could help

BambiFocus  -  Jul 10, 2014

I am using the same code for the point system but still I can get the rank function to work. King or Tabby could you please help me? Instead coins I have points and when I try to use !rank in chat nothing displays. Even when I changed all the "coins" to points and I've tried different kinds of rank codes but none works. So please could you help me? :) Im really interested in the code that king wrote but I cant get it to work :( please help :) www.twitch.tv/bambiifocus is my twitch if you want to send me messages through there :)

doktorpeng  -  Aug 09, 2014

some problem like teh bambi ... !rank seems to dont work for me too :(

peterslayer1111  -  Aug 09, 2014

Same, !rank doesn't work as well. Really hope that someone knows a fix :(

JoeMarceau  -  Jul 01, 2015

on *:text:!rank:#:{
if ($readini(Points.ini,$+(#,.,$nick),Points) <= 9) { msg # $nick you are rank1 with $readini(Points.ini,$+(#,.,$nick),Points) Points. Earn $calc(10 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank2 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 9) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 19) { msg # $nick you are rank2 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 20 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank3 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 19) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 29) { msg # $nick you are rank3 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 30 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank4 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 29) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 39) { msg # $nick you are rank4 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 40 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank5 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 39) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 49) { msg # $nick you are rank5 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 50 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank6 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 49) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 59) { msg # $nick you are rank6 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 60 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank7 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 59) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 69) { msg # $nick you are rank7 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 70 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank8 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 69) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 79) { msg # $nick you are rank8 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 80 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank9 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 79) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 89) { msg # $nick you are rank9 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 90 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Rank10 }
if ($readini(Points.ini,$+(#,.,$nick),Points) > 89) && ($readini(Points.ini,$+(#,.,$nick),Points) <= 99) { msg # $nick you are rank10 with $readini(Points.ini,$+(#,.,$nick),Points) Coins. Earn $calc( 100 - $readini(Points.ini,$+(#,.,$nick),Points)) More Coins To Become a Ran11 }
}

this works for me

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.