mIRC Home    About    Download    Register    News    Help

Print Thread
how can i? little help plz #182840 15/08/07 04:15 PM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
am hows is it to only work a "on *:nick" script in a specific channel?

is this correct?
Code:
on 1:NICK: {
  if ($chan == #channel) {
      if ($nick !isop $chan) {
        something to be executed
  }
}

or anything wrong with that code?

Re: how can i? little help plz [Re: sigbin] #182841 15/08/07 04:19 PM
Joined: Jan 2004
Posts: 509
L
LostShadow Offline
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Should work fine. Make sure you have 1 on nick event in the remote page. You might also be looking at $newnick.

Re: how can i? little help plz [Re: LostShadow] #182842 15/08/07 04:27 PM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
i dont know how to use the $newnick can you give me an example on that?

Re: how can i? little help plz [Re: sigbin] #182844 15/08/07 05:00 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Two (fictive) examples smile
Code:
on ^*:nick: {
  echo -ca info $nick changed nick to $newnick
  haltdef
}

Code:
on *:nick: {
  if ($count($newnick,sex,fugg,whatever)) { echo -a offensive new nick of $nick : $newnick }
}

Re: how can i? little help plz [Re: sigbin] #182853 15/08/07 06:16 PM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
In a on nick event, $chan return $null (you don't change your nick in a specific channel).
Generaly you have to use $comchan($nick\$newnick,0) in a while smile


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Wims] #182884 16/08/07 01:08 AM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
thankz the both of you but i cant make it work or rather i dont know how to use that... can you help me integrate that to this code? some how make it work in a "on *:nick" script...
Code:
  if (!$hget(badnick)) hmake badnick 10
  var %i = 1
  while ($gettok($badnick,%i,32)) {
    if ($+(*,$gettok($badnick,%i,32),*) iswm $nick) {
      if ($nick !isop $chan) {
        hinc badnick $nick
        var %badnick = $gettok($badnick,%i,32)
        if ($hget(badnick,$nick) == 1) some kick nick command
        if ($hget(badnick,$nick) == 2) some ban nick command
      }
    }
    inc %i
  }
}

Re: how can i? little help plz [Re: sigbin] #182890 16/08/07 02:07 AM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
on *:nick:{
var %i = $numtok($badnick,32) ,%n $newnick ,%c $comchan(%n,0)
while (%i) {
if ($+(*,$gettok($badnick,%i,32),*) iswm %n) { hinc -m badnick %n $calc($hget(badnick,$nick) +1) | break }
dec %i
}
var %h = $hget(badnick,%n) ,%cmd $iif(%h == 1,kick,ban -k)
while (%c && %h) {
if ($me isop $comchan($newnick,%c)) && ($newnick !isop $v2) %cmd $v2 %n $iif(%h == 2,2) Badnick !
dec %c
}
}

i made some change, hope it's works smile

Note : your method to check if the nick is "bad" or not is not the best...


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Wims] #182900 16/08/07 03:07 AM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
thankz wims for the reply nd code... but this script i would lick to work that script in just a specific channel like channel #sigbin... that script will only work in that channel... am wim im in undernet network im using this command to kick or ban "/msg x kick #channel nick reason" i cant edit your code i dont know how...

Re: how can i? little help plz [Re: sigbin] #182901 16/08/07 03:16 AM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
Ok so use this :

on *:nick:{
var %i = $numtok($badnick,32) ,%n $newnick
while (%i) {
if ($+(*,$gettok($badnick,%i,32),*) iswm %n) { hinc -m badnick %n $calc($hget(badnick,$nick) +1) | break }
dec %i
}
if ($hget(badnick,$nick)) hdel badnick $nick
var %h = $hget(badnick,%n) ,%cmd $iif(%h == 1,msg x kick,$iif(%h == 2,ban -k))
if (%cmd) && ($me isop #sigbin) && (%n !isop $v2) %cmd $v2 %n $iif(%h == 2,2) Badnick !
if (%h == 2) hdel badnick %n
}

i add some "if" to delete the table for the old $nick, and another to delete the table of the $newnick if it's the second time that you "do something" for this nick..

Edit : change the $iif and if part, user that don't match your list were always ban

Last edited by Wims; 16/08/07 03:36 AM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Wims] #182902 16/08/07 04:10 AM
Joined: Jun 2004
Posts: 124
S
sigbin Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Jun 2004
Posts: 124
thankz man... great help

Re: how can i? little help plz [Re: Wims] #182904 16/08/07 04:49 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Wims: If you're going to post code, please use the Code Tags button. It looks like the # character, and is located in the bar at the top of these message areas.

Also please watch your formats, as you are using incorrect format for setting some of the variables, as well as setting variables when not required.

Here's a re-write of the code you posted.
Code:
on *:nick:{
  var %i = $numtok($badnick,32)
  while (%i) {
    if $+(*,$gettok($badnick,%i,32),*) iswm $newnick) { hinc -m badnick $newnick }
    dec %i
  }
  if ($hget(badnick,$nick)) hdel badnick $nick
  var %h = $hget(badnick,%n) ,%cmd = $iif(%h == 1,msg x kick,$iif(%h == 2,ban -k))
  if (%cmd) && ($me isop #sigbin) && ($newnick !isop $v2) %cmd $v2 $newnick $iif(%h == 2,2) Badnick !
  if (%h == 2) hdel badnick $newnick
}

Re: how can i? little help plz [Re: RusselB] #182906 16/08/07 05:40 AM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
Sorry about the code tags button, i'm not familiar with tags button, i'll try to use it now but is this is really annoying for you, or for other ?

And about the format, i don't call that "incorrect" because mirc allow us to script like that (i mean not put the egal sign in some case and the { }) i agree to say that i should not use this syntax but it's just a practice smile (and that take less place).
I'm one of those would want to see a single syntax for mirc in general because imo, if you have only one way to do something, so there can't be confusion for other.
You said that i use incorrect format, but compared to what are you saying this ? mIRC help not said it's incorrect (not said it's correct, but so, why allow it ?)

As $newnick is repeated several times, i think it's better to store it.

Last edited by Wims; 16/08/07 05:44 AM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Wims] #182908 16/08/07 06:04 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Please use that code tags! This makes it much easier to comprehend...
Concerning syntax and brackets, every now and then there is a discussion about bracket use and misuse (most recent example) - there's much room for "personal taste of style".
For example, I'm prefering the most univocal bracket style:
Code:
on *:nick:{
  var %i = $numtok($badnick,32)
  while (%i) {
    if ($+(*,$gettok($badnick,%i,32),*) iswm $newnick) { hinc -m badnick $newnick }
    dec %i
  }
  if ($hget(badnick,$nick)) { hdel badnick $nick }
  var %h = $hget(badnick,%n) ,%cmd = $iif((%h == 1),msg x kick,$iif((%h == 2),ban -k))
  if ((%cmd) && ($me isop #sigbin) && ($newnick !isop $v2)) { %cmd $v2 $newnick $iif((%h == 2),2) Badnick ! }
  if (%h == 2) { hdel badnick $newnick }
}

On the other hand side, people will take snippets etc they see here as an example for their own scripts, thus the syntax should be as exemplary as possible (we all will slip up every once a while whistle ).

For example:
"var %varname plaintext-data" ...will work.
"var %varname $identifier" ...will not work in all circumstances.
"var %varname = plaintextdata or $identifier" ...will work. Therefore it is a good idea - from my point of view - to use always that syntax smile


Last edited by Horstl; 16/08/07 06:12 AM.
Re: how can i? little help plz [Re: Horstl] #182909 16/08/07 06:48 AM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
My preference is to not use { } when it's not necessary and like Riamus2 said in the recent, thread don't put { } is more faster than put it (ok, not really..)

About the = sign, before, i used it in anytime because i did not know really what he mean, but today, i think it's necessary to use it only when value contain data that SHOULD be parsed as a variable setting like :

Code:
//var -s %a 1 ,%b 2 ,%c $mid(sometexthere,%a,%b)


If we just look at the $mid itself, he is right, but this command create an error :
* Invalid format: $mid
put the = sign solve the problem of course.
i don't know other case that = is required and i'll be happy to know, just for my knowledge smile


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Wims] #182912 16/08/07 11:24 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I said it was faster, but I also said that it would not be noticeably faster. Unless you're testing speed by checking miliseconds, you won't even notice.

The biggest problem with not using them in this forum is that this forum is a help forum. People learn scripting from here. Even knowing how to script, this line is hard to understand without looking closely to see exactly what is going on in it:

Code:
if (%cmd) && ($me isop #sigbin) && (%n !isop $v2) %cmd $v2 %n $iif(%h == 2,2) Badnick !


If for no other reason, you should consider using {}'s in here just so that people learning scripting can easily understand what is going on and learn from it. It's also best to have people learn good scripting practices before learning shortcuts... especially shortcuts that may not always work. There are cases where leaving {}'s off will cause the script to fail even with only one command after an IF.

As for using the equal sign with /var, it is always best to use it simply because it also can fail if you do not. Yes, it will only fail with items that need to be parsed, but again, this is a help forum and people learning scripting will probably not see the relatively few times that we say when the equal sign is needed and when it isn't. That means that they may try without and then get an error and have no idea why they have an error.

Personally, I don't think it matters how people script on their own. If someone wants to make it 10ms faster by dropping a lot of {}'s, that's up to them. If he or she wants to make the code hard to understand so people are less likely to mess with it, that's also up to them. However, in a help forum or channel, it's better to follow proper syntax at all times. It reduces the number of problems people have when learning to script. smile


Invision Support
#Invision on irc.irchighway.net
Re: how can i? little help plz [Re: Riamus2] #182914 16/08/07 12:08 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Here Here!

Re: how can i? little help plz [Re: Riamus2] #182921 16/08/07 03:01 PM
Joined: Jul 2006
Posts: 3,586
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,586
Lol, ok.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: how can i? little help plz [Re: Riamus2] #182928 16/08/07 03:46 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Using only one ( and ), or surrounding the entire if statement in an extra set of () would make it just as easy to read imo.

if (x && y && z) do this
if ((x) && (y) && (z)) do this
if (x) && (y) && (z) { do this }

The first two are just as good.

Re: how can i? little help plz [Re: hixxy] #182942 17/08/07 12:14 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Personally, I use:

if (x && y && z) { do this }

In any case, as I said, it's just my personal opinion. I think that the entire IF section should always have ()'s around it and commands should have {}'s around it except in certain situations when you may not want to. And unless there are order of operations issues, I don't bother with having a bunch of extra ()'s inside of the IF because too many also can make it harder to read. Again, it's just my personal opinion and I was just explaining my reasoning. smile

Note that I also don't put multiple commands on a single line using pipes except in the case of using RETURN after a command and I never put anything on the event line. Again, just personal preference. And for anyone who wants to mention speed... I don't accept that a few miliseconds are noticeable enough to make it worth doing it differently. smile


Invision Support
#Invision on irc.irchighway.net