mIRC Home    About    Download    Register    News    Help

Topic Options
#178330 - 08/06/07 10:37 PM $calc problem
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#178332 - 08/06/07 11:00 PM Re: $calc problem [Re: sparta]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
You need to evaluate the '$+(%, test., $nick)':

Code:
if ($calc($test - 3) > $($+(%, test., $nick), 2)) {

Top
#178333 - 08/06/07 11:06 PM Re: $calc problem [Re: Bekar]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
Still same result, it triggers 3 times up to 10..
Code:
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,.) }

Top
#178335 - 08/06/07 11:46 PM Re: $calc problem [Re: sparta]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
.. Well, duh.. Of course it does..

> = greater-than.


Use either ==, or >= and then reset %test.$nick afterwards.

Top
#178336 - 08/06/07 11:49 PM Re: $calc problem [Re: sparta]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
$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

Top
#178397 - 10/06/07 12:11 AM Re: $calc problem [Re: Riamus2]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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,.) }

Top
#178407 - 10/06/07 02:30 AM Re: $calc problem [Re: sparta]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Why not just do?:
Code:
if ($($+(%, test., $nick), 2) == 8) { }


Or:

Code:
if ($calc(%test - 3) == $($+(%, test., $nick), 2)) { }


Depending on what you're trying to do.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#178425 - 10/06/07 09:18 AM Re: $calc problem [Re: Riamus2]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
I trying to do this:
Code:
%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,.) }

Top
#178428 - 10/06/07 09:51 AM Re: $calc problem [Re: sparta]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
Wow.. Goto's.. Haven't seen them for a while..

Code:
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.. wink

[Typo's edited]


Edited by Bekar (10/06/07 10:05 AM)

Top
#178429 - 10/06/07 09:56 AM Re: $calc problem [Re: Bekar]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
thnx, i will try understand ur code, then i know how to NOT use goto's wink

Found a nice error in ur code m8 wink ON *:TEXT:*?: wouldent work, need to be ON *:TEXT:*:?: wink u forgot a : smile


Edited by sparta (10/06/07 10:01 AM)
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#178430 - 10/06/07 10:01 AM Re: $calc problem [Re: sparta]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
Code:
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.

Top
#178431 - 10/06/07 10:04 AM Re: $calc problem [Re: RusselB]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
Wow.. How'd I read 'grcho' as 'gecho'.. *sighs*

And yeah, sorry for the typo :P

RusselB, nice thought on the !$istok() smile Didn't think to use it that way.

Top
#178432 - 10/06/07 10:06 AM Re: $calc problem [Re: sparta]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
Originally Posted By: sparta
thnx, i will try understand ur code, then i know how to NOT use goto's wink

If you have any questions about it, ask! Happy to explain..

Top
#178433 - 10/06/07 10:31 AM Re: $calc problem [Re: Bekar]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#178435 - 10/06/07 11:18 AM Re: $calc problem [Re: RusselB]
Bekar Offline
Fjord artisan

Registered: 11/12/02
Posts: 503
Loc: Melbourne, Australia
.. I don't agree with them ..

But that's ok, every one is allowed to have an opinion wink

Top
#178436 - 10/06/07 11:20 AM Re: $calc problem [Re: RusselB]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
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


Edited by sparta (10/06/07 11:33 AM)
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top