mIRC Home    About    Download    Register    News    Help

Print Thread
F
fusebaum
fusebaum
F
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! laugh

Quote:
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
}

I
Iyou
Iyou
I
Did your scripz works ?

F
fusebaum
fusebaum
F
Originally Posted By: Iyou
Did your scripz works ?

No smirk

i was seeing if someone could help me fix it. Thanks!

F
fusebaum
fusebaum
F
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:

Quote:
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,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
Try use this code:

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! }
}

F
fusebaum
fusebaum
F
Originally Posted By: westor
Try use this code:

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 laugh

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,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
Use this code:

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) }
}

F
fusebaum
fusebaum
F
Originally Posted By: westor
Use this code:

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,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
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.

F
fusebaum
fusebaum
F
Originally Posted By: westor
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 laugh

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 smile


Last edited by fusebaum; 07/03/16 09:03 PM.
Joined: Dec 2008
Posts: 1,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
Just change the 2nd line with this:

Code:
  if (%keywait) && (%keywait > $ctime) { .msg $nick ( $+ $nick $+ ): You can try again in $qt($duration($calc(%keywait - $ctime))) to use the command! | return }

F
fusebaum
fusebaum
F
Originally Posted By: westor
Just change the 2nd line with this:

Code:
  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 laugh

Joined: Apr 2010
Posts: 964
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 964
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.
F
fusebaum
fusebaum
F
Originally Posted By: westor
Just change the 2nd line with this:

Code:
  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,483
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,483
You want to work for the other users and not for the currently user that used the command?

If yes use this code:

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) }
}


Link Copied to Clipboard