mIRC Homepage
Posted By: ChickyChan one-time notice on join - 10/09/12 11:34 PM
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.
Posted By: KindOne Re: one-time notice on join - 11/09/12 01:16 AM
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
  }
}
Posted By: ChickyChan Re: one-time notice on join - 11/09/12 02:55 AM
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?
Posted By: Loki12583 Re: one-time notice on join - 11/09/12 03:49 AM
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)) {
Posted By: ChickyChan Re: one-time notice on join - 11/09/12 08:46 AM
Thanks, it's working fine.
© mIRC Discussion Forums