AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Music Menu (https://forums.alliedmods.net/showthread.php?t=185166)

bazhenov93 05-13-2012 13:19

Music Menu
 
hello There :x
After reading this, I started creating the plugin, for me it will be useful too..
The plugin was simple, and it was bored.. So I decided add some stuff..
The problem I have:

to stop an sound (.wav) it's client_cmd(id, "stopsound) - but for .mp3?
I don't remember it, but is something like "mp3 stop" right?

Also, how can I check what music is listening the player? (func in handler)
2. See /listen func, I hope someone understand what I mean..

Anyways, any help will be appreciated!! :oops:

Also, could be nice if someone can explain me how to add text to menu from an .ini/.cfg file..
LIKE:

%TITLE1% = Music title 1.. %FILE% = music1.mp3
and etc... thanks :)

PHP Code:

#include <amxmodx>
#include <colorchat>
 
#define PLUGIN "Music Menu"
#define VERSION "0.0.1"
new const music[][] = {
 
 
"sound/misc/mymusic/On_ne_dlya_tebya.mp3",
 
"sound/misc/mymusic/Lydi_odino4ki.mp3",
 
"sound/misc/mymusic/Ne_zavidui.mp3",
 
"sound/misc/mymusic/String_Tek.mp3",
 
"sound/misc/mymusic/Rolling_In The_Deep",
 
"sound/misc/mymusic/Proste_dvizheniya.mp3",
 
"sound/misc/mymusic/Stripped.mp3",
 
"sound/misc/mymusic/Adelante.mp3",
 
"sound/misc/mymusic/Royksopp_Forever.mp3",
 
"sound/misc/mymusic/It_Was_Written.mp3",
 
"sound/misc/mymusic/Extacy.mp3",
 
"sound/misc/mymusic/Silly_Girl.mp3"
}
new const 
tracks[][] = {
 
 
"?????? feat Elvira T - ?? ?? ??? ????",
 
"?????? Project - ???? ????????",
 
"Конец Фильма - ?? ???????",
 
"X-Ray Dog - String Tek",
 
"Adele - Rolling In The Deep (Dimension DNB Remix",
 
"Tatu - Proste dvizheniya",
 
"Shiny Toy Guns - Stripped",
 
"Sash - Adelante",
 
"Rцyksopp  - Royksopp Forever",
 
"Damian Marley - It Was Written (Chasing Shadows Remix)",
 
"Infected Mushroom - Extacy",
 
"Neon Hitch - Silly Girl"
}
new 
bool:IsPlaying[33], MenuWasOpened[33]
new 
status[64], listen 
 
public plugin_precache(){
 for(new 
isizeof musici++)
 
precache_generic(music[i])
}
public 
plugin_init(){
 
register_plugin(PLUGINVERSION"Twix^^")
 
 
register_clcmd("say""HookSayAll")
 
register_clcmd("say_team""HookSayTeam")
 
 
register_clcmd"say /music""cmdMusic")
 
register_clcmd"say_team /music""cmdListen")
 
register_clcmd"say /listen""cmdListen")
 
register_clcmd"say_team /listen""cmdListen")
 
register_clcmd"say /stop""cmdStop")
 
register_clcmd"say_team /stop""cmdStop")
 
listen register_cvar("listen""1")
}
public 
HookSayAll(id){
 
 new 
szSaid128 ], iLen
 iLen 
charsmaxszSaid )
 
read_argsszSaidiLen )
 
remove_quotesszSaid )
 
 if ( 
containszSaid"/music" ) == ){
 
  
MenuWasOpened[id] = true
 
}
}
public 
HookSayTeam(id){
 
 new 
szSaid128 ], iLen
 iLen 
charsmaxszSaid )
 
read_argsszSaidiLen )
 
remove_quotesszSaid )
 
 if ( 
containszSaid"/music" ) == ){
 
  
MenuWasOpened[id] = true
 
}
}
public 
cmdMusic(id){
 new 
menu menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n""cmdMusic_Func")
 
formatex(status63"\wMusic: %s^n"IsPlaying[id] ? "\rON" "\dOFF")
 
menu_additem(menu"\wOn ne dlya tebya..""a1")
 
menu_additem(menu"\wLydi odino4ki""a2")
 
menu_additem(menu"\wNe zavidui""a3")
 
menu_additem(menu"\wString Tek^n""a4")
 
menu_additem(menu"\yRANDOM^n""a5")
 
menu_additem(menustatus"a6")
 
menu_additem(menu"\wNext""a7")
 
menu_setprop(menuMPROP_EXITMEXIT_ALL);
 
menu_display(idmenu0);
}
 
PAGE2(id){
 new 
menu menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n""cmdMusic_Func")
 
formatex(status63"\wMusic: %s^n"IsPlaying[id] ? "\rON" "\dOFF")
 
menu_additem(menu"\wRolling In The Deep (Dimension DNB Remix)""b1")
 
menu_additem(menu"\wProste dvizheniya""b2")
 
menu_additem(menu"\wStripped""b3")
 
menu_additem(menu"\wAdelante^n""b4")
 
menu_additem(menustatus"b5")
 
menu_additem(menu"\wBack""b6")
 
menu_additem(menu"\wNext""b7")
 
menu_setprop(menuMPROP_EXITMEXIT_ALL)
 
menu_display(idmenu0)
}
 
PAGE3(id){
 new 
menu menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n""cmdMusic_Func")
 
formatex(status63"\wMusic: %s^n"IsPlaying[id] ? "\rON" "\dOFF")
 
menu_additem(menu"\wRoyksopp Forever""c1")
 
menu_additem(menu"\wIt Was Written (Chasing Shadows Remix)""c2")
 
menu_additem(menu"\wSave Me (Bulb Remix)""c3")
 
menu_additem(menu"\wSilly Girl^n""c4")
 
menu_additem(menustatus"c5")
 
menu_additem(menu"\wBack""c6")
 
menu_setprop(menuMPROP_EXITMEXIT_ALL)
 
menu_display(idmenu0)
}
public 
cmdMusic_Func(idmenuitem){
 
 if( 
item == MENU_EXIT ){
  
menu_destroy(menu)
  return 
PLUGIN_HANDLED
 
}
 new 
data[6], szName[64]
 new 
accesscallback
 menu_item_getinfo
(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback)
 new 
key str_to_num(data[1])
 switch( 
data[0] )
 {
  case 
'a':
  {
   switch(
key)
   {
    case 
1:
    {
     
playMusic(idmusic[0])
     
IsPlaying[id] = true
     cmdMusic
(id)
 
 
     
listenFunc(id)
    }
    case 
2:
    {
     
playMusic(idmusic[1])
     
IsPlaying[id] = true
     cmdMusic
(id)
    }
    case 
3:
    {
     
playMusic(idmusic[2])
     
IsPlaying[id] = true
     cmdMusic
(id)
    }
    case 
4:
    {
     
playMusic(idmusic[3])
     
IsPlaying[id] = true
     cmdMusic
(id)
    }
    case 
5:
    {
     
playMusic(idmusic[random_num(0sizeof music -1)])
     
IsPlaying[id] = true
     cmdMusic
(id)
    }
    case 
6:
    {
     if(
IsPlaying[id]){
      
stop_playMusic(id)
      
IsPlaying[id] = false
      cmdMusic
(id)
 
      }else{
 
      
IsPlaying[id] = true
      cmdMusic
(id)
     }
    }
    case 
7:
    {
     
PAGE2(id)
    }
   }
  }
  case 
'b':
  {
   switch( 
key )
   {
    case 
1:
    {
     
playMusic(idmusic[4])
     
IsPlaying[id] = true
     PAGE2
(id)
    }
    case 
2:
    {
     
playMusic(idmusic[5])
     
IsPlaying[id] = true
     PAGE2
(id)
    }
    case 
3:
    {
     
playMusic(idmusic[6])
     
IsPlaying[id] = true
     PAGE2
(id)
    }
    case 
4:
    {
     
playMusic(idmusic[7])
     
IsPlaying[id] = true
     PAGE2
(id)
    }
    case 
5:
    {
     if(
IsPlaying[id]){
      
stop_playMusic(id)
      
IsPlaying[id] = false
      PAGE2
(id)
 
      }else{
 
      
IsPlaying[id] = true
      PAGE2
(id)
     }
    }
    case 
6:
    {
     
cmdMusic(id)
    }
    case 
7:
    {
     
PAGE3(id)
    }
   }
  }
  case 
'c':
  {
   switch( 
key )
   {
    case 
1:
    {
     
playMusic(idmusic[8])
     
IsPlaying[id] = true
     PAGE3
(id)
    }
    case 
2:
    {
     
playMusic(idmusic[9])
     
IsPlaying[id] = true
     PAGE3
(id)
    }
    case 
3:
    {
     
playMusic(idmusic[10])
     
IsPlaying[id] = true
     PAGE3
(id)
    }
    case 
4:
    {
     
playMusic(idmusic[11])
     
IsPlaying[id] = true
     PAGE3
(id)
    }
    case 
5:
    {
     if(
IsPlaying[id]){
      
stop_playMusic(id)
      
IsPlaying[id] = false
      PAGE3
(id)
 
      }else{
 
      
IsPlaying[id] = true
      PAGE3
(id)
     }
    }
    case 
6:
    {
     
PAGE2(id)
    }
   }
  }
 }
 
menu_destroy(menu)
 return 
PLUGIN_HANDLED
}
public 
playMusic(idmusic[]){
 
 
hudStuff(id)
 
client_cmd(id"mp3 play %s"music)
}
public 
cmdStop(id){
 if(
IsPlaying[id]){
   
client_cmd(id"stop")
   
IsPlaying[id] = false
  
}
}
public 
stop_playMusic(id){
 
  if(
IsPlaying[id]){
   
client_cmd(id"stopsound")
   
set_hudmessage(random(256),random(256),random(256), 0.110.3723.03.00.11.5)
   
show_hudmessage(id"Music: OFF")
   
IsPlaying[id] = false
 
   
}else{
  if(!
IsPlaying[id]){
   
set_hudmessage(random(256),random(256),random(256), 0.110.3723.03.00.11.5)
   
show_hudmessage(id"Music: ON")
   
playMusic(idmusic[random_num(0sizeof music -1)])
   
IsPlaying[id] = true
  
}
 }
}
public 
listenFunc(id){
 
 new 
szName[33]
 
get_user_name(idszName32)
 if(
get_pcvar_num(listen))
 {
  
ColorChat(0GREY"%s is now listening ^4%s ^3- type /listen to hear it!"szNametracks[0])
 }
}
public 
cmdListen(id){
 
 new 
getMusic // how to catch if the user is listenind song title ?
 
new getUser_listening // how to cath the song that are listening another player ?
 
 
if(!MenuWasOpened[id]){
  
ColorChat(idGREY,"Currently no one is listening any music! Type ^4/music ^3and be the first!")
  return 
PLUGIN_HANDLED
 
}
 
 if(
IsPlaying[id]){
  
ColorChat(idGREY,"You already listening ^4%s"getMusic)
  return 
PLUGIN_HANDLED
 
}
 
 if(!
IsPlaying[id]){
 
client_cmd(id"mp3 play %s"getUser_listening)
 
IsPlaying[id] = true
 
 
}
 
 return 
PLUGIN_CONTINUE
}
public 
hudStuff(id){
 
 if(
IsPlaying[id]){
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3821.02.00.11.0, -1)
 
show_hudmessage(id"|||||||||||||||||||||||")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3621.02.00.11.0, -2)
 
show_hudmessage(id"...................................")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3821.02.00.11.0, -3)
 
show_hudmessage(id"")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3621.02.00.11.0, -4)
 
show_hudmessage(id"|||||||||||||||||||||||")
 
 
set_task(5.0"hud_Stuff")
 }
 
 if(!
IsPlaying[id]){
  return 
PLUGIN_HANDLED
 
}
 
 return 
PLUGIN_CONTINUE
}
public 
hud_Stuff(id){
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3821.02.00.40.1, -2)
 
show_hudmessage(id"|||||||||||||||||||||||")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3621.02.00.40.1, -3)
 
show_hudmessage(id"...................................")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3821.02.00.40.1, -1)
 
show_hudmessage(id"")
 
 
set_hudmessage(random(256),random(256),random(256), 0.020.3621.02.00.41.1, -4)
 
show_hudmessage(id"|||||||||||||||||||||||")
 
 
set_task(5.0"hudStuff")



mottzi 05-13-2012 17:40

Re: Music Menu
 
Stop mp3: jup the command is mp3 stop.
/listening: Just save the song at the moment you play the sound.

bazhenov93 05-14-2012 15:54

Re: Music Menu
 
The problem is that I never worked with that, and I don't know how to save it..
Maybe temp file?

mottzi 05-15-2012 01:52

Re: Music Menu
 
There are several examples on the forums. Just search :)

bazhenov93 05-15-2012 02:13

Re: Music Menu
 
I have searched in the whole 14 pages and didn't find it!
Or are you talking about nvault?


All times are GMT -4. The time now is 00:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.