mIRC Home    About    Download    Register    News    Help

Print Thread
#222734 01/07/10 06:05 PM
S
Shark1
Shark1
S
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

#222736 01/07/10 06:14 PM
Joined: Jan 2007
Posts: 1,155
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,155
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.

DJ_Sol #222749 01/07/10 08:13 PM
S
Shark1
Shark1
S
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.

#222751 01/07/10 08:15 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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.

Riamus2 #222754 01/07/10 10:54 PM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
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_
    }
  }
}


Tomao #222760 02/07/10 08:27 AM
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
or /play

Tomao #222766 02/07/10 01:59 PM
Joined: Feb 2006
Posts: 523
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 523
careful! you need a space in between '%c_' and '*' there


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Tomao #222772 02/07/10 05:09 PM
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
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
  }
}

Tomao #222774 02/07/10 05:27 PM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
@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.

Tomao #222777 02/07/10 07:38 PM
Joined: Feb 2006
Posts: 523
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 523
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


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Link Copied to Clipboard