mIRC Home    About    Download    Register    News    Help

Topic Options
#264906 - 30/01/19 03:17 PM [help] alias msg
Greeple Offline
Self-satisified door

Registered: 30/01/19
Posts: 4
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.

https://prnt.sc/meap2r

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

Top
#264907 - 30/01/19 06:59 PM Re: [help] alias msg [Re: Greeple]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1141
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

Code:
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 }

Top
#264908 - 30/01/19 09:04 PM Re: [help] alias msg [Re: maroon]
Greeple Offline
Self-satisified door

Registered: 30/01/19
Posts: 4
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

Top
#264909 - 30/01/19 10:19 PM Re: [help] alias msg [Re: maroon]
Greeple Offline
Self-satisified door

Registered: 30/01/19
Posts: 4
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?
Code:
set %randtime $rand(50,500)
$+(timerzona.,$nick) 1 %randtime msg .... 

Top
#264910 - 31/01/19 02:38 AM Re: [help] alias msg [Re: Greeple]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1141
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:

Code:
$+(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- )
return
}
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

Top
#264911 - 31/01/19 12:54 PM Re: [help] alias msg [Re: maroon]
Greeple Offline
Self-satisified door

Registered: 30/01/19
Posts: 4
ok smile

Top