mIRC Homepage
Posted By: UnDeadPuff Script for twitch - 20/02/15 08:12 PM
Hello

Cookies are a currency I award on my channel for the viewers that spend time there, and one of the usage of those cookies are that users can scare me via commands, and pay for that with said cookies. I have a script that should do that, and for some reason it doesn't. The script is supposed to take 5 cookies away from the user when he/she uses the !scarewave1 command, or tell them they don't have enough cookies if they have less than 5. Any help would be greatly appreciated, as this is already bugging me out to extreme extents.

Code:
on *:TEXT:!scaryWave1 :#:{
  var %topic = $+(#,.,$nick)
  var %cookies = $readini(Points.ini,%topic,Points)
  var %final = 5
  var %remove = %cookies - %final
  if (%remove > 4) {
    writeini -n Points.ini %topic Points %remove
    splay C:\Users\Marian\Desktop\Stream Images\StreamScary\ScaryWave1.mp3
  }
  if (%remove < 5) {
    msg $chan Sorry $nick $+ , but you need at least 5 cookies to scare me.
  }
}
Posted By: Nillen Re: Script for twitch - 20/02/15 08:30 PM
You appear to have a space at the end of the command, try removing that. Otherwise users should be forced to add a space when typing to be able to trigger it.
Posted By: UnDeadPuff Re: Script for twitch - 20/02/15 08:48 PM
You're life saver. I overlooked that and almost quit the thing...thank you very much. One more thing please?

set -u300 %floodscaryWave2. $+ $nick On
set -u300 %floodscaryWave2 On

these are supposed to set a flood control so users don't spam the commands. They don't really work though. any ideas why?
Posted By: Taracita Re: Script for twitch - 20/02/15 09:48 PM
An if statement should get the flood to work. Try:

Code:
 
if ((%floodscarywave2) || ($($+(%,floodscarywave2.,$nick),2))) { return }
  set -u300 %floodscarywave2 On
  set -u300 %floodscarywave2. $+ $nick On


This code makes it so that there has to be a 5 minute gap between any new person using the command, and also a 5 minute gap from anyone one person using it. I'm not sure that's what you intended, but I kept your same flood time.
Posted By: Nillen Re: Script for twitch - 21/02/15 05:02 AM
Precisely what Taracita said. You're creating variables, but you're not checking if the variables are active or not.

Here are some useful reads that will help you come to the next level of mSL

/help variables
/help aliases
/help if then else
Posted By: UnDeadPuff Re: Script for twitch - 21/02/15 12:20 PM
I want to stop users from spamming the scary commands (got several) as that would make the stream unpleasant, and get my bot banned by twitch (I'm scripting the bot for streaming purposes). The cooldown timer on any scare would be 5 minutes, as you said. Thank you for the help guys, appreciate!
Posted By: Majeye Re: Script for twitch - 22/02/15 01:19 PM
You could totally remove the nickname portion of the cooldown timer since you have the global cooldown set to the exact same timer of 5 minutes. the personal cooldown doesn't need to happen if no one can post the command for 5 minutes anyway.

here is the code with the nickname CD in it:
Code:
if ((%floodscarywave2) || ($($+(%,floodscarywave2.,$nick),2))) { return }
  set -u300 %floodscarywave2 On
  set -u300 %floodscarywave2. $+ $nick On


here it is without the nickname CD:
Code:
if ((%floodscarywave2) || ($($+(%,floodscarywave2.,$nick),2))) { return }
  set -u300 %floodscarywave2 On
Posted By: UnDeadPuff Re: Script for twitch - 01/03/15 10:20 AM
Hello

A quick question - how do I verify that a given variable is within a number range? eg. verify that %x is found in [1,20].
Posted By: Nillen Re: Script for twitch - 01/03/15 11:14 AM
/help if then else

You're looking for isnum.
The help files are your friend.
Posted By: UnDeadPuff Re: Script for twitch - 02/03/15 02:37 PM
Thanks
I know I'm annoying, and I am trying to figure out on my own as much as I can. But I just started meddling with irc scripts 2 weeks ago, so my knowledge is quite limited.

Code:
on *:TEXT:!rpg:#: {
  if ((%floodrpg) || ($($+(%,floodrpg.,$nick),2))) { return }
  set -u30 %floodrpg On
  set -u30 %floodrpg. $+ $nick On
  var %switch = $rand(0, 1)
  if (%switch == 0) {
    var %adventuremessage = $read(RPGEventsMinus.txt, n)
    var %eventcookies = $rand(1,20)
    msg $chan $nick loses %eventcookies cookies: %adventuremessage
    var %topic = $+(#,.,$nick)
    var %cookies = $readini(Points.ini,%topic,Points)
    var %remove = %cookies - %eventcookies
    writeini -n Points.ini %topic Points %remove
  }
  else {
    var %adventuremessage = $read(RPGEventsPlus.txt, n)
    var %eventcookies = $rand(1,20)
    msg $chan $nick gains %eventcookies cookies: %adventuremessage
    var %topic = $+(#,.,$nick)
    var %cookies = $readini(Points.ini,%topic,Points)
    var %remove = %cookies + %eventcookies
    writeini -n Points.ini %topic Points %remove
  }
}


Any ideas why the flood control would make this script not work at all? the flood is practically copied from the one given here by you, only replacing the command name and the timers. Thank you for your patience smile
Posted By: Belhifet Re: Script for twitch - 02/03/15 03:21 PM
You only return here if these events are true.

if ((%floodrpg) || ($($+(%,floodrpg.,$nick),2))) { return }


If this is making your script return, then you have one of these variable set.
Posted By: Taracita Re: Script for twitch - 03/03/15 10:12 AM
Exactly as Belhifet said. In the variables tab you want to check to see if the specified flood is listed. If it's there, that would be the reason the script isn't working. Currently, with the way you have it coded, it should only prevent flooding for 30 seconds per person, or 30 seconds between different people. Have you tried waiting the 30 seconds to see if it works again?
Posted By: UnDeadPuff Re: Script for twitch - 06/03/15 07:16 PM
Thank you, but it worked a little while after posting, without changing anything in the code. Not sure what the issue was there smile
© mIRC Discussion Forums