mIRC Homepage

[help] alias msg

Posted By: Greeple

[help] alias msg - 30/01/19 03:17 PM

The problem is the following, the script was written on Mirс 7.52, everything was fine, now if you write

on *:TEXT:!test:#:{
timer1 1 3 zonahod
alias zonahod { msg $chan рарар врврв }

This message, instead of being sent to the channel, sends to the status as if it were a nickname.


and this happens only when the alias is called by a timer, if you call everything without a timer, and everything is fine with adiirс, after updating to 7.54 I thought that because of the update, I rolled it back to 7.52, but the same thing, help, is it really impossible to call? it seems like before i did everything it worked frown
Posted By: maroon

Re: [help] alias msg - 30/01/19 06:59 PM

when you call your alias manually, you're doing it from within the #channel window where $chan is defined either for a command typed in the editbox or launched from the nicklist or channel rightclick menus. mIRC has never defined $chan for a timer launched from :TEXT: or other similar events.

Note how the

* Timer 1 activated
* Timer 1 halted

created during your event are echoed by mIRC to the status window instead of the channel. To avoid the activated/halt message showing, use .timer instead of timer

If you want this alias to work from within the :TEXT: event, you need to pass the channel name to the alias on its command line

on *:TEXT:!test:#:{ 
timer1 1 3 zonahod $unsafe( $chan )

alias zonahod { var %a $chan | if ($1 ischan) var %a $1 | if (%a) msg %a message goes here }
Posted By: Greeple

Re: [help] alias msg - 30/01/19 09:04 PM

Sorry for the encoding, ok, everything is clear, but it seemed to me that a few months ago it worked for me, so I decided to ask grin
Posted By: Greeple

Re: [help] alias msg - 30/01/19 10:19 PM

Can I ask another question? Is there any way to resume the script with running timers when disconnected from the server and reconnect?
There are a lot of timers for each nickname, they are started up for their random time, and if they disconnect from the server, can they be resumed?
set %randtime $rand(50,500)
$+(timerzona.,$nick) 1 %randtime msg .... 
Posted By: maroon

Re: [help] alias msg - 31/01/19 02:38 AM

By default, timers go belly-up when they come from a network which disconnects, unless you use the -o switch.

If you're going to have timers trying to survive past a disconnect event, you would need to handle the possibility that they trigger while that network is not in a connected state, or during the interval between on-connect and re-joining that channel. This is too much to easily do inside a timer, so instead of having the timer contain the message, it should call an alias while passing along the parameters needed to correctly handle things. Make an alias foobar then call it something like:

$+(timerzona.,$nick) -o 1 %randtime foobar $nick $chan msg .... 

alias foobar {
if (!$nick($2,$1)) {
if ($2 ischan) { echo $2 note: nick $1 is no longer in channel either due to quitting or changing nick | return }
$+(timer,$ctimer) -o 1 $rand(50,500) foobar $1 $unsafe( $2- )
msg $2 channelname is $2 and nick is $1 and message is $4-

Note the code now has code to verify whether the nick is still around. If you need to, you can also add code to deal with the situation where someone changes nick while you're in channel. You could check if you have a timer named after $nick and clone the timer to $newnick then kill the old timer
Posted By: Greeple

Re: [help] alias msg - 31/01/19 12:54 PM

ok smile
© 2020 mIRC Discussion Forums