mIRC Homepage
Posted By: Shark1 Script help - 01/07/10 06:05 PM
hey
I'm writting a script and i need help.
I want to do a script which calls every user on a channel.

For example:
On channel X are 4 users. When I type in the command (!yell for example) the script will call all 4 user like this:

Quote:
[xx:xx:xx] <Script> user1
[xx:xx:xx] <Script> user2
[xx:xx:xx] <Script> user3
[xx:xx:xx] <Script> user4
Posted By: DJ_Sol Re: Script help - 01/07/10 06:14 PM
Code:
;on text if someone says !yell in a channel (#)
on *:text:*!yell:#:{

;count the number of nicks in channel and store number to a local variable %c_
  var %c_ = $nick(#,0)

;while %c_ is not $null
  while (%c_) {

;message in channel that users nick.
    msg # $nick(#,%c_)
    dec %c_
  }
}



This will respond to anyone saying !yell. You can use mirc user levels or write code for it to only respond to specific nicknames. I didn't want to make it more complicated. Let us know if you need help with this.
Posted By: Shark1 Re: Script help - 01/07/10 08:13 PM
Originally Posted By: DJ_Sol
Code:
;on text if someone says !yell in a channel (#)
on *:text:*!yell:#:{

;count the number of nicks in channel and store number to a local variable %c_
  var %c_ = $nick(#,0)

;while %c_ is not $null
  while (%c_) {

;message in channel that users nick.
    msg # $nick(#,%c_)
    dec %c_
  }
}



This will respond to anyone saying !yell. You can use mirc user levels or write code for it to only respond to specific nicknames. I didn't want to make it more complicated. Let us know if you need help with this.


Yes, it works great now. I managed to specify the nicknames (actualy levels). That didn't make me any problems, the only real problem was the code it self.

Thank you for your help and quick response.
Posted By: Riamus2 Re: Script help - 01/07/10 08:15 PM
Be aware that unless you have flood protection enabled in mIRC's settings, you will get flooded off a server if you have more than 4-6 people. And, depending on the channel, you may get banned for even 3 people if you do it often enough.
Posted By: Tomao Re: Script help - 01/07/10 10:54 PM
Yeah, It'd be better to add a timer and trigger flood protection to the current code. And I don't suppose you want to yell at the client that runs the code either:
Code:
on *:text:!yell:#:{
  if (!%x) {
    inc -u5 %x
    var %c_ = $nick(#,0)
    while (%c_) {
      if ($nick(#,%c_) != $me) {
        .timer 1 $calc(%c_* 2) msg # $v1
      }
      dec %c_
    }
  }
}

Posted By: chacha Re: Script help - 02/07/10 08:27 AM
or /play
Posted By: jaytea Re: Script help - 02/07/10 01:59 PM
careful! you need a space in between '%c_' and '*' there
Posted By: chacha Re: Script help - 02/07/10 05:09 PM
i think that with the command /play is better because if the nicklist is not yet finished another user could repeat !yell after 5 sec and execute the code again
Code:
on *:text:!yell:#:{
  if !$play(#) {
    tokenize 3 $regsubex($str(.,$nick(#,0)),/./g,$+($nick(#,\n),$chr(3)))
    write tmpfile $*
    .play # tmpfile
    .remove tmpfile
  }
}
Posted By: Tomao Re: Script help - 02/07/10 05:27 PM
@chacha: that is one good way you've provided. :-) Yes, I agree with you, especially when dealing with a big channel.
@Jaytea: thanks for the reminder, but it works without a space after the variable though.
Posted By: jaytea Re: Script help - 02/07/10 07:38 PM
it doesn't, if that were allowed it would create ambiguity since '*' is a valid character in a variable name. see:

Code:
//var %c_ = 3 | echo -a $calc(%c_ * 2) - $calc(%c_* 2) - $calc($null 2)


%c_* is quite clearly being treated as $null there since, presumably, a variable named %c_* doesn't exist.

chacha: there's also /filter -wlfc # tmpfile which, since we're already straying from the original script by omitting the (<nick> != $me) check, will include the status prefix of each nickname (@%+ etc.) if there is one to include. it saves us having to resort to such measures as a $regsubex() loop which are all but overused these days :P

there's also the possibly of receiving a * Line too long: $regsubex error with a suitably massive nicklist
© mIRC Discussion Forums