mIRC Home    About    Download    Register    News    Help

Print Thread
#138639 04/01/06 11:40 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
hi all

Somehow I'm not getting this right.
I working on a personal bot and it has a truth or dare game.
Now I would like the people who have ops in my room to add or delete questions.
The add part works fine and with the -d switch the last line delete works fine but to delete a specific question that is a problem.
I read the help file and it says that the -s and -w switch are needed to delete questions with spaces.
But it doesn't seem to work.
What am I doing wrong ?
Here is my code:
Code:
 On *:TEXT:.tdvoeg*:?: {
  /write scripts\questions\truths.mrc $2-
}
On *:TEXT:.tdwis*:?: {
  /write -ds $+ $2- scripts\questions\truths.mrc
 }
 


I hope some can tell me what I am doing wrong.

Greetzz

#138640 04/01/06 11:55 AM
Joined: Jul 2005
Posts: 37
G
Ameglian cow
Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
if i understand you u want to del a full line
try /write -DL(number of the line to be del)
make it search for the text and get the line number

Last edited by gans; 04/01/06 12:01 PM.
#138641 04/01/06 12:05 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
The problem is when a op wants to delete a line he or she has no idea what the line number is so that option doesn't work.

#138642 04/01/06 12:42 PM
Joined: Jul 2005
Posts: 37
G
Ameglian cow
Offline
Ameglian cow
G
Joined: Jul 2005
Posts: 37
ok well the problum with your way is that $2- has space in it so as soon as it gets to the filename its trying to look up text($2) that was in the $2- so the only way u can do it is like this

On *:TEXT:.test*:#: {
var %loop = 1
while (%Loop <= $lines(scripts\questions\truths.mrc)) {
if ($2- isin $read(scripts\questions\truths.mrc,%loop)) { /write -dl $+ %loop scripts\questions\truths.mrc }
inc %loop
}
}

#138643 04/01/06 01:02 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
Thank you very much .....
I had no idea it would be like this.

#138644 04/01/06 07:43 PM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
I hate to be the pedantic one but;

Remember when you delete a line from the file
you're still doing inc %loop
which has really skipped a line since the file would then
have one less line in it.

maybe some code like

while ($read(filename,w,*something*)) {
write -dl $+ $readn filename
}

This might not do as you want if the something string contains wildcards already though.

Maybe /filter would make cleaner faster code.

#138645 04/01/06 10:50 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
From my experience, and after reviewing the suggestions submitted so far, Hitchhiker's code is the closest to what you're looking for.

Since you want to find text that is being entered from someone else, I would do it like this
Code:
 on *:text:.tdwis*:#:{
if ($nick isop $chan) {
while $read(filename,w,$+(*,$2-,*)) {
write -dl $+ $readn filename
}
}
}
 

Note: This will delete ALL lines in the file that contain the information being passed via $2-.
It will only work for a person that is opped in the channel when they give the command. If they aren't opped, the command will be ignored.


Link Copied to Clipboard