mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
I'm a total noob at mIRC, but I do have some basic commands on my bot for my channel. The only thing I'm missing for my bot that I need is a game list function. Basically the whole !join and !list thing. I've looked around the forum and I did manage to find a thread with ALMOST everything I need. The only thing I'm missing is a !next command so that the bot will remove the current user on the list, and say "[username], it's your turn to join!" for the next viewer on the list. Can anyone help me with the script? I can post what I have so far for this script if it helps.

on *:text:!join:#: {
if ($read(list.txt,nw,$nick)) { msg $chan $nick , you're already on the list you silly goose! | return }
else write list.txt $nick
msg $chan Alright $nick , I've added you to the list!
}

on *:text:!del *:#: {
if ($nick isop #) {
if (!$read(list.txt,nw,$2)) { msg $chan $2 isn't on the list. | return }
elseif ($read(list.txt,nw,$2)) { msg $chan Ok, I've deleted $2 from the list.
write -dl $+ $readn list.txt }
}
}

on *:text:!list:#: {
var %t1 $read(list.txt,1)
var %t2 $read(list.txt,2)
var %t3 $read(list.txt,3)
var %t4 $read(list.txt,4)
var %t5 $read(list.txt,5)
msg $chan %t1 %t2 %t3 %t4 %t5 }
}

If all I can get is a !next command, I'd be content. However, it'd also be really helpful if someone could help me with the !list command. When I type !list, the bot lists the users like this: "mario luigi yoshi peach" I would like it to be a little more organized. Maybe at least have commas in between each name, or have numbers next to each username. Another thing I would like to have is a !clearlist command to clear the entire list. Oh yeah, and is it possible to have an !open and !close list script that opens and closes the user's ability to enter?

I know it's quite a lot, but I would really appreciate if someone could lend a hand. Thanks!

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
On *:TEXT:!list:#: {
var %l = $lines(list.txt)
var %x = 1
while (%x <= %l) {
var %p = $read(list.txt, %x)
set %list $addtok(%list,$+(%x,.,$chr(32),%p,$chr(44),$chr(32)),32)
inc %x 
}
msg $chan %list
unset %list
}

This should do exactly what you want for list.
Code:
On *:TEXT:!close:#: {
If (%listopen) {
unset %listopen
msg $chan List Is Now Closed! No more joins allowed!
}
if (!%listopen) {
msg $chan List Is Already Closed.
}
}

On *:text:!open:#: {
if (%listopen) {
msg $chan List Is Already Open.
}
elseif (!%listopen) {
unset %listopen
msg $chan List Is Now Open. You may join!
}
}

on *:text:!join:#: { 
if (%listopen) {
if ($read(list.txt,nw,$nick)) { msg $chan $nick , you're already on the list you silly goose! | return }
else { 
write list.txt $nick 
msg $chan Alright $nick , I've added you to the list!
}
}
}

and this is !open !close
and !join with one more line to work with !open and !close


now.. do you have a script that defines who the current user is? Or is it the 1st user on the list?


Last edited by OrFeAsGr; 01/11/15 03:07 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Thank you so much!

I don't have a script that defines who the current user is. Actually, I now realize that I'm starting more from nothing than I am with something for a game list function for my bot lol.
So now, all I need is a script that defines who the current user is, one that can move from the current user to the next user in the list(a !next command), and one that can clear the list totally.

Last edited by UncleKoopa; 01/11/15 06:49 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Ok, so I pasted the scripts in. The !list works just fine when I had it paired with my old !join command. It doesn't work with this new one, however. There are some other problems with all of the other commands too. Here's a screenshot of the problem: https://gyazo.com/2bef7fa9963324a14f2d40464f71d4f9

So when I open the list twice, it doesn't say "list is already open" on the 2nd !open. Also, when I try to close the list, it says "List is already closed" instead of "The list is now closed" I also can't join when the list is open. Any idea on what the problem could be? I pasted the code in, so I didn't change anything. I even created a new remote file specifically for the game list and it didn't work.

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
I'm sorry for this... i was writing this from my phone and i made a tone of mistakes because i was in a rush.
Code:
On *:TEXT:!close:#: {
if (%listopen) {
unset %listopen
msg $chan List Is Now Closed! No more joins allowed!
}
if (!%listopen) {
msg $chan List Is Already Closed.
}
}

On *:text:!open:#: {
if (%listopen) {
msg $chan List Is Already Open.
}
elseif (!%listopen) {
set %listopen 1
msg $chan List Is Now Open. You may join!
}
}

on *:text:!join:#: { 
if (%listopen) {
if ($read(list.txt,nw,$nick)) { msg $chan $nick , you're already on the list you silly goose! | return }
elseif (!$read(list.txt,nw,$nick)) {
write list.txt $nick 
msg $chan Alright $nick , I've added you to the list!
}
}
}

This should work!
NOTE: My mistake was that on the !open script i did unset %listeopen even when the %listopen didnt exist (so list was closed) I also fixed some other typos.
Does !list script work right?
;
;
Also write -c list.txt will erase all lines of list.txt

Last edited by OrFeAsGr; 01/11/15 10:22 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
I managed to get it to work, thanks a bundle. I even managed to make them OP commands only. And yes, the !list command works just fine.
Now, I think the only thing left is a !next command for the list. I need to be able to cycle through each user on the list. Is there any way to do that?

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
ON *:TEXT:!next:#: {
if ($nick isop $chan) {
inc %usercount 1
if (%usercount < $lines(list.txt)) {
msg $chan It's time for $read(list.txt, %usercount) to play!
}
elseif (%usercount == $lines(list.txt)) {
inc %usercount 1
msg $chan It's time for $read(list.txt, %usercount) to play again
}
elseif (%usercount > $lines(list.txt)) {
;unset %usercount
;msg $chan List Is Over!
set %usercount 1
msg $chan Back to $read(list.txt, %usercount) !
}
}

As it is now it will start over when the last player has played. If you want it to end when the last player plays remove the ; from the lines and put it in the next 2 smile

Last edited by OrFeAsGr; 02/11/15 11:49 AM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Alright, so I took the 2 ; and put them onto the next 2 lines which worked. However, the command isn't totally functional. Here's the issue: https://i.gyazo.com/b0047641c2e0105b95ffc9c97ec426df.png

So, there are 3 people on this list. When I get to the 3rd person on this list, their name doesn't show up. It just says "It's time for to play again" when it's supposed to say "It's time for Afroraptor1 to play". Also, when the list is over, whenever I use !next it goes back to the top of the list when it's supposed to delete the users as I go through each one. Any idea what the problem could be?

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
ON *:TEXT:!next:#: {
if ($nick isop $chan) {
inc %usercount 1
if (%usercount <= $lines(list.txt)) {
msg $chan It's time for $read(list.txt, %usercount) to play!
if (%usercount == $lines(list.txt)) {
write -c list.txt
unset %usercount
}
}
}
}

This will erase all lines when you reach the last player.

Last edited by OrFeAsGr; 03/11/15 03:59 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
It works, thank you so much! I kind of feel bad because I'm just asking you over and over for more scripts because I know next to nothing about mIRC. I'm really thankful that you were able to help me, my bot is nearing perfection!

I just have one more question. I was playing around with the script you sent before that makes the bot say "The list is over!" when I type !next and the list is empty. I was trying to take that part and fit it in with the most recent script you sent, but to no avail. What do I need to add to the most recent script you sent to make it say "The list is over" when I type !next?

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Do you want it to say The List Is Over along with the player message of the last player or when you say !next after the last player.
I mean:
Code:
UncleKoopa: !next
Bot: Time for "last_player" to play
...
UncleKoopa: !next 
Bot: List is over!

Or
Code:
Unclekoopa: !next
Bot: Time for "last_player" to play!
Bot: The List Is Over

Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Code:
UncleKoopa: !next
Bot: Time for "last_player" to play
...
UncleKoopa: !next 
Bot: List is over!

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
ON *:TEXT:!next:#: {
if ($nick isop $chan) {
inc %usercount 1
if (%usercount <= $lines(list.txt)) {
msg $chan It's time for $read(list.txt, %usercount) to play!
}
if (%usercount > $lines(list.txt)) {
msg $chan The List Is Over
write -c list.txt
unset %usercount
}
}
}

For that we don't unset the variable and dont erase the lines when we reach the last player. We let it the same, so the next time you say !next %usercount is more than the lines
Code:
if (%usercount > $lines(list.txt)) {

And this triggers and erases the lines and unsets %usercount
smile I hope i helped!! You don't ask for a lot, i like to help when i can!

Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Works like a charm! Thank you so much for all of your help! I've managed to learn just a tiny bit more about how writing commands work. I'm super happy you were able to help. My custom Twitch bot now has all of the basics. Eventually, I'd like to maybe add a songrequest system and a strawpoll system, but I'll do the research some other day. I'm just glad I finally have this list. Thank you SOOOO much, OrFeAsGr, you're the man.

Last edited by UncleKoopa; 04/11/15 10:26 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
Oh, and one more quick thing. Sorry!

Code:
on *:text:!join:#: { 
  if (%listopen) {
    if ($read(list.txt,nw,$nick)) { msg $chan $nick , you're already on the list silly goose! | return }
    elseif (!$read(list.txt,nw,$nick)) {
      write list.txt $nick 
      msg $chan /me grabs her pencil and adds $nick to the list
    }
  }
}


What should I add to this to make it so that if someone tries to join and the list is closed, the bot will say "Sorry, but the list is currently closed"

Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Code:
on *:text:!join:#: { 
  if (%listopen) {
    if ($read(list.txt,nw,$nick)) { msg $chan $nick , you're already on the list silly goose! | return }
    elseif (!$read(list.txt,nw,$nick)) {
      write list.txt $nick 
      msg $chan /me grabs her pencil and adds $nick to the list
    }
  }
elseif (!%listopen) {
msg $chan Sorry, but the list is currently closed 
}
}

hey, sorry for not answering i havent been on for some days! This should work smile

Last edited by OrFeAsGr; 10/11/15 04:18 PM.
Joined: Nov 2015
Posts: 10
U
Pikka bird
OP Offline
Pikka bird
U
Joined: Nov 2015
Posts: 10
It works. Thank you so much for your help! I seriously appreciate it.


Link Copied to Clipboard