|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Hey there! New here, never have done anything with mirc :P So I have a bunch of keys for a beta. I want my bot to whisper a key to people whenever they type in !Key. I have all the keys in a text file. So my idea if for the script to whisper them a key from the first line of the text file then delete the first line of the text file, so that when someone else types in !key, they get the next key. I got the whisper from a text file working, but not too sure how to set up the delete part? Any help is greatly appreciated, thanks! on *:text:!key:#:{ msg $nick $read(C:\Users\Owner\AppData\Roaming\mIRC\keys.txt, n, 1) /write -dl1 C:\Users\Owner\AppData\Roaming\mIRC\keys.txt }
|
|
|
|
Joined: Mar 2016
Posts: 6
Nutrimatic drinks dispenser
|
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 6 |
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
No i was seeing if someone could help me fix it. Thanks!
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Got it to whisper a code, delete the first line, and repeat. I also set a cooldown. Is there a way to keep the cooldown active even when mirc closes and restarts? Thanks! Here it is as of now: on *:text:!key:#:{ if (!%comwait) { set -u604800 %comwait 1 msg $nick $read(C:\Users\Matt\AppData\Roaming\mIRC\keys.txt, n, 1) /write -dl1 C:\Users\Matt\AppData\Roaming\mIRC\keys.txt } else msg $chan Sorry $nick, you're only allowed 1 key a week! <3 }
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Try use this code:
ON *:TEXT:!key:*: {
var %f = C:\Users\Owner\AppData\Roaming\mIRC\keys.txt
if (!$isfile(%f)) { msg $nick Error: File Not exist! | return }
if (!$lines(%f)) { msg $nick Error: File is empty! | return }
var %r = $read(%f,nt,1)
var %rn = $readn
if (%r) {
msg $nick %r
write -dl $+ %rn $qt(%f)
}
elseif (!%r) { msg $nick There is NOT any key available! }
}
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Try use this code:
ON *:TEXT:!key:*: {
var %f = C:\Users\Owner\AppData\Roaming\mIRC\keys.txt
if (!$isfile(%f)) { msg $nick Error: File Not exist! | return }
if (!$lines(%f)) { msg $nick Error: File is empty! | return }
var %r = $read(%f,nt,1)
var %rn = $readn
if (%r) {
msg $nick %r
write -dl $+ %rn $qt(%f)
}
elseif (!%r) { msg $nick There is NOT any key available! }
}
That actually works really well! The "There is NOT any key available!" does not work if the file is empty though, but besides that, it works How can I add a cooldown to this command that lasts even if the mirc chat is closed and re-opened? Say a week cooldown or so? Thanks again, you're awesome!
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Use this code:
ON *:TEXT:!key:*: {
if (%keywait) && (%keywait > $ctime) { return }
var %f = C:\Users\Owner\AppData\Roaming\mIRC\keys.txt
if (!$isfile(%f)) { msg $nick Error: File Not exist! | return }
if (!$lines(%f)) { msg $nick Error: File is empty! | return }
var %r = $read(%f,nt,1)
var %rn = $readn
if (%r) { set %keywait $calc($ctime + 604800) | msg $nick %r | write -dl $+ %rn $qt(%f) }
}
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Use this code:
ON *:TEXT:!key:*: {
if (%keywait) && (%keywait > $ctime) { return }
var %f = C:\Users\Owner\AppData\Roaming\mIRC\keys.txt
if (!$isfile(%f)) { msg $nick Error: File Not exist! | return }
if (!$lines(%f)) { msg $nick Error: File is empty! | return }
var %r = $read(%f,nt,1)
var %rn = $readn
if (%r) { set %keywait $calc($ctime + 604800) | msg $nick %r | write -dl $+ %rn $qt(%f) }
}
That one isn't working at all. No popup or txt deletion at all. Any idea on what to change? Thanks again!
Last edited by fusebaum; 07/03/16 08:28 PM.
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
It suposed to execute 1 time the command per 1 week as you requested, so if you used the command then you should wait 1 week to use it again.
In order you want to cancel that use: /unset %keywait
The code is working perfect as i tested.
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
It suposed to execute 1 time the command per 1 week as you requested, so if you used the command then you should wait 1 week to use it again.
In order you want to cancel that use: /unset %keywait
The code is working perfect as i tested. Awesome, that does work! My bad One last thing if you can help me with it? So someones uses the command, gets a code, if they type it in again, can they get a message in chat that says "Sorry, but you can only get 1 code a week, you have 5d 4h 32m left" or maybe just "Sorry, you can only get 1 code a week" Thanks again, you're amazing! I really, really appreciate all the help
Last edited by fusebaum; 07/03/16 09:03 PM.
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Just change the 2nd line with this:
if (%keywait) && (%keywait > $ctime) { .msg $nick ( $+ $nick $+ ): You can try again in $qt($duration($calc(%keywait - $ctime))) to use the command! | return }
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Just change the 2nd line with this:
if (%keywait) && (%keywait > $ctime) { .msg $nick ( $+ $nick $+ ): You can try again in $qt($duration($calc(%keywait - $ctime))) to use the command! | return }
You're awesome. Thank you so much for all the help, I really, really appreciate it
|
|
|
|
Joined: Apr 2010
Posts: 969
Hoopy frood
|
Hoopy frood
Joined: Apr 2010
Posts: 969 |
If this is to be used on twitch, you'll need something like my mTwitch scripts to enable twitch whispers for mIRC
Last edited by FroggieDaFrog; 09/03/16 12:45 AM.
|
|
|
|
Joined: Mar 2016
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Mar 2016
Posts: 8 |
Just change the 2nd line with this:
if (%keywait) && (%keywait > $ctime) { .msg $nick ( $+ $nick $+ ): You can try again in $qt($duration($calc(%keywait - $ctime))) to use the command! | return }
Hey there! So this is working great for me, but it doesn't actually work for anyone else, it will just say "This much time left" in their whispers. Any idea on how to fix it? TRhanks!
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
You want to work for the other users and not for the currently user that used the command? If yes use this code:
ON *:TEXT:!key:*: {
if (%keywait_ [ $+ [ $nick ] ]) && (%keywait_ [ $+ [ $nick ] ] > $ctime) { return }
var %f = C:\Users\Owner\AppData\Roaming\mIRC\keys.txt
if (!$isfile(%f)) { msg $nick Error: File Not exist! | return }
if (!$lines(%f)) { msg $nick Error: File is empty! | return }
var %r = $read(%f,nt,1)
var %rn = $readn
if (%r) { set %keywait_ [ $+ [ $nick ] ] $calc($ctime + 604800) | msg $nick %r | write -dl $+ %rn $qt(%f) }
}
|
|
|
|
|
|
|
|