mIRC Homepage
Posted By: bodo0815 check user script - 09/09/05 07:55 PM
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
Posted By: RusselB Re: check user script - 10/09/05 02:14 AM
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  }
}
  
Posted By: Om3n Re: check user script - 10/09/05 03:01 AM
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).
Posted By: SladeKraven Re: check user script - 10/09/05 03:21 AM
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
Posted By: RusselB Re: check user script - 10/09/05 07:36 AM
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.
Posted By: bodo0815 Re: check user script - 10/09/05 02:40 PM
thx but the script do not work confused
there are nothing...

how is the script with hashtables?

thx bodo
Posted By: RusselB Re: check user script - 10/09/05 08:32 PM
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.
Posted By: Kelder Re: check user script - 10/09/05 09:59 PM
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...
Posted By: DaveC Re: check user script - 11/09/05 11:32 AM
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
Posted By: bodo0815 Re: check user script - 12/09/05 10:41 AM
thx DaveC

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

thx bodo
Posted By: DaveC Re: check user script - 12/09/05 10:48 AM
Well why did you use commas in the first place then?!?!?!?!?!

locate
$addtok(%cusers,$v1,44)
replace with
$addtok(%cusers,$v1,32)
© mIRC Discussion Forums