|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I have a small problem with my code, i inc a %var. The %var is set to 10, how ever when it gets to 7 i want it to react 1 time, how ever if i use if ($calc(%test - 3) > $+(%, test., $nick))) , then it triggers all the way up to 10, it result in that it will be triggered 3 times, but i just want it to trigger 1 time, then no more, if i use == it wont react at all, any ideas?
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
You need to evaluate the '$+(%, test., $nick)':
if ($calc($test - 3) > $($+(%, test., $nick), 2)) {
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
Still same result, it triggers 3 times up to 10..
if ($calc($test - 3) > $($+(%, test., $nick), 2)) { }
the > result in that it triggers on everything abow 7 ..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
.. Well, duh.. Of course it does..
> = greater-than.
Use either ==, or >= and then reset %test.$nick afterwards.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
$test should be %test. I'm still not sure exactly what you're trying to accomplish from your description, so this may be all that's needed, or more may be necessary. If you need more, please try to explain some more of what's going on. You said that once it hits 7, you want it to react once, but I'm not sure what you mean.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I need to match a %var, if that %var is less then 10, to be exact 3 less then 10, then i want it to react and do one command one time, now it does a react 3 times due
if ($calc(%test - 3) > $($+(%, test., $nick), 2)) { }
the > tells if its more then 7, then it should react, and it reacts on 8 - 9 and 10 .. i only want it so send the command 1 time at 8.. like if i did set %test 8 if (%test == 8) { echo -a the test var is 1 more then 7, so it's 8 and i reacted on that }
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Why not just do?:
if ($($+(%, test., $nick), 2) == 8) { }
Or:
if ($calc(%test - 3) == $($+(%, test., $nick), 2)) { }
Depending on what you're trying to do.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I trying to do this:
%msgpro Normal
%msga 10
%msgu 60
on *:text:*:?:{
if (%msgpro != Disabled) {
if ($nick == Q) || ($nick == NickServ) || ($nick == X) || ($nick == W) { goto end }
if ($($+(%, msg., $nick), 2) > %msga) { goto flood }
if ($calc(%msga - 3) == $($+(%, msg., $nick), 2)) { .notice $nick Slow down a bit. }
inc -u $+ %msgu $+(%, msg., $nick)
goto end
}
:flood
.ignore -wnu120 $nick 3
grcho $nick is ignored for 2 minutes, possible notice flood.
.notice $nick You being ignored for 2 minutes, possible notice flood.
:end
}
and i want to warn people befor they are ignored. And maybe someone know a bether cleaner way to do what i want, and by the way, if i change "if" to "else if" the code wont be triggered at all, how come? the part if ($nick == Q) bla bla .. then the line below that one.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
Wow.. Goto's.. Haven't seen them for a while..
ON *:TEXT:*:?: {
if ((%msgpro != Disabled) && (%msga > 0)) {
if ($istok(Q NickServ X W, $nick, 32)) { return }
if ($($+(%, msg., $nick), 2) == %msga) {
.ignore -wnu120 $nick 3
grcho $nick is ignored for 2 minutes, possible msg flood.
.notice $nick You are being ignored for 2 minutes, possible msg flood.
}
elseif ((%msga > 5) && ($calc(%msga - 3) == $($+(%, msg., $nick), 2))) {
.notice $nick Slow down a bit.
}
inc -u $+ $iif(%msgu > 0, $v1, 60) $+(%, msg., $nick)
}
}
Ths should do what you're after, and also inhibit the code from multiple-flood-triggering. It also gets over the issue of someone setting '%msga' low, and thus sending 'Slow down a bit.' way too early. It also doesn't use ugly GOTO's..  [Typo's edited]
Last edited by Bekar; 10/06/07 09:05 AM.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
thnx, i will try understand ur code, then i know how to NOT use goto's  Found a nice error in ur code m8  ON *:TEXT:*?: wouldent work, need to be ON *:TEXT:*:?:  u forgot a : 
Last edited by sparta; 10/06/07 09:01 AM.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:text:*:?:{
if (%msgpro != Disabled) {
if !$istok(Q Nickserv X W,$nick,32) {
if ($($+(%,msg.,$nick), 2) > %msga) {
.ignore -wnu120 $nick 3
grcho $nick is ignored for 2 minutes, possible notice flood.
.notice $nick You're being ignored for 2 minutes, possible notice flood.
}
elseif ($calc(%msga - 3) == $($+(%,msg.,$nick), 2)) { .notice $nick Slow down a bit. }
inc -u $+ %msgu $+(%, msg., $nick)
}
}
}
Sometimes changing from multiple if's to if/elseif requires a re-write of the format of the code. I noticed that you have the command grcho in your code. I didn't know if that's a custom alias that you have, or a typo, so I left it alone. I also made the presumption that if %msgpro == Disabled, then the entire code would be ignored, rather than how you have it, where the :flood section would still be run irrelevant.
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
Wow.. How'd I read 'grcho' as 'gecho'.. *sighs* And yeah, sorry for the typo :P RusselB, nice thought on the !$istok()  Didn't think to use it that way.
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
thnx, i will try understand ur code, then i know how to NOT use goto's  If you have any questions about it, ask! Happy to explain..
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
While GOTO's are frowned upon, generally, there are times when they actually make for better code. There are a couple of Tutorial examples in this section of Hawkee which show fairly good examples as to when GOTO is actually a preferred method, as well as why.
|
|
|
|
Joined: Dec 2002
Posts: 503
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 503 |
.. I don't agree with them .. But that's ok, every one is allowed to have an opinion 
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
Why does this work:
inc %test
while this dosent?
inc -u $+ %ttime %test
%ttime is set to the 60 .. i get this error:
* /inc: insufficient parameters
how ever if i change the code to:
inc -u60 %test
then it working just fine.
but the only thing i added is a time when the %var should be removed as a %var. someone that can explain?
;------ edit
i solved it. inc $+(-u,%ttime) %test
Last edited by sparta; 10/06/07 10:33 AM.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
|