mIRC Home    About    Download    Register    News    Help

Topic Options
#251968 - 11/03/15 08:09 PM The ever growing thirst for knowledge and help!
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
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. }
}


Edited by Feyl0rd (11/03/15 08:11 PM)

Top
#251970 - 11/03/15 08:41 PM Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd]
Loki12583 Offline
Hoopy frood

Registered: 22/01/04
Posts: 1244
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.


Edited by Loki12583 (11/03/15 10:03 PM)

Top
#251971 - 11/03/15 08:42 PM Re: The ever growing thirst for knowledge and help! [Re: Loki12583]
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
Posts: 40
Thanks for the reply. I actually might try the txt file idea. Seems pretty straight forward... I think.

Top
#251972 - 11/03/15 09:10 PM Re: The ever growing thirst for knowledge and help! [Re: Loki12583]
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
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.

Top
#251974 - 11/03/15 10:03 PM Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd]
Loki12583 Offline
Hoopy frood

Registered: 22/01/04
Posts: 1244
Yep my bad, just need to wrap that index in another $hget - I've edited the original post

Top
#251975 - 11/03/15 10:23 PM Re: The ever growing thirst for knowledge and help! [Re: Loki12583]
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
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. }
}

Top
#252002 - 14/03/15 07:23 PM Re: The ever growing thirst for knowledge and help! [Re: Loki12583]
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
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:

Top
#252003 - 14/03/15 07:30 PM Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd]
Feyl0rd Offline
Ameglian cow

Registered: 15/12/14
Posts: 40
I'm thinking maybe a while loop would fix this? I'll look into it a bit more.

Top