mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2004
Posts: 45
N
Navid Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
Hello.
I asked a few people in irc, and as always they dont know much lol, so i came here again smile.
I have a characters.ini and in that I have
[chr1]
chrname=Chr1
hp=50
energy=20
attack=20
defense=15
planet=earth

and I wish to write a code that it will directly writeini in $nick.ini all that I have under the topic [chr1].
I thought of /copy but I'm not sure how to use that (there is no examples on /help).
Thanks for helping around

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I'm not familiar with ini files, but it seems to me that something like this should work
Code:
/copy characters.ini $+($nick,.ini)

That, realistically, just creates a copy of the characters.ini file using the name <nick>.ini

If that doesn't work, then try reading the information from the ini file you already have, line by line, then writing it to a new ini file. I can see how this method could be significantly longer depending on the amount of information haing to be read and then written.

Joined: Feb 2004
Posts: 45
N
Navid Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
well I'm am trying to use this technic to avoid writing all the writeini codes in the remote and instead just put
<something to copy> Characters.ini $2
writeini $nick <something to copy, including after the =>

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Try this

Code:
 alias copychar {
  var %file = characters.ini
  if ( $ini(%file,$$1) ) {
    var %w = 1
    while ( $ini(%file,$1,%w) ) {
      writeini $+($1,.ini) $1 $v1 $readini(%file,$1,$v1)
      inc %w
    }
    echo -a ** Done copying topic $+(",$1,") to $+($1,.ini)
  }
  else echo -a ** $$1 does not exist 
} 


Syntax: /copychar <topic>

**Change characters.ini if needed


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Feb 2004
Posts: 45
N
Navid Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
I'm not good with wildcards or scans, but can I use something like
/copy -a characters.ini testing.ini,w,* $+ $2 $+ *
and so it searches any wildcards starting with the $2, it directly copies it and pastes everything in it to the testing.ini.

I dont use .ini either, its just very basic and people know it smile

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
/copy is copies files or appends it to existing files.

Quote:
/copy -ao <filename> <filename>
Copies a file to another filename or directory. You can also use wildcards for the source filename, and a directory name for the destination. The -o switch overwrites a file if it exists. The -a switch appends the first file to the second one.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Feb 2004
Posts: 45
N
Navid Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
Thanks Xdaemon Your Code work smile Thanks a lot!. My life is made easyier now ^_^

EDIT: for var %file = characters.ini my characters.ini file is in a folder called bot_stats, I tried var %file = Bot_Stats\characters.ini and $findfile(Bot_Stats,Characters.ini) none worked. blush
any ideas?

EDIT: Lol sorry I fixed that, minor problem. Thanks again. This is how I have it.
Code:
copychar {
  var %file = Bot_Stats\Characters\ $+ $2 $+ .stats
  if ( $ini(%file,$$1) ) {
    var %w = 1
    while ( $ini(%file,$1,%w) ) {
      writeini Members\ $+ $+($1,.ini)$nick stats $v1 $readini(%file,$1,$v1)
      inc %w
    }
    echo -a ** Done copying topic $+(",$1,") to $+($1,.ini)
  }
  else echo -a ** $$1 does not exist 
}


and in my !register code i got
/copychar $2
and its keeps on saying ** DiGiTaL does not exist

Last edited by Navid; 18/07/05 07:22 PM.
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Quote:
and in my !register code i got
/copychar $2
and its keeps on saying ** DiGiTaL does not exist


On the variable %file, you changed the filename & it requires a 2nd parameter but when you called the alias, you didn't put a second parameter that's why it's giving you the error message.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Feb 2004
Posts: 45
N
Navid Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Feb 2004
Posts: 45
Okay all FIXED Thank you very much smile


Link Copied to Clipboard