Karma Game 2

By NickLeStrange on Oct 13, 2013

Ok, so my original Karma Game ( http://www.hawkee.com/snippet/9793/#c105112 ) script was a bit convoluted, relying on a bunch of text files to function. So here I have recoded it, and this time it stores all the information in variables.

For this to work, a user has to opt-in to play the game by registering their nickname. This is done by typing /msg nameofbot register password - with the password being their own password in order to un-register later on; ex /msg Red_Queen register 12345

When a user registers, it creates 5 variables that are stored until the user un-registers. These variable will all start with the user's nickname. If the user wants to play under a different name, he/she will have to register that one too.

It stores: "registered", the password, the user score, the date joined, and the time joined.
If the user is already registered, the script will inform them, and vice versa.

You can add a High Score, and a Legendary Score goal for users to reach, when a user reaches this score, it announces it to the channel. You can also control the score increments, the default is 1. So the user scores 1 point for every line of text submitted to the channel.

These settings are available from the menu bar, status, channel, and query windows.

Commands for the end users:
/msg bot register password (registers the user)
/msg bot remove password (un-registers the user)
!kscore (displays the requester's score - sent to the requester as a .notice)
!kscore
nickname* (displays the score of someone else - sent to the requester as a .notice)

Note: Using the script as is will enable it for all channels. I haven't tested it like that. I only use it on 1 channel.

*Feel free to use this script, and add to it / modify it to your hearts content.
**Spread the love by giving credit where credit is due.

Recommended that you use mIRC 6.35.

on 1:load: {
  set %karmahighscore = 1000
  set %karmalegendaryscore = 100000
  set %%addkarma = 1
}

on 1:text:!kscore*:#: {
  if ($2 == $null) { KUserScore }
  elseif ($2 != $null) { %kuserscore = $2 | KGetUserScore }
}

on 1:text:*:?: {
  if ($1 == register) && ($2 != $null) { %kpass = $2 | KarmaRegister }
  elseif ($1 == Register) && ($2 == $null) { .notice $nick To register please specify a password - example; /msg $me register *password* - also please write down the password for later use. }
  elseif ($1 == remove) { %kpass = $2 | KarmaDeRegister }
}

on 1:text:*:#: {
    %currentkarma = % [ $+ [ $nick ] [ $+ [ count ] ] ]
    %sumkarma = %currentkarma + %addkarma
  if (% [ $+ [ $nick ] ] == registered) { 
    set % $+ $nick $+ count %sumkarma 
  }
  if (% [ $+ [ $nick ] [ $+ [ count ] ] ] == %karmahighscore) { .msg $chan $nick has just reached the High Score of %karmahighscore karma points! Grats $nick $+ ! }
  if (% [ $+ [ $nick ] [ $+ [ count ] ] ] == %karmalegendaryscore) { .msg $chan $nick has just reached the LEGENDARY Score of %karmalegendaryscore karma points! Grats $nick $+ ! }
}

menu menubar,status,channel,query {
  -
  Karma Control
  .Karma increments:/AddKarmaIncrements
  .-
  .Set High Score:/KarmaHighScore
  .Set Legendary Score:/KarmaLegendaryScore
  .-
  .Uninstall:/KUninstall
}

alias AddKarmaIncrements {
  set %addkarma $?="Specify the value at which you want the karma score to increase. Default value is 1."
  if (%addkarma == $null) { set %addkarma 1 }
  elseif (%addkarma == 0) { set %addkarma 1 }
}

alias KarmaHighScore {
  set %karmahighscore $?="What is the high score that you want chatters to achieve? Defaul value is 1000"
  if (%karmahighscore == $null) { set %karmahighscore 1000 }
  elseif (%karmahighscore == 0) { set %karmahighscore 1000 }
}

alias KarmaLegendaryScore {
  set %karmalegendaryscore $?="What is the legenadry score that you want chatters to achieve? Defaul value is 100000"
  if (%karmalegendaryscore == $null) { set %karmalegendaryscore 100000 }
  elseif (%karmalegendaryscore == 0) { set %karmalegendaryscore 100000 }
}

alias KarmaRegister {
  if (% [ $+ [ $nick ] ] == registered) { .notice $nick You have already registered on the % [ $+ [ $nick ] [ $+ [ date ] ] ] $+ , at % [ $+ [ $nick ] [ $+ [ time ] ] ] $+ . }
  else { set % $+ $nick registered | set % $+ $nick $+ password %kpass | set % $+ $nick $+ count 0 | set % $+ $nick $+ date $date | set % $+ $nick $+ time $time | .notice $nick Welcome to The Karma Game $nick $+ ! Your password has been set to % [ $+ [ $nick ] [ $+ [ password ] ] ] $+ , and your current score is % [ $+ [ $nick ] [ $+ [ count ] ] ] $+ . } 
}

alias KarmaDeRegister {
  if (%kpass == % [ $+ [ $nick ] [ $+ [ password ] ] ]) { unset % $+ $nick | unset % $+ $nick $+ count | unset % $+ $nick $+ password | unset % $+ $nick $+ date | unset % $+ $nick $+ time | .notice $nick You have been removed from The Karma Game $+ ! }
  else { .notice $nick Either you have already been removed from The Karma Game, or you've never joined. I have no records for you. }
}

alias KUserScore {
  if (% [ $+ [ $nick ] ] == registered) { .notice $nick Your current karma score = % [ $+ [ $nick ] [ $+ [ count ] ] ] $+. }
  else { .notice $nick Either you have been removed from The Karma Game, or you've never joined. I have no records for you. }
}

alias KGetUserScore {
  if (% [ $+ [ %kuserscore ] ] == registered) { .notice $nick %kuserscore $+ 's current karma score = % [ $+ [ %kuserscore ] [ $+ [ count ] ] ] $+. }
  else { .notice $nick %kuserscore isn't playing The Karma Game. }
}

alias KUninstall {
  unset %karmahighscore
  unset %karmalegendaryscore
  unset %addkarma
  unset %currentkarma
  unset %sumkarma
  unset %kuserscore
  unset %kpass
  unset %knick
  unload -rs Karma.mrc
}

Comments

Sign in to comment.
dma   -  Sep 23, 2015

seems like apian in the neck i got 55 people on my channel

 Respond  
cptpan   -  Nov 21, 2013

Does this even work?

NickLeStrange  -  Nov 21, 2013

It does, I'm using it in my chan.

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.