mIRC Homepage

Cannot get script to continue

Posted By: Budd

Cannot get script to continue - 04/01/15 07:51 PM

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!
Posted By: Scakk

Re: Cannot get script to continue - 04/01/15 08:59 PM

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.
Posted By: Budd

Re: Cannot get script to continue - 04/01/15 09:12 PM

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 }
}
Posted By: Loki12583

Re: Cannot get script to continue - 04/01/15 09:54 PM

Well that's invalid syntax, so that might have something to do with it.
Posted By: Sakana

Re: Cannot get script to continue - 04/01/15 09:55 PM

$network doesn't exist/work on the Twitch IRC server, so try and remove that part
Posted By: Budd

Re: Cannot get script to continue - 04/01/15 10:56 PM

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.
Posted By: Budd

Re: Cannot get script to continue - 04/01/15 11:03 PM

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.
Posted By: Sakana

Re: Cannot get script to continue - 04/01/15 11:06 PM

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 
  }
}
Posted By: Budd

Re: Cannot get script to continue - 04/01/15 11:10 PM

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.
Posted By: Sakana

Re: Cannot get script to continue - 04/01/15 11:30 PM

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
Posted By: Wims

Re: Cannot get script to continue - 05/01/15 12:01 AM

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-)
Posted By: Budd

Re: Cannot get script to continue - 05/01/15 12:02 AM

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.
Posted By: Sakana

Re: Cannot get script to continue - 05/01/15 01:48 AM

smile

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

Re: Cannot get script to continue - 05/01/15 02:59 AM

Thanks Sakana!
© 2022 mIRC Discussion Forums