mIRC Home    About    Download    Register    News    Help

Print Thread
The ever growing thirst for knowledge and help! #251968
11/03/15 08:09 PM
11/03/15 08:09 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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.
Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd] #251970
11/03/15 08:41 PM
11/03/15 08:41 PM
Joined: Jan 2004
Posts: 1,271
L
Loki12583 Offline
Hoopy frood
Loki12583  Offline
Hoopy frood
L

Joined: Jan 2004
Posts: 1,271
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.
Re: The ever growing thirst for knowledge and help! [Re: Loki12583] #251971
11/03/15 08:42 PM
11/03/15 08:42 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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.

Re: The ever growing thirst for knowledge and help! [Re: Loki12583] #251972
11/03/15 09:10 PM
11/03/15 09:10 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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.

Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd] #251974
11/03/15 10:03 PM
11/03/15 10:03 PM
Joined: Jan 2004
Posts: 1,271
L
Loki12583 Offline
Hoopy frood
Loki12583  Offline
Hoopy frood
L

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

Re: The ever growing thirst for knowledge and help! [Re: Loki12583] #251975
11/03/15 10:23 PM
11/03/15 10:23 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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. }
}

Re: The ever growing thirst for knowledge and help! [Re: Loki12583] #252002
14/03/15 07:23 PM
14/03/15 07:23 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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:

Re: The ever growing thirst for knowledge and help! [Re: Feyl0rd] #252003
14/03/15 07:30 PM
14/03/15 07:30 PM
Joined: Dec 2014
Posts: 40
Feyl0rd Offline OP
Ameglian cow
Feyl0rd  Offline OP
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.