mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
I'm quite new to mIRC scripting and have had some coding experience in other languages, but I'm having trouble with this.
To make the banall command I am using a hash table, and the code is as follows:

on *:JOIN:#raku:{
/hadd -s Users_on_channel $address }
}

on *:PART:#raku:{
/hdel -s Users_on_channel $address }

on *:TEXT:*:#raku: {
if ($nick isop $chan && $me isop $chan) {
if ($1 == .banall) { set %var $hget(Users_on_channel,0).item ;returns amount of values in the hash table
set %i 1
while (%i <= %var)
{
/ban $chan $hget(Users_on_channel, %i).data
inc %i
}
}
}

Is there a more efficeint way of doing this or fixing the code?
And yes, the table exists.


Last edited by Starasdsd; 17/01/12 11:22 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There really isn't much reason to use a hash table. You already know who is on the channel. Just ban them that way. You can loop through the nick list using $nick($chan,N) where N is the number of the nick. You can also use that to only ban regular users or regular and voiced users or whatever so you're not banning the ops. The only thing to keep in mind is that you need to check that $address() exists for each person because anyone in the channel when you join who doesn't type or do anything won't have an updated address. For anyone without the address, you'll need to check /userhost or /who or /whois to obtain the address of that nick before you can ban them. Of course, your script doesn't handle anyone who is already in the channel when you join anyhow. So if you want it to just work like yours, then skip anyone without an $address().

Notes on yours...
* Two many }'s on the on JOIN event.
* You are adding the ITEM $address to the table without and DATA and then you're banning using DATA. That won't work.
* Banning each person separately is a huge flood. You should check what the server allows for multiple bans and ban them in groups (e.g. +bbbb address1 address2 address3 address4).
* Use @ on your event to check if you are an op instead of using an IF ($me isop $chan) line.
* For while loops and anything else that is only used within the script and not needed once the script finishes, it's usually best to use local variables instead of global variables (/var instead of /set).
* You are missing a } in your on TEXT event.
* You aren't removing anyone who QUITS.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
Ok... so, now I have this:


if ($1 == .banall) { var %var $nick(#raku,0,a,o)
var %i 1
while (%i <= %var)
{
/ban $chan $nick(#raku,%i,a,o)
inc %i
}
}

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
That should work if it's in your on text event. Again, you might want to combine bans into a group to avoid really flooding the channel. I usually do that by using $addtok() to add all the addresses to a variable, then when $numtok() says that I have the right number of addresses, I do a ban on that variable and unset it and add more addresses to it. That would be done in your while loop. Then, after the while loop is finished, you would want to check if the variable has anything in it and ban those. That is because you might have been banning in groups of 4, but ended up with 2 in the variable when you finished going through the nicks. So they'd have to be banned separately once the loop finishes.

Also, remember that anyone who was in the channel when you joined and who hasn't said or done anything will not have an $address. You'd need to obtain that by checking one of the commands I listed above with your script whenever the $address() is $null. That or just ban the $nick if the $address is $null.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
Its not working for some reason, and I havent bothered adding $addtok etc because I am really not all that familiar with these identifiers smirk

I think the problem lies in the execution of the ban:

/ban $chan $nick(#raku,%i,a,o)
But i have no idea whats wrong.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
This should work to ban all the users in the channel except ops.
Code:
on $@*:text:/\.banall/iS:#raku:{
  if ($nick isop #) {
    var %i = 1, %n, %- = $nick(#,0,a,o)
    while ($nick(#,%i,a,o)) {
      %n = %n $v1
      if (%i = %-) || ($numtok(%n,32) == $modespl) {
        mode # $+(+,$str(b,$v1)) $address(%n,2)
        %n = ""
      }
      inc %i
    }
  }
}
I've taken the liberty of banning the type two address instead, which is the host.

Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
Not working, I am and op and so is the bot.
Also note I have this in an on text event.

this is what I have used:

Code:
if ($1 == .banall) { var %i = 1, %n, %- $nick(#raku,0,a,o)
      while ($nick(#raku,%i,a,o)) {
        %n = %n $v1
        if (%i = %-) || ($numtok(%n,32) == $modespl) {
          mode #raku $+(+,$str(b,$v1)) $address(%n,2)
          %n = ""
        }
        inc %i
      }
    }

EDIT: Shouldn't there be a space where the $+ and the start of the brackets are?

Last edited by Starasdsd; 18/01/12 04:26 AM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You don't need to specify the channel name throughout the code. You only need the channel name jotted down by the text event, as shown to you above. That will tell mIRC to listen to the certain channel.

It's optional if you want to leave a space. It works both ways.

Do you happen to use an outdated copy of mIRC?

Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
Ah I see.
I'm using version 7.22

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Try with correct syntax, your first if statement is missing an opening {, and the 2nd if should be:

Code:
 if ((%i == %-) || ($numtok(%n,32) == $modespl)) {


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
The first if statement is not missing a {..
Trying what you suggested.

EDIT: Doesn't work.

Ive tried other commands I have within the same event and they work fine, so it isn't a glitch.

Last edited by Starasdsd; 18/01/12 09:19 AM.
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Hit Ctrl+H in the script editor, it will pop up a messagebox if you are missing any braces anywhere. Make sure it doesn't pop up any messageboxes.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jan 2012
Posts: 7
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Jan 2012
Posts: 7
It isnt missing any.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Place the code in a new remote file. You can't have multiple text events in the same remote. Only the first one on top will trigger:

This is your original code:
on *:text:*:#:{
...
}

This is my suggestion to you:
on *:text:*:#:{
...
}

You need to either remove the first text event or combine them as one. This is the scenario I can think of that your mIRC won't respond to the code execution.

Another way is to have both text events listen to different triggers:

on *:text:.banall:#:{
on *:text:.banall2:#:{

Then you can have as many as you want in the same remote without any conflict.

Last edited by Tomao; 18/01/12 10:34 PM.

Link Copied to Clipboard