mIRC Home    About    Download    Register    News    Help

Print Thread
#244156 27/01/14 06:39 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
 
on *:text:!mmr*:#: {

  var %chan $chan
  var %t1 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,1)
  var %t2 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,2)

  if ($2 == $null) { msg $chan %t1 | msg $chan %t2 | return }

  if (# == # [ $+ [ $nick ] ]) || ($nick == nillens) { 
    if ($2 == solo) && ($3 == edit) { msg $chan Solo mmr is now $4 | write -l1 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Solo: $4 | return }
    if ($2 == party) && ($3 == edit) { msg $chan Party mmr is now $4 | write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Party: $4 | return }
  }

  if ($nick isop #) { 
    if ($2 != solo) && ($2 != party) { msg $chan Specify if you played solo or party. | return }
    elseif ($3 != +) && ($3 != -) { msg $chan Did you go + or -? | return } 
    elseif ($4 !isnum) { msg $chan Sorry, $4 is not a number. | return }  

    elseif ($2 == solo) && ($3 == +) { 
      var %s+ $calc(%t1 + $4)
      write -l1 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Solo: %s+
      msg $chan Current solo mmr is: %s+ ( $+ %t1 + $4 $+ )
    }

    elseif ($2 == solo) && ($3 == -) { 
      var %s- $calc(%t1 - $4)
      write -l1 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Solo: %s-
      msg $chan Current solo mmr is: %s- ( $+ %t1 - $4 $+ )
    }

    elseif ($2 == party) && ($3 == +) { 
      var %p+ $calc(%t2 + $4)
      write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Party: %p+
      msg $chan Current party mmr is: %p+ ( $+ %t2 + $4 $+ )
    }

    elseif ($2 == party) && ($3 == -) { 
      var %p- $calc(%t2 - $4)
      write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt Party: %p-
      msg $chan Current party mmr is: %p- ( $+ %t2 - $4 $+ )
    }

  }
}


What it does is every time I try to +/- it always go back to 0 like this:
[07:34] <@nillens> !mmr solo - 50
[07:34] <@nillensbot> Current solo mmr is: 0 (Solo: 4103 - 50)
[07:38] <@nillens> !mmr solo + 50
[07:38] <@nillensbot> Current solo mmr is: 0 (Solo: 0 + 50)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You're writing text (Solo:, Party:) to lines 1 and 2, then you try to use them as numbers in $calc. Also, if a file begins with a number it must be the number of lines in the file.

Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Lemme see if I understood you correctly.

I'm changing the output to
3 <- Indication of how many lines
4103 <- Solo mmr
4020 <- Party mmr

And have the command read lines 2 and 3 while having "Solo: , Party:" in the actual msg # instead?

So, this is what my code looks like right now. But I'm still not getting the results I want.

(EDITED OUT)

I changed it once again, it was confusing me with the read lines.

Code:
on *:text:!mmr*:#: {

  var %chan $chan
  var %l2 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,1)
  var %l3 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,2)

  if ($2 == $null) { msg $chan %l2 | msg $chan %l3 | return }

  if (# == # [ $+ [ $nick ] ]) || ($nick == nillens) { 
    if ($2 == solo) && ($3 == edit) { msg $chan Solo mmr is now $4 | write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt $4 | return }
    if ($2 == party) && ($3 == edit) { msg $chan Party mmr is now $4 | write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt $4 | return }
  }

  if ($nick isop #) { 
    if ($2 != solo) && ($2 != party) { msg $chan Specify if you played solo or party. | return }
    elseif ($3 != +) && ($3 != -) { msg $chan Did you go + or -? | return } 
    elseif ($4 !isnum) { msg $chan Sorry, $4 is not a number. | return }  

    elseif ($2 == solo) && ($3 == +) { 
      var %s+ $calc(%l2 + $4)
      write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %s+
      msg $chan Current solo mmr is: %s+ ( $+ %l2 + $4 $+ )
    }

    elseif ($2 == solo) && ($3 == -) { 
      var %s- $calc(%l2 - $4)
      write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %s-
      msg $chan Current solo mmr is: %s- ( $+ %l2 - $4 $+ )
    }

    elseif ($2 == party) && ($3 == +) { 
      var %p+ $calc(%l3 + $4)
      write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %p+
      msg $chan Current party mmr is: %p+ ( $+ %l3 + $4 $+ )
    }

    elseif ($2 == party) && ($3 == -) { 
      var %p- $calc(%l3 - $4)
      write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %p-
      msg $chan Current party mmr is: %p- ( $+ %l3 - $4 $+ )
    }

  }
}


It's working just as I want it now.

Thanks a lot bud! <3




Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You can't write to lines 2 and 3 if there is no line 1.

Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
I added this line to the command afterwards, before I added this I just messed around with the test by adding the 3 in line 1 manually.

Code:
 write -l1 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt 3 

So whenever they initialize this command by a switch I put in, this file will be created with -l1 being a 3.

So the file will always look like this.


Btw Loki, I just wanna say thanks so much, your help is really appreciated and it allows a scrub like me to make commands that I want actually work.
So from the bottom of my heart, to everyone who helps out here at the forums. Thank you!


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
When a number is the first line, it's treated as not actually being part of the file contents. If you $read(file,1), it will return 4103, and $read(file,2) will return 4020. You can get around this behavior by specifying the t switch $read(file,t,1), this treats the first line as text no matter what.

A comment on your logic, it doesn't make sense to limit !mmr solo edit 10 to the channel owner, but allow ops to use !mmr solo + 10, as either command can set it to the same value.

But you may just want to do some restructuring (this is testing and working):

Code:
on *:text:!mmr*:#: {
  var %file = mmr.ini
  var %solo = $readini(%file,n,$chan,solo)
  var %party = $readini(%file,n,$chan,party)

  if ($2 == $null) { msg $chan Solo: %solo | msg $chan Party: %party | return }

  if (# == # [ $+ [ $nick ] ]) || ($nick == nillens) { 
    if ($2 == solo) && ($3 == edit) { msg $chan Solo mmr is now $4 | writeini %file $chan solo $4 | return }
    if ($2 == party) && ($3 == edit) { msg $chan Party mmr is now $4 | writeini %file $chan party $4 | return }
  }

  if ($nick isop #) {
    if ($2 != solo) && ($2 != party) { msg $chan Specify if you played solo or party. | return }
    elseif ($3 != +) && ($3 != -) { msg $chan Did you go + or -? | return } 
    elseif ($4 !isnum) { msg $chan Sorry, $4 is not a number. | return }  

    else {
      var %item = $lower($2), %op = $3, %value = $4
      var %new.value = $calc(% [ $+ [ %item ] ] %op %value)
      writeini %file $chan %item %new.value
      msg $chan Current %item mmr is %new.value
    }
  }
}

Last edited by Loki12583; 28/01/14 05:18 PM.
Joined: Dec 2013
Posts: 779
N
Nillen Offline OP
Hoopy frood
OP Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Oh no, the edit was simply there when I was testing it out and didn't want random ops in the channel to mess around with the command.
Your code is probably 10x better than mine, it's at least way more compact. But I think I'll stick with mine cause of the feeling of making it myself (With your help ofc)

Code:
on *:text:!mmr*:#: {
  if ($($+(%,floodchan.,$chan),2)) || ($($+(%,flood.,$nick),2)) { return }
  set -u10 %floodchan. $+ $chan On

  if (# == # [ $+ [ $nick ] ]) || ($nick == nillens) {
    var %chan $chan
    if ($2 == on) && ($istok(%mmrs,#,32)) { msg # Mmr system is already on! | return }
    elseif ($2 == on) && (!$istok(%mmrs,#,32)) { set %mmrs $addtok(%mmrs,#,32) | msg # Mmr system now on! | write -l1 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt 3 | return }
    if ($2 == off) && (!$istok(%mmrs,#,32)) { msg # Mmr system is already off! | return }
    elseif ($2 == off) && ($istok(%mmrs,#,32)) { set %mmrs $remtok(%mmrs,#,32) | msg # Mmr system now off! | return }
  }

  if ($istok(%mmrs,#,32)) {
    var %chan $chan
    var %l2 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,1)
    var %l3 $read(C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt,2)

    if ($2 == $null) { msg $chan Solo: %l2 | msg $chan Party: %l3 | return }

    if ($nick isop #) { 
      if ($2 == solo) && ($3 == edit) { msg $chan Solo mmr is now $4 | write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt $4 | return }
      if ($2 == party) && ($3 == edit) { msg $chan Party mmr is now $4 | write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt $4 | return }
      if ($2 != solo) && ($2 != party) { msg $chan Specify if you played solo or party. | return }
      elseif ($3 != +) && ($3 != -) { msg $chan Did you go + or -? | return } 
      elseif ($4 !isnum) { msg $chan Sorry, $4 is not a number. | return }  

      elseif ($2 == solo) && ($3 == +) { 
        var %s+ $calc(%l2 + $4)
        write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %s+
        msg $chan Current solo mmr is: %s+ ( $+ %l2 + $4 $+ )
      }

      elseif ($2 == solo) && ($3 == -) { 
        var %s- $calc(%l2 - $4)
        write -l2 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %s-
        msg $chan Current solo mmr is: %s- ( $+ %l2 - $4 $+ )
      }

      elseif ($2 == party) && ($3 == +) { 
        var %p+ $calc(%l3 + $4)
        write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %p+
        msg $chan Current party mmr is: %p+ ( $+ %l3 + $4 $+ )
      }

      elseif ($2 == party) && ($3 == -) { 
        var %p- $calc(%l3 - $4)
        write -l3 C:\Users\Nillen\Dropbox\BOT\Mmrs\mmrs $+ %chan $+ .txt %p-
        msg $chan Current party mmr is: %p- ( $+ %l3 - $4 $+ )
      }


    }
  }
}

Is what the final script looks like for me.

And yeah, I know. I put if statements where I can simply use elses, it's cause it helps me understand what it is I'm writing when scripting it. It's a bad habit of mine.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Link Copied to Clipboard