mIRC Home    About    Download    Register    News    Help

Print Thread
#238951 10/09/12 11:34 PM
Joined: Apr 2012
Posts: 5
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2012
Posts: 5
I want to /notice someone who joined my channel if he's joining with his nick for the first time.
So if he joins my channel a second time the /notice would not occur.
I thought about using a text file and make my script check whether the name is in the file or not.
If the name is written in the textfile nothing would happen.
If the name is not in the textfile the script would execute and add the one who's triggered the script to the textfile so the script wouldn't be triggered again if he joined.

I've got this so far but it doesn't work at all.

Code:
on *:JOIN:#mychannel:{
var %person = $read(people.ini)
  if ($readn == 0) 
  {
    /notice $nick Good day! 
    /write people.ini $nick
  }
}


Any help would be appreciated.

Last edited by ChickyChan; 10/09/12 11:45 PM.
Joined: Feb 2011
Posts: 448
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 448
Code:
  if ($readn == 0) 
  {

The opening brace '{' can't begin a line. This was causing the script to fail.


You don't need '/' inside of scripts, you can have them if you like, but they are not needed.

Corrected script.
Code:
on ^*:JOIN:#mychannel:{
  var %person = $read(people.ini)
  if ($readn == 0) {
    notice $nick Good day! 
    write people.ini $nick
  }
}

Joined: Apr 2012
Posts: 5
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2012
Posts: 5
Thanks, at least the error message doesn't appear anymore.
But the script still does nothing.
I figured that
Code:
var %person = $read(people.ini)

nor
Code:
set %person $read(people.ini)

do anything.

Then I simply tried
Code:
  if ($nick != $read(people.ini,s,$nick)) {
    notice $nick Good day! 
    write people.ini $nick
  }

However, even if the person who triggered the script is in the .ini file it would still reply with "Good day!".
I suspect that I can't use $read in that situation.
Is there any other solution?

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
The s switch will return the rest of the line (excluding the first word). Use the w switch instead, and always use the n switch to prevent evaluation of the line unless you specifically need to. Prepend the $read alias with ! to negate its return value, so that the statements inside the block are run if the name is not found.

Also, .ini files have a specific formatting you aren't using. Just use .txt.

Code:
if (!$read(people.txt,nw,$nick)) {

Joined: Apr 2012
Posts: 5
C
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Apr 2012
Posts: 5
Thanks, it's working fine.


Link Copied to Clipboard