mIRC Pokemon Friend Code Adder + Database

By GoldenTEx on Oct 11, 2008

The code works very simple. (For Pokemon Diamond/Pearl)
The syntax is !addfc #### #### ####
The code will check if the friend code is 4 digits spaced out, and if not, it'll reply with an error message. If the friend code is in correct syntax (Not knowing if possible for the Nintendo database to add, just checks the normal standards of the codes), then it'll write a line in the database. Only you as the owner can access the database to ensure privacy.

on *:TEXT:!addfc *:*: {
  if ($len($2) == 4) && ($2 isnum) && ($len($3) == 4) && ($3 isnum) && ($len($4) == 4) && ($4 isnum) {
    write fc.txt $nick : The FC for him or her is : $2-5
    notice $nick You have successfully added your friend code to the database.
  else {
  notice $nick Invalid friend code. To let my owner add your friend code, please say !addfc friendcode . Replace friendcodehere with your 12 digit friend code with spaces every 4 numbers. }


Sign in to comment.
Jethro   -  Jan 05, 2010

I guess it was just a fluke for GoldenTEx to script...as he's not been active since oct. of last year.

Sapphy   -  Jan 04, 2010

Where's the database? lol

GoldenTEx   -  Oct 12, 2008

Thanks for your feedbacks.
Of course, this was just a first code to start with for me.
I'll start to code a little better as I do more.

Typo   -  Oct 12, 2008

Two things I noticed right off, one is you use $2-5 instead of $2-4 which would allow extra data in since you never check if (!$5).
The second thing is..

if ($len($2) == 4) && ($2 isnum) && ($len($3) == 4) && ($3 isnum) && ($len($4) == 4) && ($4 isnum) {

Could be changed to

if ($len($remove($2-4,$chr(32))) == 12) && ($remove($2-4,$chr(32)) isnum) {

I know its not a lot shorter but it does give you a great example of creative thinking to bring down the amount of ifs you need.

You should also consider checking the input against the file to make sure it doesnt already exist to avoid someone adding the same number a thousand times.

The code in general is a very simple one, almost too much so.

Keep up the coding. :)

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.