mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
on *:TEXT:!enemy:#: {
var %lines = 0
while ( $lines(enemy.txt) != %lines ) {
inc %lines
msg $chan 4 $+ $chr(35) $+ %lines $+ 12 $read(enemy.txt, %lines)
}
}
on *:TEXT:!enemyadd *:#: {
write enemy.txt $2-
}
on *:TEXT:!enemydel *:#: {
write -dl $+ $2 enemy.txt
}

I wonder what's wrong with it.. I copied it off another script and just changed a few things but I can't get it to work. =/

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
The logic has to be there for things to work

"If this is !=" might work in a while script, but isnt common syntax
Plus it is beter to put the value of what you are testing against into a variable so mIRC doesn't have to recheck that value every time it goes through the loop.

Code:
on *:TEXT:!enemy:#: {
  var %lines = 1
  var %lines.total = $lines(enemy.txt)
  while ( %lines <= %lines.total ) {
    msg $chan 4 $+ $chr(35) $+ %lines $+ 12 $read(enemy.txt, %lines)
    inc %lines
  }
}


the logic is, that while the value in %lines is less than or equalt to the value in %lines.total, sort of the same as != but can (theoretically) leave you with %lines being a larger number than %lines.total leaving you with a runaway loop.

I hope the number of lines in that file is small because dumping them all out with a while loop like that can lead to flooding off very quiickly

you might try this instead:

on *:TEXT:!enemy:#: { .play -q1 $chan enemy.txt }

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
I don't really care about flooding, I'm just wondering why it's not working.

The lines should stay at like 2-3, so no worries about flooding.

I'll try that last thing you gave though, maybe it'll help.

Edit: Still doesn't work, it doesn't remember the entries, it doesn't add them and it doesn't remove them. There must be something I'm missing here.

If I put all of this in a single script-file, and I load that, will it work?

Last edited by Noeptolemos; 07/12/05 04:16 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
There's nothing wrong with your !enemyadd command, so I don't know why it's not adding. As to deleting, you'd have to specify the line number in the !enemydel command that corresponds to the proper enemy.

You can easily have that entire script in one file..in fact, because the commands are relative to each other, I would recommend it.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
just checking, you are putting this script in a bot, and you then from another client (or other people) post the !enemy?

if Not, then look at using aliaseses to add remove and play the text

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
Exactly, I run it on one my servers here at home, and I/friends will type the !enemy and it should give a list. It's for an online game.

Also, I know how the deleting works, I got a script like this for !orders as well. I just copied the orders one, which works, and changed the .txts and the !enemy(add/del).

Still wondering why it wouldn't work. :x

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Put it all in its own mrc, if you have other "on text" events in there it may be that one above these is too generic and thus firing before (and stopping) this one. you can also reload -rs1 that.mrc to move it above all others and hopefully prevent the conflict if there is one.


Link Copied to Clipboard