Author Topic: [Turtorial]How to let your bot read a file.  (Read 171 times)

Glow

  • Trial Moderator
  • Junior
  • ***
  • Posts: 69
  • Reputation +3/-4
  • Gimme -1! Newbie mIRC scripter
  • Location: Netherlands
    • View Profile
[Turtorial]How to let your bot read a file.
« on: February 10, 2011, 06:38:02 am »
Hello,

Today I gonna explain you how you bot reads a file so you dont have to fill in everything in your script remote!

First of all you have to create the file. So for example create (a txt file) slap. Insert some funny things(each enter means another sentence).

Then the command!
First of all the normal
Code: [Select]
on *:TEXT:!slap*:#: {Then you have to let your bot read the file.
Code: [Select]
msg # %read C:\documents\slap.txt
}

The C:\documents\slap.txt is just an example. If you place it somewhere else note each step you take to your file.
So here the code you finally get:
Code: [Select]
on *:TEXT:!slap*:#: {
msg # %read C:\documents\slap.txt
}

If you didnt understand something you can ask me ;)

Jane: Modify Your Script Please, Thanks.
« Last Edit: February 10, 2011, 09:01:49 pm by Jane »

Share on Bluesky Share on Facebook


Jane

  • Management
  • Full
  • *******
  • Posts: 130
  • Reputation +1/-0
  • mIRC Scripters
    • View Profile
Re: [Turtorial]How to let your bot read a file.
« Reply #1 on: February 10, 2011, 07:24:45 am »
I Remmeber these scritps ;D it's nice for new bies to start learning. Good job!

King_Hual

  • Trial Moderator
  • Newbie
  • ***
  • Posts: 36
  • Reputation +3/-2
    • View Profile
Re: [Turtorial]How to let your bot read a file.
« Reply #2 on: February 10, 2011, 03:29:19 pm »
Hello. Today I'm REALLY gonna explain how the bot reads files. And to be more specific, how the bot reads a random line from a file. For example, the file will be C:\slap.txt. You can create it in any folder, and then just put the destination to it at the place where i put "file name", or the example file name.

Code: [Select]
on *:TEXT:!slap*:#: { It's obvious that this is the TEXT event.
 
Code: [Select]
msg # $read(C:\slap.txt, $r(1,$lines(C:\slap.txt) ) )
}
"$read(file name, line to read)" opens and reads the file (a specific line from it), and then returns the text from the line. To read the random lines like in the example above, just type $r(1, $lines(file name) ) where the "line to read" text is. "$lines(file name)" returns the total value of the lines. Like if you have 2 lines, it will return a value of 2.

And the full code:
Code: [Select]
on *:TEXT:!slap*:#: {
  msg # $read(C:\slap.txt, $r(1,$lines(C:\slap.txt) ) )
}

If you have any questions ask me, rookies  ;)
« Last Edit: February 10, 2011, 04:13:33 pm by King_Hual »