mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
In a Twitch channel, we have a function for a weekly "sweetheart". This person gets certain perks for the week and one of the fun functions is that the chat's bot "stalks" them.

However I can't get the script to go past this portion of the code and continue to read the rest of the script. I've tried re-writing this part several times now.

Could anyone help me figure out how to write this portion? Here is a sample of what I have now:

Code:
 ;SWEETHEART STALKER
on *:text:*:#: {
  if ($nick == %sweet. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ]) {
    var %sweetr = $rand(1,20)
    if (%sweetr == 1) { msg $chan Hey, sweetheart <3 } 
    if (%sweetr == 2) { msg $chan It's the channel qt 3.14 <3 } 
    if (%sweetr == 3) { msg $chan Wow you are absolutely A-M-A-Z-I-N-G <3 } 
    if (%sweetr == 4) { msg $chan Oh hey der Kappa <3 } 
  }
} 


Thanks!

Joined: Oct 2009
Posts: 24
Ameglian cow
Offline
Ameglian cow
Joined: Oct 2009
Posts: 24
Your $rand() has 1-20 while you only have 4 if statements. Either add 16 more ifs or change the $rand() to be 1-4.

Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
I changed it to only 1,4 and the script still won't continue. I should note, the random statements work fine, I just can't get the script to read past this block of code.

I have this after it to test it:
Code:
;SCRIPT TESTER - Test to see if script is read to the very bottom
on *:text:!stest:#:{
  if ($nick == budd_manlove) { msg # Test successful! } { return }
}

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Well that's invalid syntax, so that might have something to do with it.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
$network doesn't exist/work on the Twitch IRC server, so try and remove that part

Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Loki12583
Well that's invalid syntax, so that might have something to do with it.


Could you explain what you mean?

Also, the original code above actually works. I just cant get the script to read past it (even if the rand() is set 1-20, it works). The next block of code (!stest command) works as well but only when I comment out the sweetheart coding.

Last edited by Budd; 04/01/15 10:58 PM.
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Sakana
$network doesn't exist/work on the Twitch IRC server, so try and remove that part


I've removed it, the code still works but I still can't get it to read past it.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
The syntax is supposed to be something like this (the return is redundant though)

Code:
on *:text:!stest:#:{
  if ($nick == budd_manlove) { 
  msg # Test successful! 
  return 
  }
}

Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Thanks for that. The !stest portion actually worked before. I changed it to what you suggested and it still works but only if I comment out the sweetheart portion. If the sweetheart portion is active, it doesn't reach that part of the script to respond to the !stest command.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
When you have a script that triggers on any text, it's usually a good idea to place it in its own file in the scripts editor. Otherwise, other on text events written in the same file tend to stop working

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Well, events written in the same file just don't "tend" to stop working lol. mIRC will search the script file for a matching event, once one event has matched, mIRC simply stop looking into that file. You can only trigger one kind of event per file, suppose your remote script file is:
Code:
on *:text:*:#:{ echo -s $nick said on $chan : $1- }
on *:text:!test:#:{ echo -s $nick executed !test on $chan }


If someone type !test, the second on text event will never trigger, because the first one with the '*' matchtext will always match for "!test". Now suppose to change the order:

Code:
on *:text:!test:#:{ echo -s $nick executed !test on $chan }
on *:text:*:#:{ echo -s $nick said on $chan : $1- }


If someone now type !test, the first on text event will trigger, the second one won't, however in this situation, the second on text event can be triggered (for anything else than "!test" given as $1-)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Originally Posted By: Sakana
When you have a script that triggers on any text, it's usually a good idea to place it in its own file in the scripts editor. Otherwise, other on text events written in the same file tend to stop working


Thank you, I'm a bit new to this if you couldn't tell. Would you mind telling me how to create a separate file for this? I've scripted everything so far in the "remote" tab so I don't know how to have mIRC read outside of that tab.

@Wims - That makes a lot of sense. So basically, I either need that portion at the bottom of the script, or not in the script at all, or accessible from another location.

Last edited by Budd; 05/01/15 12:06 AM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
smile

Just click File -> New when you're in the Remote tab. You can change between files under View

Joined: Jan 2015
Posts: 9
B
Budd Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
B
Joined: Jan 2015
Posts: 9
Thanks Sakana!


Link Copied to Clipboard