mIRC Homepage
Posted By: yamaz What's wrong with this little script? - 23/01/06 06:11 PM
Hi there, I have this alias (it resends the last file sent):

/resend {
if (%ultimofile == $null) { echo -a Non hai inviato nessun file. Idiota. | return }
if ($?!="Inviare %ultimofile a $active $+ ?" == $true) {
if ($left($active,1) == #) {
var %sendnick = $?="Invio a che nick?"
}
else var %sendnick = $active
if (%sendnick == $null) { echo -a Specifica un nick. | return }
dcc send %sendnick %ultimofile
}
}

it works almost perfectly, there's only a problem: if you type /resend in a channel window, it seems that the script can't detect that it's a channel ( if ($left($active,1) == #) )and does not ask for a nick to send. How can I fix it?

Thanks alot
Posted By: CoolWave Re: What's wrong with this little script? - 23/01/06 07:24 PM
Hello yamaz,

mIRC replaces each single # caracter (not affixed to a word, so) by the channel name associated to the event.

For example, in a ON *:TEXT:#:, # returns $chan, the channel where the event was triggered (e.g. #Scripts)

In an 'manual' alias on a channel, or an alias called via your popups menu, # returns the value of $active, the channel name so. For example, if you put an /echo > # in your alias, you will see the replacement.

So, with that, you understand that your comparaison looks like..
IF (a caracter == a channel name)
For example, if you are on #Scripts: $left($active,1) = # et # = #Scripts, which finally look like :
IF (# == #Scripts)
.. and that, that can not work !


Two solutions so:

* The better way, i think, is to use if ($active ischan), no problem here, or simply if ($chan), which check if we are on a channel.

* I you want to use # like a caracter, you can use $chr(35) ou $(#,0) so that mIRC does not replace it by a channel or no-value. Like that, mIRC does not evaluate this caracter.

I hope that will help you.
Posted By: yamaz Re: What's wrong with this little script? - 24/01/06 07:59 PM
Quote:
Hello yamaz,

Two solutions so:

* The better way, i think, is to use if ($active ischan), no problem here, or simply if ($chan), which check if we are on a channel.

* I you want to use # like a caracter, you can use $chr(35) ou $(#,0) so that mIRC does not replace it by a channel or no-value. Like that, mIRC does not evaluate this caracter.

I hope that will help you.


The second solution is the quickest and the less painful smile I used it and it worked smile Merci beaucoup
© mIRC Discussion Forums