mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Alright. I'm back again with another idea and would like some insight / guidance. I'm looking to create a script that stores a Youtube link into (maybe a hashtable?) and has on text command that pulls the top one out of the table and then deletes it. So maybe something like:
Code:
;Song playLIST
on *:text:!songrequest*:#:{
  if %pl = on {
    /hadd -a 1 $$2 playlist
  }
  if %pl = off {
    /hmake playlist
    var %pl = on
    /hadd -a 1 $$2 playlist
  }
}

on *:text:!nextsong:#:{
  if ($nick == bubbernaut_cce) {
    msg $chan $hget(playlist, 1)
  }
  else { msg $chan only bubbernaut_cce can run this command. }
}

Last edited by Feyl0rd; 11/03/15 08:11 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Hash tables don't have a top. I suggest adding actual entries as numerical indices and have some other keys (current, next, last) which point to the indices.

Code:
on *:text:!songrequest*:#:{
  hinc playlist last
  hadd playlist $hget(playlist,last) $2
}

on *:text:!nextsong:#:{
  if ($hget(playlist,current)) hdel playlist $v1
  hinc playlist current

  echo -ag current song is $hget(playlist,$hget(playlist,current))
}


All that said, appending to a plain text file then reading and deleting the first line would not be a terrible implementation for this either.

Last edited by Loki12583; 11/03/15 10:03 PM.
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Thanks for the reply. I actually might try the txt file idea. Seems pretty straight forward... I think.

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Using the example you've posted it spits out numbers in order instead of the link that's supposed to be associated with the number it spits out. I tried fiddling with it but I can't get it to spit out the link instead of the number.

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Yep my bad, just need to wrap that index in another $hget - I've edited the original post

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
Yep, that fixed it, haha.
I was working on the txt varient of this. But I couldn't get it to work. It would read line 2 (because it would delete line 1 before it could read it and spit it out I guess.)
Code:
on *:text:!songrequest*:#:{
  write playlist.txt $2
}
on *:text:!next:#:{
  if ($nick == feyl0rd) || if ($nick == bubbernaut_cce) {
    msg $chan The next song is: $read(playlist.txt,.,1)
    .timer 1 4 write -dl 1 playlist.txt
  }
  else { msg $chan only bubbernaut_cce can run this command. }
}

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
After some more testing with your post. It seems that it just continues on down a list. Example:
User1: !songrequest X
User2: !songrequest Y
User3: !songrequest Z
Mod: !nextsong
Bot: Song: Z
Mod: !nextsong
Bot: Song:
Mod: !nextsong
Bot: Song:

Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Dec 2014
Posts: 40
I'm thinking maybe a while loop would fix this? I'll look into it a bit more.


Link Copied to Clipboard