mIRC Home    About    Download    Register    News    Help

Print Thread
#231381 16/04/11 12:11 AM
Joined: Apr 2011
Posts: 2
D
Bowl of petunias
OP Offline
Bowl of petunias
D
Joined: Apr 2011
Posts: 2
mmkay, so I have said script;
Code:
ON !1:TEXT:*word*:#mychan:{
inc %derek

  if(%derek == 0)
  {
    /msg $chan <color>4Please $nick , Do not use such language in here.
    
  }
  elseif(%derek == 1)
  {
    /msg $chan <color>4Pplease $nick , Do not use such language. This is the channel's final warning before someone gets kicked.
    
  }
  else
  {
    /msg $chan <color>4Goodbye $nick . You have been warned. Your ban will lift in approximately 5 minutes.
    /ban $chan $nick
    /kick $chan $nick
    /notice $me set $bnick 's unban time to 5 minutes.
  }

}


When someone types 'word' it goes thru all 3 options without stopping... how can this be solved?

Joined: Jul 2006
Posts: 4,163
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,163
If statement need spaces between the keyword and the condition, the opening bracket also need to be on the same line if used, you don't need them in that specific case though since you only have one command for each if.
Also, you can use ban -ku300 to kickban and auto-unban after 5 minutes, avoiding the notice to yourself :

Code:
on !1:text:*word*:#mychan:{
  inc %derek
  if (%derek == 0) {
    msg $chan 4Please $nick $+ , do not use such language in here.
  }
  elseif (%derek == 1) {
    msg $chan 4Please $nick $+ , do not use such language. This is the channel's final warning before someone gets kicked.
  }
  else {
    msg $chan 4Goodbye $nick $+ . You have been warned. Your ban will lift in approximately 5 minutes.
    ban -ku300 $chan $nick 2
  }
}
Fixed some minor things too.

Last edited by Wims; 16/04/11 12:39 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2011
Posts: 2
D
Bowl of petunias
OP Offline
Bowl of petunias
D
Joined: Apr 2011
Posts: 2
Thanks, that works great! I'll make sure to keep those things in mind. smile

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Derek_Elensar, how can the increment of %derek be 0? It will be 1 upon setting it. This just looks rather "unusual" to me when you put it as
Quote:
inc %derek
if (%derek == 0) {
Unless, of course, you do it as
Code:
set %derek 0
And your script will fail to warn and kick once the count keeps being incremented more than one time without getting unset and starting afresh.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I'm surprised Wims didn't look at the fact that the variable is not dynamic, meaning if person A triggers the script, his or her offense will be counted as one warning. There comes the person B masking the forbidden word, it'll cause the script to increase the count as another warning. That just doesn't add up, does it? This script should have been perfected as such:
Code:
on @*:text:*word*:#mychan:{
  inc $+(%,derek,$network,$chan,$wildsite)
  if ($(,$+(%,derek,$network,$chan,$wildsite)) > 2) {
    msg $chan 4Goodbye $nick $+ . You have been warned. Your ban will lift in approximately 5 minutes.
    ban -ku300 $chan $nick 2
    unset $+(%,derek,$network,$chan,$wildsite)
  }
  elseif ($(,$+(%,derek,$network,$chan,$wildsite)) == 2) {
    msg $chan 4Please $nick $+ , do not use such language. This is the channel's final warning before someone gets kicked.
  }
  else {
    msg $chan 4Please $nick $+ , do not use such language in here.
  }
}
Of course, last but not least, we need to unset the variable when the offender is kicked and banned.

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: "the script"

msg $chan 4Please $nick $+ , do not use such language. This is the channel's final warning before someone gets kicked.


still not completely fair, since it is not realistic to assume that everyone sees these 'warnings', but looks to be intentional. i'm sure the OP will soon learn what is and isn't appropriate for a channel operator.

also, do try to avoid using $(, stuff) when handing out example code as it is undocumented, counter-intuitive, and possibly uninentional behaviour that could easily become fixed / unsupported in future versions, just as $(,, stuff) becoming $null in the past did.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Jul 2006
Posts: 4,163
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,163
He asked how to fix the problem, I answered, and he was just happy with this.
As for the %derek var probably never being 0, you just don't know, no point trying to guess without further information.
If you re-read carefuly, you will see that he made that code "channel based" on purpose, again, he might be a good idea to do it "nick based" but there's no point doing so when the code clearly shows it's "channel based".


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Agreed. Recommending improvements is fine, but it's still valid to give out a working version of what was originally asked for first. Most likely, the variable will never be 0 and the OP didn't realize this, so it's a good thing to point that out. But it's possible that it could be 0 depending on the rest of the scripts that might be being used, so I'd point it out, but not change it.

As for channel versus nick based protections, the request was (possibly) for channel based by looking at the code. Giving a working version of that is fine. The reason I say possibly for that is that the ELSE says that they've been warned. They may not have been warned if it's channel based warnings. Again, this is probably just the OP not realizing what it was going to do. So it's also good to point out the problems with that kind of format and then leave it to the OP to choose how to handle it best.

I don't think it's necessary to add "everything" to the variable name. The only time you need $network if if you are on the same channel(s) on multiple networks, which is usually not the case. $chan is only needed if you want a separate counter for each channel. Considering the nick is probably the same person even if the channel is changed while on the same network, allowing more warning just because the person is in a different channel isn't really required. Add to that the fact that the script specifies a single channel, so it won't trigger for other channels anyhow. Just including $nick (or some form of address mask if there are a lot of people using the same nicks) is enough in most cases. The rest just adds more work to the script that isn't really necessary. The additional items can be suggested for times when they may be useful, but I wouldn't put them right in there from the start.

Last edited by Riamus2; 16/04/11 02:52 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks jaytea and Riamus2. I was trying to be helpful and anticipating to get some feedback along the way so I can learn more from the experienced to gain improvement and know-how. Wims, bursting your bubble was not what I intended. I was just a little surprised considering you always give out matter-of-fact edit and fix. Yes, perhaps I didn't know well enough why the increment would have been 0, but it struck me that it would...I'm still not too certain of that.

Lastly, I haven't a clue why Derek_Elensar would use a regular var, because it'll increase by 1 for everybody. And once it gets increased more than one time, the script may not trigger Again upon the word matched. I'm not sure, and again, it may have been intentional to be coded that way.

Please pardon the pun.

Joined: Jul 2006
Posts: 4,163
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,163
No problem here Tomao smile
I just decided not to add anything to the code except minor things because it seems he was just looking for a complete working code, without any willing to learn, and because the code is channel based with no logical error regarding that

Last edited by Wims; 16/04/11 05:29 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Tomao
And once it gets increased more than one time, the script may not trigger Again upon the word matched.


It will continue to trigger, but if it is never reset, then the ELSE will trigger every time. Chances are, that's not what is wanted, but there may be a reset somewhere else that handles that.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard