|
Veteran Member
|

05-13-2012
, 13:19
Music Menu
|
#1
|
hello There 
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!!
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 i; i < sizeof music; i++) precache_generic(music[i]) } public plugin_init(){ register_plugin(PLUGIN, VERSION, "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 szSaid[ 128 ], iLen iLen = charsmax( szSaid ) read_args( szSaid, iLen ) remove_quotes( szSaid ) if ( contain( szSaid, "/music" ) == 0 ){ MenuWasOpened[id] = true } } public HookSayTeam(id){ new szSaid[ 128 ], iLen iLen = charsmax( szSaid ) read_args( szSaid, iLen ) remove_quotes( szSaid ) if ( contain( szSaid, "/music" ) == 0 ){ MenuWasOpened[id] = true } } public cmdMusic(id){ new menu = menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n", "cmdMusic_Func") formatex(status, 63, "\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(menu, status, "a6") menu_additem(menu, "\wNext", "a7") menu_setprop(menu, MPROP_EXIT, MEXIT_ALL); menu_display(id, menu, 0); } PAGE2(id){ new menu = menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n", "cmdMusic_Func") formatex(status, 63, "\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(menu, status, "b5") menu_additem(menu, "\wBack", "b6") menu_additem(menu, "\wNext", "b7") menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) menu_display(id, menu, 0) } PAGE3(id){ new menu = menu_create("\w======- \rMusic Menu \w-======^n\r OR WHATEVER,, TITLE here..^n", "cmdMusic_Func") formatex(status, 63, "\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(menu, status, "c5") menu_additem(menu, "\wBack", "c6") menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) menu_display(id, menu, 0) } public cmdMusic_Func(id, menu, item){ if( item == MENU_EXIT ){ menu_destroy(menu) return PLUGIN_HANDLED } new data[6], szName[64] new access, callback menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback) new key = str_to_num(data[1]) switch( data[0] ) { case 'a': { switch(key) { case 1: { playMusic(id, music[0]) IsPlaying[id] = true cmdMusic(id) listenFunc(id) } case 2: { playMusic(id, music[1]) IsPlaying[id] = true cmdMusic(id) } case 3: { playMusic(id, music[2]) IsPlaying[id] = true cmdMusic(id) } case 4: { playMusic(id, music[3]) IsPlaying[id] = true cmdMusic(id) } case 5: { playMusic(id, music[random_num(0, sizeof 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(id, music[4]) IsPlaying[id] = true PAGE2(id) } case 2: { playMusic(id, music[5]) IsPlaying[id] = true PAGE2(id) } case 3: { playMusic(id, music[6]) IsPlaying[id] = true PAGE2(id) } case 4: { playMusic(id, music[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(id, music[8]) IsPlaying[id] = true PAGE3(id) } case 2: { playMusic(id, music[9]) IsPlaying[id] = true PAGE3(id) } case 3: { playMusic(id, music[10]) IsPlaying[id] = true PAGE3(id) } case 4: { playMusic(id, music[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(id, music[]){ 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.11, 0.37, 2, 3.0, 3.0, 0.1, 1.5) show_hudmessage(id, "Music: OFF") IsPlaying[id] = false }else{ if(!IsPlaying[id]){ set_hudmessage(random(256),random(256),random(256), 0.11, 0.37, 2, 3.0, 3.0, 0.1, 1.5) show_hudmessage(id, "Music: ON") playMusic(id, music[random_num(0, sizeof music -1)]) IsPlaying[id] = true } } } public listenFunc(id){ new szName[33] get_user_name(id, szName, 32) if(get_pcvar_num(listen)) { ColorChat(0, GREY, "%s is now listening ^4%s ^3- type /listen to hear it!", szName, tracks[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(id, GREY,"Currently no one is listening any music! Type ^4/music ^3and be the first!") return PLUGIN_HANDLED } if(IsPlaying[id]){ ColorChat(id, GREY,"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.02, 0.38, 2, 1.0, 2.0, 0.1, 1.0, -1) show_hudmessage(id, "|||||||||||||||||||||||") set_hudmessage(random(256),random(256),random(256), 0.02, 0.36, 2, 1.0, 2.0, 0.1, 1.0, -2) show_hudmessage(id, "...................................") set_hudmessage(random(256),random(256),random(256), 0.02, 0.38, 2, 1.0, 2.0, 0.1, 1.0, -3) show_hudmessage(id, "") set_hudmessage(random(256),random(256),random(256), 0.02, 0.36, 2, 1.0, 2.0, 0.1, 1.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.02, 0.38, 2, 1.0, 2.0, 0.4, 0.1, -2) show_hudmessage(id, "|||||||||||||||||||||||") set_hudmessage(random(256),random(256),random(256), 0.02, 0.36, 2, 1.0, 2.0, 0.4, 0.1, -3) show_hudmessage(id, "...................................") set_hudmessage(random(256),random(256),random(256), 0.02, 0.38, 2, 1.0, 2.0, 0.4, 0.1, -1) show_hudmessage(id, "") set_hudmessage(random(256),random(256),random(256), 0.02, 0.36, 2, 1.0, 2.0, 0.4, 1.1, -4) show_hudmessage(id, "|||||||||||||||||||||||") set_task(5.0, "hudStuff") }
Last edited by bazhenov93; 05-13-2012 at 14:08.
|
|