mIRC Home    About    Download    Register    News    Help

Print Thread
replacing letters #14889 11/03/03 03:33 AM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
what wrog with this?
it suppose to replace every o with a 0..
i always get
O Unknown command
------------------------------------------------------------------------
on *:INPUT:*:{
if ( o isin $1- ) {
$replace(o,$1-,msg $chan u)
halt
}

Re: replacing letters #14890 11/03/03 03:40 AM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
It would be easier to help if you said what you were trying to do...(you said you wanted to replace o with 0, but what do you want to do with the text you get?)

$replace is used like this:
I want to replace the e in the word hello with the letter b, so I use this:
//echo -a $replace(hello,e,b)


Code:
on *:INPUT:*: {
  if ( o isin $1- ) {
    msg $active $replace($1-,o,0)
    halt
  } 
}
^I think that will do what you are trying to.

Re: replacing letters #14891 11/03/03 06:10 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
Yeah, but the way i see it, you will have a problem, unless you are already aware of it....but:

on *:input:*:{
if (o isin $1-) {
msg $chan $replace($1-,o,0)
halt
}
}

will only send the message IF there is an o within the text, otherwize, the message will never get sent...... you dont need an if condition at all in that:

on *:input:*:{
msg $chan $replace($1-,o,0)
}

$replace will be called, and replace only the o's with a 0 , and return everthing else the way it was, and if there are no o's in the text, it will return text exactly, the other way only preformed the /msg IF there was an o in text, dunno if you were 100% aware of this or not, but thought i'd let you know anyway

Re: replacing letters #14892 11/03/03 06:28 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
You are right that the if statement is not needed, but you are wrong that messages not containing a o will not be sent - the /halt is done only is there is a o in the text, and it is to stop 2 messages being sent (1 message with the replaced text, 1 without) - the /halt will not be done for messages without a so those messages will be sent as normal.

In your script there are 2 problems:
1. All of your messages will be sent twice - once with the "o"s replaced, once without.
2. This code:
on *:input:*:{ msg $chan
Will not work in a query, because $chan will be $null - that is why I used $active.

Both of our scripts have 1 flaw though - /commands are filtered too - they shouldn't be.

Code:
on *:input:*:{
  if ( $left($1,1) != / ) {
    msg $active $replace($1-,o,0)
    halt
  }
}

Re: replacing letters #14893 11/03/03 06:36 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
lol, yeah ur right, wasn't thinkin of /commands at the time, details :P

Re: replacing letters #14894 11/03/03 09:16 PM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
on *:input:*:{ if ( $left($1,1) != / ) { msg $active $replace($1-,o,0) halt } }
--------------------------------------------------------------------------

k it replace the leter but it says halt after it and it repeats the text in unreplaced form too


<q[o_O]p> 00 halt
<q[o_O]p> oo
<q[o_O]p> 00 halt
<q[o_O]p> oo
<q[o_O]p> s0 halt
<q[o_O]p> so
<q[o_O]p> Oh
<q[o_O]p> 0 halt
<q[o_O]p> s0s halt
<q[o_O]p> sos
<q[o_O]p> 0s halt
<q[o_O]p> os
<q[o_O]p> asasa halt
<q[o_O]p> asasa
<q[o_O]p> sad halt
<q[o_O]p> sad

Re: replacing letters #14895 11/03/03 09:42 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
You have to put in the new lines like it shows it on the forums. I.e
Code:
on *:input:*:{
  if ( $left($1,1) != / ) {
    msg $active $replace($1-,o,0)
    halt
  }
}

not
Code:
on *:input:*:{ if ( $left($1,1) != / ) { msg $active $replace($1-,o,0) halt } }

Re: replacing letters #14896 13/03/03 12:02 AM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
k it works but now how to i make it so it can can more then one letter?
cause this won't work
--------------------------------------------------------------------------

on *:input:*:{
if ( $left($1,1) != / ) {
msg $active $replace($1-,o,0)
halt
}
if ( $left($1,1) != / ) {
msg $active $replace($1-,w,\/\/)
halt
}
}
-------------------------------------------------------------------------

Re: replacing letters #14897 13/03/03 12:15 AM
Joined: Dec 2002
Posts: 395
M
MonoSex Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Dec 2002
Posts: 395
Code:
on *:input:*:{
  if ($left($1,1) != /) {
  msg $active $replace($1-,o,0,[color:green]w,\/\/[/color],[color:blue]e,3[/color],[color:purple]s,5[/color])
  halt
}

Re: replacing letters #14898 13/03/03 03:13 AM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
ok thnx now one more thing how do i how can i replace words just words and not letters?

ex: "i am in pian" should come out "ich bin in pain"(w/e the german word is)

and not "ich bin ichn pichan"

the ich replaces evey "i"


Re: replacing letters #14899 13/03/03 05:03 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
$replace($1-,i am a pain,ich bin in pain)

Re: replacing letters #14900 15/03/03 01:25 AM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
$replace($1-,i am a pain,ich bin in pain)
_________________________________________________

i know that i can do that but what i want to know was how i can do an identifer to see if the the word being replace by itself and reither or not to do the replace..

ex: if i type "i am in" it would replace the "i" because its by itself and not the i in "in"

Re: replacing letters #14901 15/03/03 01:34 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
on *:input:*:{
  if (/* iswm $1) || !$ctrlenter { return }
  var %a = $1-
  while $istok(%a,i,32) { %a = $reptok(%a,i,ich,1,32) }
  while $istok(%a,am,32) { %a = $reptok(%a,am,bin,1,32) }
  
  ;and so on ...

  msg $active %a
  halt
}

Re: replacing letters #14902 16/03/03 06:39 PM
Joined: Feb 2003
Posts: 20
D
dragonslayere Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Feb 2003
Posts: 20
doesn't work .....

Re: replacing letters #14903 19/03/03 12:52 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Yep, sorry, replace this line
if (/* iswm $1) || $ctrlenter { return }