mIRC Home    About    Download    Register    News    Help

Print Thread
#240590 17/02/13 04:53 PM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
I'm making a script, which uses this.
Quote:
set %announcer 1
set %remainer $read(remaining.txt, %announcer)
while (%remainer != $null) {
if (%remainer ison #test) {
notice %remainer $1-
write -ds $+ %remainer remaining.txt
}
inc %announcer 1
set %remainer $read(remaining.txt, %announcer)
}

it basically reads through a txt file, and see's if someone is on channel, if they are, it'll send them a /notice, it will then delete them from the file. Althoguh i'm having some problems, it only seemed to notice the first person. I'm starting to think that it's the if statement in the while loop, would that stop it looping perhaps?

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
I don't see an immediate flaw in your script.
From how you use $read I assume the .txt file only contains nicknames?
Also, you can probably use local variables instead of global ones here (or do you need the variables in other events too?)
I have rewritten the script to be more condensed/'simpler'.
Does this perhaps work for you?

Code:
var %announcer = 1
while ($read(remaining.txt,n,%announcer)) {
  if ($v1 ison #test) {
    notice $v1 $1-
    write -ds $+ $v1 remaining.txt
  }
  inc %announcer
}

5618 #240592 17/02/13 06:01 PM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
didn't seem to work, maybe it's because It doesn't really work with the rest of the script.
this is the full script:
Code:
alias announce { 
  if ($1 == $null) { 
    echo 4 -a Add a message to announce!
    halt
  }
  writeini announce.ini set true 1
  copy -o people.txt remaining.txt
  set %announcer 1
  set %remainer $read(remaining.txt, %announcer) 
  while (%remainer != $null) {
    if (%remainer ison #test) {
      notice %remainer $1- 
      write -ds $+ %remainer remaining.txt 
    }
    inc %announcer 1
    set %remainer $read(remaining.txt, %announcer)
  }
  if ($read(remaining.txt, 1) == $null) {
    writeini announce.ini set true 0
  }
}
on *:JOIN:#test: {
  if ($readini(announce.ini,set,true) == 1) {
    set %remainer $read(remaining.txt, s, $nick) 
    if (%remainer != $null) { 
      notice %remainer $1- 
      write -ds $+ %remainer remaining.txt
    }
  }
}

Do you reckon you could modify my entire script please smile? I would, but I have never really done the kind of things you used in script you did.

as for global or local variables, I don't know, I guess global to be on the safe side laugh

EDIT:
____________
OMG, can't believe I forgot to note down the announcement message so if someone joins, the script didn't know what it was saying! lol, i'm such a derp
I'll let ya know if it works once i added the message thing.

EDIT: AGAIN
________________
i replaced notice wooolly $1- with $readini(announcement.ini(ETC)) so the script knew what it was actually announcing lol, but it still didn't work unfortunatly. Only send message to the first person on list, and when i /hop'ed, it didn't send notice to person.

Last edited by dominic_eddy; 17/02/13 06:23 PM.
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
Anyone got any ideas smile?

Joined: Oct 2012
Posts: 164
D
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
You should change this line (in the on join event)
Code:
$read(remaining.txt, s, $nick)
to
Code:
$read(remaining.txt,nw,$nick)

Using the s switch for read only returns the text which comes after the matched text, which in this case is nothing.
Originally Posted By: mirc.hlp
//echo $read(info.txt, s, mirc)
Scans the file info.txt for a line beginning with the word mirc and returns the text following the match value.

Deega #240618 18/02/13 09:19 AM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
aw thaks man! smile join is working perfectly now, only thing tat's still a bit messed up is the announcement alias :S i tested it with 3 names in the list to begin with, all 3 we're in chan, and it sent message to only 2, then i added a 4th one, and switched the names round abit to see if it was anything to do the order, and it still only announced to the 2 nicks :S lol.
That puzzles me :S

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
The problem is possibly caused by the fact that two present nicks are right beneath one another in the .txt file. Because you delete a line from the file on a match, increasing the value of %announcer will actually mean you skip one line on the next $read()

5618 #240624 18/02/13 09:59 AM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
um, I get what your saying, good point! i'll have a little look around and see what I can do. maybe soemhow only increade %announcer if the curent nick isn't on #test.

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
or cheat and dec %var first when it is

5618 #240626 18/02/13 10:50 AM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
Thank god! Finally it's working, thanks all! much appreciated


Link Copied to Clipboard