mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2004
Posts: 59
S
synth7 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Jul 2004
Posts: 59
Code:
on ^*:TEXT:*:#: {
  var %n = $nick, %t = $$1-
  echo # $timestamp $+(<,%n,>) %t
  haltdef
}

on *:INPUT:#: {
  haltdef
  .msg # %t
  var %n = $me, %t = $$1-
  if ($left(%t,1) == $chr(47)) {
    ???????
  }
  echo # $timestamp $+(<,,%n,,>) %t
}


This code bolds my name on my INPUT's, and leaves the other peoples' the same, but I can change it whenever I want. As you can see in this part of the code...

Code:
  if ($left(%t,1) == $chr(47)) {
    ???????
  }


I try to check the first character, and it it's a / that starts a command, it does the command like normal. However, I can't get it to do the command alone, and I don't know how. Also, anything else that could make my code better would be appreciated.

Any help?

Last edited by synth7; 24/11/05 03:51 PM.


Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Leaving the bulk of your code intacked ill offer this...

Code:
on ^*:TEXT:*:#: {
  haltdef
  var %n = $nick, %t = $1-
  echo # $timestamp $+(<,%n,>) %t
}

on *:INPUT:#: {
  if (!$istok(/ $readini($mircini, text, commandchar), $left($1, 1), 32)) && (!$ctrlenter) && (!$inpaste) {
    haltdef
    var %n = $me, %t = $1-
    .msg # %t
    echo # $timestamp $+(<,,%n,,>) %t
  }
}

* code untested

if (!$istok(/ $readini($mircini, text, commandchar), $left($1, 1), 32)) && (!$ctrlenter) && (!$inpaste) {
^ this line checks that the first character of the input ($left($1, 1)) is not either / or the userdefinable command char (/ $readini($mircini, text, commandchar), )
^ it then checks you dont have the ctrl key down, which is the mIRC defualt keydown to instruct you dont want to process this text in anyway (!$ctrlenter)
^ it then checks your not in a pasting operation, which you may or maynot want to add (!$inpaste)

A note on pasting, if you have pasted multiple lines using ctrl-v, then you are going to have triggered the $ctrlenter anyway so it wont process the lines, you can of course right click the mouse to paste or press shift-insert.



You might want to remove the && (!$inpaste) depending on your prefrence to seeing it as you want when pasting text.

Joined: Jul 2004
Posts: 59
S
synth7 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Jul 2004
Posts: 59
Ok, thanks! On to my next question...

With things like my system info script, it doesn't show my name in bold, probably because I don't have custom /msg alias. I tried writing one, and this should work right?

Code:
alias msg {
  .!msg # $$1-
  echo # $timestamp $+(<,,$me,,>) $$2-
}

Last edited by synth7; 24/11/05 08:03 PM.


Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
try

alias msg { .msg $1- | echo $iif($window($1),$1,-a) $timestamp $+(<,,$me,,>) $2- }

That might work in most occasions.

PS: NEVER put a $$ in a command replaced alias, it stops proccessing of the script the MSG was called from, this is not the same as the behavour of mirc if it was an internal command.

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Just a note, /echo has a lot of switches you could use, my favorite is echo -mbflrt $chan $+(<,$me,>) $1-

#136239 27/11/05 03:32 AM
Joined: Jul 2004
Posts: 59
S
synth7 Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Jul 2004
Posts: 59
One more question from me heh. I have this right now

Code:
on *:INPUT:#: {
  if (!$istok(/ $readini($mircini, text, commandchar), $left($1, 1), 32)) {
    haltdef
    var %n = $me, %t = $1-
    .!msg # %t
    echo -mft # $+(&lt;,,%n,,&gt;) %t
  }
}


However, when I paste in lines of code to a friend, it doesn't preserve the spacing of the code, so i see this...

Quote:

[Nov-26 22:27:27] <synth> on *:LOAD: {
[Nov-26 22:27:27] <synth> if ($version != 6.16) {
[Nov-26 22:27:27] <synth> dialog -m synstats synstats.wrongversion
...on and on


What magic bit of code will help me overcome this?



#136240 27/11/05 10:26 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Well, there's no easy way to do it, so basically just live with it and don't send those spaces. mIRC code will still work and those leading spaces will be added automatically again once you check the code (the {} button in the editor) and save it. It's a limitation in mIRC, one that probably won't ever be overcome since it requires developing a new scripting language...

Some people will advise you to replace spaces with another character, $chr(160), because some fonts have nothing in that position. Other fonts have strange characters there, like a capital with accents on it. And most importantly, it will break any code you send.
Another way is to include 2 ctrl-b characters (bold) between each pair of spaces, as this will show correctly on screen at a minor cost of extra message length and it not working on channels that don't allow color codes. Still, any code sent using such a script will be broken since ctrl-b ctrl-b is not a valid command.

#136241 27/11/05 04:13 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
the fact that you have an "on input" script affecting you text is the cause of the leading spaces being truncated.
Code:
if (($left($1,1) == $readini($mircini,text,commandchar)) || ($left($$1,1) == !) || ($left($$1,1) == @) || ($ctrlenter == $true)) { return }


using this in your string will allow you to paste plain text with spaces intact. There would not be any need for any $replace() for have mIRC treat plain text normally. Also having an "on/off" $group control would allow you to turn off the "on input" script and avoid the problem that way.


Link Copied to Clipboard