|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
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. 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.
}
}
Last edited by UnDeadPuff; 20/02/15 08:13 PM.
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
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.
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
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?
|
|
|
|
Joined: Feb 2015
Posts: 3
Self-satisified door
|
Self-satisified door
Joined: Feb 2015
Posts: 3 |
An if statement should get the flood to work. Try:
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.
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
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
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
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!
Last edited by UnDeadPuff; 21/02/15 01:41 PM.
|
|
|
|
Joined: Jan 2014
Posts: 107
Vogon poet
|
Vogon poet
Joined: Jan 2014
Posts: 107 |
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: if ((%floodscarywave2) || ($($+(%,floodscarywave2.,$nick),2))) { return }
set -u300 %floodscarywave2 On
set -u300 %floodscarywave2. $+ $nick On here it is without the nickname CD: if ((%floodscarywave2) || ($($+(%,floodscarywave2.,$nick),2))) { return }
set -u300 %floodscarywave2 On
|
|
|
|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
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].
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
/help if then else
You're looking for isnum. The help files are your friend.
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
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.
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
Last edited by UnDeadPuff; 02/03/15 02:38 PM.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
Fjord artisan
Joined: Jun 2014
Posts: 248 |
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.
|
|
|
|
Joined: Feb 2015
Posts: 3
Self-satisified door
|
Self-satisified door
Joined: Feb 2015
Posts: 3 |
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?
|
|
|
|
Joined: Feb 2015
Posts: 16
Pikka bird
|
OP
Pikka bird
Joined: Feb 2015
Posts: 16 |
Thank you, but it worked a little while after posting, without changing anything in the code. Not sure what the issue was there
|
|
|
|
|