mIRC Homepage
Posted By: R34N1M4T3D Allowing Certain People To PM - 26/04/04 06:54 AM
I hate going into a room and having people I don't know whisper me with "asl" and such nonsense. But I want my friends to PM me, How would I go about this?
I know to have anyone who PM's me say a message is

Code:
 on *:text:*:?:/msg $nick message 
Posted By: LocutusofBorg Re: Allowing Certain People To PM - 26/04/04 09:59 AM
Judging from what your post title is, I assume you mean you don't want to receive any msgs within, say, 10 seconds from entering a channel. If it is not, be more specific.

Code:
[color:green]; when you join any channel[/color]
on *:JOIN:#: {
  [color:green]; add the channel to a list - people are not  allowed to msg you from those[/color]
  %chans = %chans $chan
  [color:green]; remove the channel after 10 secs[/color]
  .timer 1 10 %chans = $remtok(%chans,$chan,1,32)
}
[color:green] [/color]
[color:green]; when you receive a PM[/color]
on *:OPEN:?:*: {
  [color:green]; create a setting to detect what we want[/color]
  set %tmp 1
  [color:green]; check if the user is in a forbidden channel[/color]
  var %i = $numtok(%chan,32)
  while (%i) { if ($nick ison $gettok(%chan,%i,32)) unset %tmp | dec %i }
  [color:green]; if not found, ignore, else allow[/color]
  if (%tmp) { unset %tmp }
  else { .timer 1 0 close -m $nick }
}
Posted By: FiberOPtics Re: Allowing Certain People To PM - 26/04/04 10:04 AM
Hi,

you could use this code:
Code:
 
on ^*:OPEN:?:*: if !$istok(%friends,$nick,44) { .msg $nick I'm not accepting private messages right now | halt } 


This is just an example where someone opens a query to you, it will check if it's nickname is in the variable %friends, if it isn't, it will message them with that msg, and simply halt mIRC from opening the queryt. That's why I've used the ON OPEN event.

There are of course many variations possible. You could e.g. use user levels and then use the /auser command. There are always multiple ways of achieving soemthing.

You could also add a 'Pager' that will let you know if someone tried to message you (maybe u forgot to add a friend to the variable %friends) and atleast you will see that someone tried to msg you.

Example:
Code:
#msgblocker on
on ^*:OPEN:?:*:{ 
  if !$istok(%friends,$nick,44) { 
    if !$window(@queries) { window @queries }
    aline -h @queries $timestamp $nick $+ : $1-
    .notice $nick I'm not accepting private messages right now 
    halt 
  } 
}
#msgblocker end
 [color:red]  [/color] 
Menu nicklist {
  Msgblocker
  .Add Nick:{ %friends = $addtok(%friends,$1,44) | echo -a $1 has been added to your friends list }
  .Remove Nick:{ %friends = $remtok(%friends,$1,1,44) | echo -a $1 has been removed from your friends list }
  .-
  .$iif($group(#msgblocker) == on,Disable,Enable) Msgblocker:{
    if ($group(#msgblocker) == on) disable #msgblocker
    else enable #msgblocker
  }
} 


You'll notice that I added a Nicklist popup wiht it, where u can enable/disable this script, and you can add/remove friends.

Note that variables have a limit to the amount of characters they contain. If you have hundreds of friends, you're better of with using for instance a Hash Table.

Example:
Code:
  
#msgblocker on
on ^*:OPEN:?:*:{ 
  if !$hget(friends,$nick) { 
    if !$window(@queries) { window @queries }
    aline -h @queries $timestamp $nick $+ : $1-
    .notice $nick I'm not accepting private messages right now 
    halt 
  }
}

on *:START:{ hmake friends | hload friends $+(",$mircdir,friends.txt,") }
on *:EXIT: hsave -o friends friends.txt 

#msgblocker end
 [color:red]  [/color] 
Menu nicklist {
  Msgblocker
  .Add Nick:{ hadd friends $1 blah | echo -a $1 has been added to your friends list }
  .Remove Nick:{ hdel friends $1 | echo -a $1 has been removed from your friends list }
  .-
  .$iif($group(#msgblocker) == on,Disable,Enable) Msgblocker:{
    if ($group(#msgblocker) == on) disable #msgblocker
    else enable #msgblocker
  }
}


Here you can simply put in an unlimited number of nicknames, as hash tables can store huge amounts of information. When you start mIRC it will load the friends.txt into a hash table, and when exiting mIRC, it will save to file.

Hope this was somewhat helpful to you!

Greetz
Posted By: Iori Re: Allowing Certain People To PM - 26/04/04 12:11 PM
To have say only people on your notify list msg you.
Code:
on ^*:open:?:{
  if !$notify($nick) { halt } 
}
Posted By: R34N1M4T3D Re: Allowing Certain People To PM - 26/04/04 06:33 PM
All 3 scripts were very useful. Thank yall. I'm going to go ahead and use the easiest one until I can play a little with the more advanced ones. Still learning my things so bare with me please.
Code:
  alias /PMon { set %awy.stat on | echo -a Away Skript 0n | /say Away Script On

  if ($1 != $null) { set %awy $1 }
  set %reason $$?="Reason?"
}
alias /PMoff { unset %awy.stat | echo -a Away Skript Off | /say Away Script Off }
On ^*:open:?:{
  if (%awy.stat == on) {{ msg $nick Sorry I'm Currently Away  Right Now %reason $+ , Please Leave A Message and I'll Get Back To You As Soon As I Can
} 
if !$notify($nick) {halt} }

}


I don't know where I'm messin up. Can someone help? confused
Posted By: FiberOPtics Re: Allowing Certain People To PM - 26/04/04 06:50 PM
Hi,

your were misusing the braces {}

Now, while I know of better ways to create an away script, i tried to edit your script the least as possible, so that you can experiment yourself in making it better:
Code:
  
alias PMon { 
  %awy.stat = on
  echo -a Away Skript 0n | say Away Script On
  if ($1) { set %awy $1 }
  set %reason $$?="Reason?"
} 
[color:red]  [/color] 
alias PMoff { %awy.stat = off | echo -a Away Skript Off | say Away Script Off }
 [color:red]  [/color] 
on ^*:open:?:{
  if !$notify($nick) { halt }  
  if (%awy.stat == on) { .msg $nick Sorry I'm Currently Away Right Now %reason $+ , Please Leave A Message and I'll Get Back To You As Soon As I Can } 
}


I'm curious though why you are doing set %awy $1, since you're not using that variable %awy anywhere else.
Btw I changed the order of if !$notify($nick) { halt } and where it says that you are away. Because people who are not on your notify list, cannot leave a message, so then you might as well simply already halt the script there, before telling them that you are away.

Greetz
© mIRC Discussion Forums