|
Joined: Jun 2004
Posts: 124
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 124 |
am hows is it to only work a "on *:nick" script in a specific channel? is this correct? on 1:NICK: {
if ($chan == #channel) {
if ($nick !isop $chan) {
something to be executed
}
} or anything wrong with that code?
|
|
|
|
Joined: Jan 2004
Posts: 509
Fjord artisan
|
Fjord artisan
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.
|
|
|
|
Joined: Jun 2004
Posts: 124
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 124 |
i dont know how to use the $newnick can you give me an example on that?
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Two (fictive) examples on ^*:nick: {
echo -ca info $nick changed nick to $newnick
haltdef
} on *:nick: {
if ($count($newnick,sex,fugg,whatever)) { echo -a offensive new nick of $nick : $newnick }
}
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
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
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2004
Posts: 124
Vogon poet
|
OP
Vogon poet
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... 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
}
}
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
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 Note : your method to check if the nick is "bad" or not is not the best...
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2004
Posts: 124
Vogon poet
|
OP
Vogon poet
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...
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
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.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jun 2004
Posts: 124
Vogon poet
|
OP
Vogon poet
Joined: Jun 2004
Posts: 124 |
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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. 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
}
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
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 (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.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
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: 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 ). 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
Last edited by Horstl; 16/08/07 06:12 AM.
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
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 :
//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
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
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: 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.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
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.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
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. 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.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|