mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2018
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Sep 2018
Posts: 8
Hi, I need help with a script.

I need it to send a channel ad every so many minutes, with message that says something like:
"Type @Trigger for my list"
When someone types @Trigger I need it to send a notice to the user who typed it which contains a url.

This is my attempt so far, but I cant even get that to work, lol.
Thanks

Code:
on :text:@Trigger:#ChannelA:{
/notice $nick http://example.com
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
/help on TEXT
shows you need either a number, or in this case an asterisk, preceding that first colon. Also reminder that this event doesn't respond to your own channel text messages, so you'd need 2 clients to test it.

Joined: Sep 2018
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Sep 2018
Posts: 8
Thanks, that explains why I couldn't seem to get anything to work.

Joined: Sep 2018
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Sep 2018
Posts: 8
I have it working, but there's an odd bug which I don't understand, which is is doesn't stop if you unload the script, you have to close mirc to stop it.

To start it after you've loaded the script you type @Trigger and it will respond with the message and url, then every 300 seconds after it will play the channel ad until you close mirc.

Oddly having the trigger in the message doesn't seem to create a feedback loop.

Code:
on *:text:@Trigger:#ChannelA:{
  /notice $nick Latest List at: http://example.com
  /timer 0 300 /msg #ChannelA Type: @Trigger for my list
}


I'm new to all this so it's pretty raw. Any suggestions on improvements gratefully received. Thanks

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Each time someone types @Trigger this script would respond. If several people have this same script, then someone typing @Trigger gets a reply from several different scripts.

If you don't assign it a specific name, the timer is given the first available number starting with 1. So since this command is in a location which executes each time someone types @Trigger, it causes a new timer to launch.

Timers are not located in a script, so they don't get canceled when the script unload. I suggested in https://forums.mirc.com/ubbthreads.php/topics/264317/Cancel_script's_timers_/unload#Post264317 that it be an option, because timers often contain names of aliases only existing in the script being unloaded. If you had typed "/timer" you would have seen a list of all the timers running, and you could cancel them by name like "/timer1 off" or can replace the 1 with another nane or even a wildcard.

What you want is at least 1 of the following.

* only create the timer if it does not already exist
* have someone types something that doesn't make several people respond to them.

Code:
on *:text:@Trigger &:#ChannelA:{
  if ($2 != $me) return
  /notice $nick Latest List at: http://example.com
  if (!$timer(mylist)) /timerMyList 0 300 /msg #ChannelA for my list Type: @Trigger $me
}


The & is a wildcard symbol matching 1 word, so this responds only to someone typing a word following @Trigger, and the first command of the event checks to see if that word is your current nick.

This gives your timer a name, and it checks that a timer by that name doesn't exist before starting it. You want to assign it your own name, because if you don't assign it a text name, it gets assigned a number instead, and that can be a little harder for scripts to deal with. $timer(xyz) refers to the namer named xyz, but $timer(7) refers to the 7th timer in the list instead of timer7.

This timer doesn't check to make sure you're in the channel or that you're even at the correct network. You could add lines to check that, such as:

if ($network != value) return
if ($me !isin #ChannelA) return

By default, timers are cancelled when you disconnect from the network where they're running, unless you use the -o switch as mentioned in /help.

You can use F1 to access mirc's /help system, or type /help /timer or /help $timer to get more information on those specific topics.

As mentioned in https://www.mirc.com/help.html the Wiki at is still being created, but often has more detailed help and examples than found in /help
http://en.wikichip.org/wiki/mirc

You can also search in the forum for posts related to other people asking about the same topics. If you search for more than 1 keyword, it returns posts that mention at least 1 of the keywords. If you want only posts mentioning both, you need to search for +keyword1 +keyword2. You also need to change the time from the default 1 year, to find older posts.


Link Copied to Clipboard