mIRC Home    About    Download    Register    News    Help

Topic Options
#129836 - 09/09/05 08:55 PM check user script
bodo0815 Offline
Babel fish

Registered: 10/04/05
Posts: 72
hello
i will check if users on channel1 and channel2
is user in channel1 but not in channel2 then kick+ban
i have this code:
Code:
 alias checkusers { 
  if ( $1 ischan ) && ( $2 ischan ) {  
    var %c = 1, %cusers 
    while $nick($1,%c) { 
      if ( $v1 !ison $2 ) && ( $v1 !isvoice $1 ) %cusers = $addtok(%cusers,$v1,44) 
      inc %c 
    } 
    msg # $iif( %cusers, **Not in $2 $+ : $v1, None) 
  } 
  else echo $colour(info) -a ** Syntax: /checkusers <#Channel1> <#Channel2> 
} 

...but too many users = * /set: line too long (line 5, check.mrc)

plz help me & thx bodo

Top
#129837 - 10/09/05 03:14 AM Re: check user script
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Going from your description in the post, rather than the code that you posted, this should work. Unfortunately I'm unable to test it at present
Code:
alias checkusers {
  if ($$1 ischan) && ($$2 ischan) {
    set %chan $iif($nick($$1,0) < $nick($$2,0),$$1,$$2)
    set %chan2 $iif(%chan == $$1,$$2,$$1)
    var %c = 1
    while %c <= $nick(%chan,0) {
      if ($nick(%chan,%c) !ison %chan2) && ($me isop %chan) {        .ban -k %chan $nick(%chan,%c) 3      }
      inc %c
    }
  }
  elseif ($$1 ischan) {    .msg $nick Sorry, you also need to be on $$2  }
  elseif ($$2 ischan) {    .msg $nick Sorry, you also need to be on $$1  }
  else {    .msg $nick Sorry, but you need to be on both $$1 & $$2  }
}
  

Top
#129838 - 10/09/05 04:01 AM Re: check user script
Om3n Offline
Fjord artisan

Registered: 06/07/03
Posts: 655
The reason for the error is because '$addtok(%cusers,$v1,44)' is first evaluating %cusers, when there are too many users the line of code and %cusers variable become very long, to the point where mirc is unable to process it efficiently (hence the undocumented limit).
_________________________
"Allen is having a small problem and needs help adjusting his attitude" - Flutterby

Top
#129839 - 10/09/05 04:21 AM Re: check user script
SladeKraven Offline
Planetary brain

Registered: 19/12/02
Posts: 3547
Loc: Kent, England
I'm not too long a hash item/data can be but maybe that would help, or even an INI, I really think there's no need in creating a hash table with only one item but... *shrugs*

-Andy

Top
#129840 - 10/09/05 08:36 AM Re: check user script
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Creating a hash table for a single item would be a waste. If he needs to work with the information in a variable, one way to get around the length limitation is to use binary variables.

Unlike local & global variables, binary variables don't have a maximum length...or at least not one that I've been able to discover, and I've tested up to 100,000 characters in length.

However, I'm unsure as to why he's even working with a variable containing all of the names, as that is slightly counter to his original request, which I responded to earlier.

Top
#129841 - 10/09/05 03:40 PM Re: check user script
bodo0815 Offline
Babel fish

Registered: 10/04/05
Posts: 72
thx but the script do not work confused
there are nothing...

how is the script with hashtables?

thx bodo

Top
#129842 - 10/09/05 09:32 PM Re: check user script
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Why are you wanting to store the nicks? Is it a list of the nicks that were kick/banned from one channel because they weren't in the other? A list of all the nicks that were in both, and therefor didn't need to be kicked/banned? or something else altogether?

I need to know why you're keeping a list of the nicks and what you intend to do with that list before I can go any further.

Top
#129843 - 10/09/05 10:59 PM Re: check user script
Kelder Offline
Hoopy frood

Registered: 12/04/03
Posts: 701
Loc: Leuven, Belgium
Why do this only when you run a command? mIRC has events like on JOIN, on PART, on NICK and timers. Just have a script check if someone is in the correct channel when he enters the other channel. If you want a short time to comply, put the test in a 30 second timer or something before checking. Also check on part so that so one just parts the required channel after a few minutes. Probably best to give the timers a name that is related to the nickname, so you can disable the timer when nick joins channel2 and can change the timer when he changes his nick during those 30 seconds...

No need to remember to run the alias every few hours or so, just have it done automatically. This also prevents having to kick 20 people at once (flood) if it's a big channel...

Top
#129844 - 11/09/05 12:32 PM Re: check user script
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Code:
alias checkusers { 
  if ( $1 ischan ) && ( $2 ischan ) {  
    var %c = 1, %cusers 
    while $nick($1,%c) { 
      if ( $v1 !ison $2 ) && ( $v1 !isvoice $1 ) %cusers = $addtok(%cusers,$v1,44) 
      inc %c
      if ($len(%cusers) > 400)  { msg # **Not in $2 $+ : %cusers | %cusers =  }
    } 
    if (%cusers != ) { msg # $iif( %cusers, **Not in $2 $+ : $v1, None) }
  } 
  else echo $colour(info) -a ** Syntax: /checkusers <#Channel1> <#Channel2> 
}


Try that , each time the %cusers gets over 400 characters it spools it out to the channel, i think 400 or 500 is max to channel line length

Top
#129845 - 12/09/05 11:41 AM Re: check user script
bodo0815 Offline
Babel fish

Registered: 10/04/05
Posts: 72
thx DaveC

i need a space between the nicks (without commas
now: nick,nick,nick,nick...
i need: nick nick nick nick...??

thx bodo

Top
#129846 - 12/09/05 11:48 AM Re: check user script
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
Well why did you use commas in the first place then?!?!?!?!?!

locate
$addtok(%cusers,$v1,44)
replace with
$addtok(%cusers,$v1,32)

Top