mIRC Home    About    Download    Register    News    Help

Print Thread
#179074 17/06/07 08:41 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Code:
on *:input:#: {
  if ($ctrlenter) || ($left($1,1) === $readini(mirc.ini,text,commandchar)) { return }
  set %tline $1-
  set %tchn $chan
  unset %idle
  inc %_ilines
  iback
  if (%ncc = 2) {
    .msg $target $1-
    echo -a $inpline
    halt
  }
  set %tline $2-
  set %nick $nick(#,$fline(#,$replace($1,%nctr,*),1,1))
  if (%nick !ison $active) { set %tline $1- | echo -a $inpline | .msg $target $1- | halt }
  set %tline %nick $+ %owcr $2-
  .msg $target %nick $+ %ncchr $2-
  echo -a $inpline
  halt
}

$inpline return the text that was inserted, how ever i have a small problem, when i type just a :, then it pic the first nick in the nick list, and then complete it, how would i make it send the text if it's nothing entered behind the :, like te: will complete test: , but : would just return : ...


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Change:
Code:
  if ($ctrlenter) || ($left($1,1) === $readini(mirc.ini,text,commandchar)) { return }



To:
Code:
if ($ctrlenter) || ($left($1,1) === $readini(mirc.ini,text,commandchar) || ($1 == :)) { return }



Of course, if you want to send something like :test and don't want this to work then, either, you could use this instead:

Code:
if ($ctrlenter) || ($left($1,1) === $readini(mirc.ini,text,commandchar) || ($left($1,1) == :)) { return }



Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
/ is always a command prefix even if it's changed in the options dialog.

if ($left($1,1) === $readini(mirc.ini,text,commandchar) || ($left($1,1) == /))

or

if ($istok($readini(mirc.ini,text,commandchar) /,$left($1,1),32))

Just in case it is changed.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, add in the extra check into what I put so that you don't have issues with /.


Invision Support
#Invision on irc.irchighway.net
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The mirc.ini file might not be in the mIRC directory all of the time (when the -i command line parameter is used), so it would be better to use $mircini instead.

Might also be worth checking $inpaste and /returning if it's $true.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, updated:
Code:
if ($ctrlenter) || ($left($1,1) === $readini($mircini,text,commandchar) || ($left($1,1) == /) || ($left($1,1) == :)) { return }



That is what I get for leaving original code and just inserting the requested answer. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Thnx for the help smile i have a question tho, i was told befor to not use $left($1,1) , and i dont know why thats not so good, i was told
(/* iswm $1) was bether to use? smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The iswm method is faster.

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Originally Posted By: hixxy
The iswm method is faster.

This is a joke right?

Use $left($1,1) cuz this makes it pretty obvious your specifying the first character. Or the left most one. It's easier to understand by looking at it.

Beware of reading the mIRC INI (config) file. The configuration is actually kept in memory, and it's possible the INI file may not match the actual settings.


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias bench1 { 
  var %i = 10000, %ticks = $ticks
  while (%i) {
    if ($left(/hello,1) == /) { noop }
    dec %i
  }
  return $calc($ticks - %ticks)
}
alias bench2 { 
  var %i = 10000, %ticks = $ticks
  while (%i) {
    if (/* iswm /hello) { noop }
    dec %i
  }
  return $calc($ticks - %ticks)
}
alias bench { 
  var %i = 10
  while (%i) {
    echo -a $!left: $bench1 ~ iswm: $bench2 
    dec %i
  }
}


Type /bench

My results:

Quote:
$left: 422 ~ iswm: 391
$left: 422 ~ iswm: 375
$left: 437 ~ iswm: 360
$left: 422 ~ iswm: 375
$left: 422 ~ iswm: 375
$left: 422 ~ iswm: 375
$left: 421 ~ iswm: 375
$left: 438 ~ iswm: 359
$left: 438 ~ iswm: 359
$left: 422 ~ iswm: 359


It seems that parsing identifiers is a slow process.

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
$left: 391 ~ iswm: 359
$left: 391 ~ iswm: 359
$left: 407 ~ iswm: 343
$left: 407 ~ iswm: 343
$left: 407 ~ iswm: 343
$left: 407 ~ iswm: 343
$left: 407 ~ iswm: 343
$left: 407 ~ iswm: 359
$left: 391 ~ iswm: 359
$left: 391 ~ iswm: 359


Link Copied to Clipboard