mIRC Home    About    Download    Register    News    Help

Print Thread
Problem with this code #177773 31/05/07 04:14 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I'm trying to write a code that will send a message to all of the channels that I & a named person share. I also want to be able to use multiple names, and send a different message based upon the name, with the previous message being used as a default.
Here's the code so far
Code:
alias cmsg {
  var %cmsg.nicks = $iif($gettok($1-,1,44),$v1,$$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks,$chr(44),$chr(32))
  var %a = 1, %b = $numtok(%cmsg.nicks,32)
  while %a <= %b {
    var %cmsg.msg = $iif($gettok($1-,2,44),$gettok($1-,2,44),$$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks,%a,32), %c = 1, %d = $comchan(%cmsg.nick,0)
    while %c <= %d {
      var %cmsg.chans = $addtok(%cmsg.chans,$comchan(%cmsg.nick,%c),44)
      inc %c
    }
    .msg %cmsg.chans %cmsg.msg
  }
  inc %a
}

It appears the problem is around line 6, as it keeps prompting me for a new message, no matter how many (or few) nicks were specified. At the moment, I'm testing the code without specifying the nicks or message in the /cmsg command line.

Re: Problem with this code [Re: RusselB] #177775 31/05/07 04:48 AM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
The 'inc %a' at the end is in the wrong place. It's not being incremented.

You're using '$1-' in multiple places, even though you've already put your '$1-' into '%cmsg.nicks'.

What are the intended arguments?
Code:
/cmsg <nick[,nick[...]]> <message>

If this is so, why are you using '$gettok($1-,1,44)' instead of simply '$1' ? Also, the message will be simply '$2-'.

So, something like this I guess:
Code:
alias cmsg {
  var %cmsg.nicks = $iif($1, $v1, $$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks($chr(44), $chr(32)
  var %a = 1, $b = numtok(%cmsg.nicks, 32)
  while (%a <= %b) {
    var %cmsg.msg = $iif($2, $2-, $$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks, $a, 32), %c = 1, %d = $comchan(%cmsg.nick, 0)
    while (%c <= %d) {
      var %cmsg.chans = %addtok(%cmsg.chans, $comchan(%cmsg.nick, %c), 44)
      inc %c
    }
    inc %a
  }
}




Re: Problem with this code [Re: Bekar] #177776 31/05/07 05:17 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>

Re: Problem with this code [Re: RusselB] #177783 31/05/07 09:04 AM
Joined: May 2007
Posts: 7
A
AciDcida Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
A
Joined: May 2007
Posts: 7
plzz help me thsi code wont work
Code:
on *@:text:*:#:{
  var %n = $nick,%c = #,%t = $strip($1-)
  if (*www.?.com iswm %t) || (*http://* iswm %t) || (*www.?.org* iswm %t) || (*www.?.net* iswm %t) || (www?.co.uk* iswm %t) || (www?.co.au* iswm %t) { 
    if (%n !isop %c) && (%n !isvoice %c) {
      .kill %n Auto-kill: dont post url 
      .kline $address(%n,2) Stop Spamming In Our Server
      echo $active $timestamp (4Warn) Punishing $9 with kline for advertise with $1-   
      onotice #wiredreality (#wiredreality/Ops) Kline triggered on $9 for Advertising $1- nickname : $nick in room $chan
      :end
    }
  }
}
 


Re: Problem with this code [Re: RusselB] #177784 31/05/07 09:05 AM
Joined: May 2007
Posts: 7
A
AciDcida Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
A
Joined: May 2007
Posts: 7
n this wont work ppl use away for badnick
Code:
}
on*.raw 301:#kampung:{
  if (sex iswm $2) {
    mode # +b $address($nick,3)
    kick # $nick You To smart But I'm more smart 
    .timer[kampung.javguest.ban] 1 60 mode # -b $address($nick,3) 
  }
}
 

Re: Problem with this code [Re: RusselB] #177795 31/05/07 01:02 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Originally Posted By: RusselB
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>

Ahh, so that rules out using:
Code:
/cmsg <nick1>,<nick2>,<nick3> <message>

Which means the logic I used above isn't right. Unfortunately, it's not easy to be able to use both methods from a /command perspective (only one or the other).

I'll look over the code when I'm awake, and make changes.

Re: Problem with this code [Re: AciDcida] #177796 31/05/07 01:05 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
AciDcida, there's no '#' or '#channel' associated with a RAW 301..

Also, the format of your event is wrong. It should be:
Code:
RAW 301:*:

A 301 (Away Reply) will never have a channel associated in it. It will only have the message the user set as their /away message.

Also, you should really start your own thread for a new issue.. wink

Re: Problem with this code [Re: RusselB] #177852 01/06/07 05:41 AM
Joined: May 2007
Posts: 7
A
AciDcida Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
A
Joined: May 2007
Posts: 7
how bout the kline code is't rite ?
if rite the code not working

Re: Problem with this code [Re: AciDcida] #177856 01/06/07 06:50 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Make your own topic, and stop posting on mine.

Re: Problem with this code [Re: RusselB] #177864 01/06/07 08:54 AM
Joined: Dec 2002
Posts: 580
N
NaquadaServ Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Originally Posted By: RusselB
I'm trying to write a code that will send a message to all of the channels that I & a named person share. I also want to be able to use multiple names, and send a different message based upon the name, with the previous message being used as a default.
Here's the code so far
Code:
alias cmsg {
  var %cmsg.nicks = $iif($gettok($1-,1,44),$v1,$$input(Space or Comma separated,e,Matching nicks))
  %cmsg.nicks = $replace(%cmsg.nicks,$chr(44),$chr(32))
  var %a = 1, %b = $numtok(%cmsg.nicks,32)
  while %a <= %b {
    var %cmsg.msg = $iif($gettok($1-,2,44),$gettok($1-,2,44),$$input(Common message,e,,$iif(%cmsg.msg,$v1)))
    var %cmsg.nick = $gettok(%cmsg.nicks,%a,32), %c = 1, %d = $comchan(%cmsg.nick,0)
    while %c <= %d {
      var %cmsg.chans = $addtok(%cmsg.chans,$comchan(%cmsg.nick,%c),44)
      inc %c
    }
    .msg %cmsg.chans %cmsg.msg
  }
  inc %a
}

It appears the problem is around line 6, as it keeps prompting me for a new message, no matter how many (or few) nicks were specified. At the moment, I'm testing the code without specifying the nicks or message in the /cmsg command line.

Originally Posted By: RusselB
Thanks for the information.

The reason I'm using $gettok($1-,1,44) is so that a person can use the alias in the format of
/cmsg <nick1> <nick2> <nick3> <nick4>,<message>


$replace(%cmsg.nicks,$chr(44),$chr(32)) is saying that you can use either a comma or space... The problem is with how you are parsing the command line parameters. Where do the nicks end and the message begin?

If you just allowed comma's you could simply use $gettok on $1 (instead of $1-) for the nicks


Originally Posted By: RusselB
Make your own topic, and stop posting on mine.


I was thinking the same thing reading this thread...


NaquadaBomb
www.mirc-dll.com
Re: Problem with this code [Re: NaquadaServ] #177871 01/06/07 03:25 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
If a person uses /cmsg <nick1> <nick2> <nick3>, <message>
then the code uses the 3 nicks that are specified before the ,
Therefore, the only time the $replace line would actually be used, is when the user issued the command /cmsg (no parameters)
in which case they would be prompted for the nicks, and at that time, they can space or comma separate the nicks, as the message will be prompted for separately.