mIRC Home    About    Download    Register    News    Help

Print Thread
how to halt onjoin script if user joining is oper #212746 01/06/09 03:05 PM
Joined: Nov 2006
Posts: 5
C
CSC2YA Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Nov 2006
Posts: 5
I've got an mirc script for a helpdesk bot. The main function of this is to monitor how many people are in helpdesk vs how many poeple are voiced and how many people in there are server operators.

The bot will then give the user joining an approximate waiting time, and will also tell them which number they are in line.

However, I can't figure out how to stop it messaging server operators when they join the helpdesk.

The script that deals with this is as follows:

Code:
on !*:JOIN:%help.chan: {
  timer 1 5
  whois $nick
  if ($nick isop $chan) halt
  if ( $readini(uhelp.ini,config,stat) ) {
    writeini uhelp.ini $chan $_n1($nick) help
    .notice $nick Please wait for your turn as we are busy right now. You will be voiced automaticly when we finish with the current guests. You are number $ini(uhelp.ini,$chan,0) in line. Thank You
  }
}
 


I've tried it with isop and isoper, but neither of these are working correctly.

At the moment it messages everyone that joins, whether or not they are an operator.

Last edited by CSC2YA; 01/06/09 03:06 PM.
Re: how to halt onjoin script if user joining is o [Re: CSC2YA] #212747 01/06/09 03:48 PM
Joined: Jul 2006
Posts: 3,697
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,697
The timers command isn't like a "sleep", you have to give a command to be executed when the timer trigger, like after an if statement and the script isn't waiting with a timer.
Also, when a user is joining a channel, usually, there is a little time before the server or a bot put the user with the right access, this means you don't know if the user is op during the on join event, so the condition is false, you need to use a correct timer to delay the 'check' :

Code:
on !*:JOIN:%help.chan:.timer 1 5 checking_nick $nick $chan
alias checking_nick {
whois $$1 $1
if ($1 !isop $$2) && ($readini(uhelp.ini,config,stat)) {
    writeini uhelp.ini $2 $_n1($1) help
    .notice $1 Please wait for your turn as we are busy right now. You will be voiced automaticly when we finish with the current guests. You are number $ini(uhelp.ini,$2,0) in line. Thank You
 }
}


Last edited by Wims; 01/06/09 03:48 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how to halt onjoin script if user joining is oper [Re: CSC2YA] #212748 01/06/09 03:51 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The problem is the fact that at the time of joining, all users are regular users. No one has ops, half-ops, voice, admin, etc. at the time of joining.

What you can do is to use a timer to delay the check if the person is opped or not. In fact, that appears to be what you have attempted to do, but your timer line is incomplete.

Code:
on !*:join:%help.chan:{
  .whois $nick
  .timer 1 5 check_ops $nick $chan
}
alias -l check_ops {
  if $1 !isop $2 {
    if ( $readini(uhelp.ini,config,stat) ) {
      writeini uhelp.ini $2 $_n1($1) help
      .notice $1 Please wait for your turn as we are busy right now. You will be voiced automaticly when we finish with the current guests. You are number $ini(uhelp.ini,$2,0) in line. Thank You
    }
  }
}


Re: how to halt onjoin script if user joining is oper [Re: CSC2YA] #212751 01/06/09 08:25 PM
Joined: Nov 2006
Posts: 5
C
CSC2YA Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Nov 2006
Posts: 5
Thanks. That code worked exactly how I needed it to.

I haven't coded for mirc for a long time (I run linux as my main OS and only use windows to run my irc server and mirc based bots on)

I completely forgot how to do timers as a result.

Thanks again for the help.

Re: how to halt onjoin script if user joining is oper [Re: CSC2YA] #212805 05/06/09 09:05 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
You don't have to wait 5 seconds to check if the nick is an op. You can usually check that after a second.

I use a generic 3 second timer that makes sure the nick is still on the channel before performing any commands.