mIRC Homepage
Posted By: Akatsuki mIRC Scripting - 15/07/05 08:19 AM
I have a very simple bot and I really want to improve it to liven up the channel I'm at. I'm really a newbie at mIRC scripting so I really want to learn more about it. If you can help me, it would be much appreciated.

I've seen these scripts on other channels but I have no idea how people scripted them.

One script is that if a user joined the channel, if the first thing he/she said is "hi" or "hi everyone" or something similar, the bot would say hi to the person. If the user doesn't say hi right after they join, but they say hi minutes later, the bot won't welcome them. If a user out of nowhere said "hi" to a friend they knew, the bot won't welcome them either.

Another script is a fun one. If someone typed the trigger:
!stab blah blah blah
The bot would respond by stabbing "blah blah blah", something like this:
Bot stabs blah blah blah 234 times.
The number is random.

Thanks in advance.
Posted By: defiant Re: mIRC Scripting - 15/07/05 10:16 AM
For the "Hi" part:

on 1:JOIN:#: {
set % $+ $nick 1
.timer 1 60 unset % $+ $nick
}
on 1:TEXT:*hi*:#: {
if (% [ $+ [ $nick ] ] == 1) {
.msg # Hiya $nick
unset % $+ $nick
}
}
--
When someone joins, a small variable is stored. When the person types something with "hi" in it, during the first minute, the bot will greet.

2nd thingy:
on 1:TEXT:!stab*:#: {
.timer -m 1 500 describe $chan stabs $2 $rand(100,999) times.
}
Posted By: Kelder Re: mIRC Scripting - 15/07/05 02:41 PM
No need for timers here
And I'd add something before the nick as the variable, you don't want someone called i throw off your global counter variable %i do you smile

You can leave out the green part if you don't like/understand it, it's just some extra checking that you don't say hi when someone starts with 'hilight me plz' or something smile

on 1:JOIN:#: {
set -u60 %chanjoin. $+ $nick 1
}
on 1:TEXT:hi*:#: {
if (%chanjoin. [ $+ [ $nick ] ] && $regex($1-,/^hi\b/is) ) {
.msg # Hiya $nick
unset %chanjoin. $+ $nick
}
}
Posted By: Akatsuki Re: mIRC Scripting - 15/07/05 06:32 PM
Wow. Thanks for the help you guys! mIRC scripting is really confusing, I'll try my best to learn.

Oh yeah, is there a way that I can make my bot say stuff in all caps? I'm working on this script:

Quote:

on *:text:!stamp*:#: {
if (%stamp == off) { describe # stamps on nick: TRIGGER IS DISABLED. }
else {
{ set %stampee $2 }
{ set %text $3- }
describe $chan stamps on %stampee $+ : %text $+ . }
}
alias stamp.on {
set %stamp on
}
alias stamp.off {
set %stamp off
}
menu channel {
Stamping
.on:/stamp.on
.off:/stamp.off
}


I want to make the %text be in all caps.
Posted By: Riamus2 Re: mIRC Scripting - 15/07/05 07:10 PM
$upper(text) will return text in all caps.
Posted By: Akatsuki Re: mIRC Scripting - 15/07/05 08:20 PM
Thanks for the help!

About the random numbers, is there a way I can make something else random?

For instance if someone types "<3" in a channel, the bot will respond by typing a random number of <3. It can range from one <3 to a hundred <3's. The <3 will be in random colors of red (ctrl+k 4) and pink (ctrl+k 13). And if someone types "<3 20", the bot will respond by typing 20 <3's.

Sorry if I'm asking too much. Thanks.
Posted By: Riamus2 Re: mIRC Scripting - 15/07/05 08:32 PM
First, you'd have to decide how to trigger it. Obviously you don't want the bot to respond to everything like that.

Here's a basic idea that you can build off of:

Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    msg $chan $str($1,$2)
  }
  else msg $chan $str($1,$rand(1,10))
}


That will display the text the number of times in a single color.

If you want random coloring, you'll need to do something like this:

Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    set %counter 1
    while (%counter &lt;= $2) {
      var %color $iif($rand(1,2) == 1,04,13)
      set %output %output $+  $+ %color
      inc %counter
    }
    msg $chan %output
  }
  else {
    set %counter 1
    while (%counter &lt;= $rand(1,10)) {
      var %color $iif($rand(1,2) == 1,04,13)
      set %output %output $+  $+ %color
      inc %counter
    }
    msg $chan %output
  }
  unset %output
  unset %counter
  unset %color
}


That should display random colors of 04 and 13 for each heart.

Note that for both of these, I limited the default random number of repeats to 1-10. You can change that if you like. Just replace all the $rand(1,10) with whatever number instead of 10.
Posted By: Akatsuki Re: mIRC Scripting - 15/07/05 11:14 PM
Thanks.

The first script with the single colors worked fine but when I tested out the second script with the random colors by typing in "<3" the bot responded with a space.

me: <3
Bot:

Did I do something wrong? All I did was change "#yourchan" into the name of the channel I'm at.
Posted By: MikeChat Re: mIRC Scripting - 16/07/05 01:39 AM
oops, in the second section you forgot to include the actual string
try this
Code:
on *:text:&lt;3*:#yourchan: {
  if ($2 isnum) {
    var %string = $str(&lt;3 $chr(32) ,$2)
    var %counter = 1
    while (%counter &lt;= $2) {
      var %color = $iif($rand(1,2) == 1,04,13)
      var %output = %output $+ %color $+ $gettok(%string,%counter,32) 
      inc %counter
    }
    msg $chan %output
  }
  else {
    var %repeat = $r(1,10)
    var %string = $str(&lt;3 $chr(32) ,%repeat)
    var %counter = 1
    while (%counter &lt;= %repeat) {
      var %color = $iif($rand(1,2) == 1,04,13)
      var %output = %output $+ %color $+ $gettok(%string,%counter,32)
      inc %counter
    }
    msg $chan %output
  }
halt
}


Note I used local vars as there is no outside event that will use the vars (/set)
Posted By: Akatsuki Re: mIRC Scripting - 17/07/05 12:18 AM
Thanks a lot!
Posted By: Riamus2 Re: mIRC Scripting - 18/07/05 01:22 PM
Good catch, MikeChat. Sorry about that.
© mIRC Discussion Forums