yea thx. but its not functionaly
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <vault>
#define PLUGIN "MP3 Player"
#define VERSION "3.0"
#define AUTHOR "One"
#define MENU_EXIT -3
#define MENU_BACK -2
#define MENU_MORE -1
new g_ConfDir[128]
new g_sync_lrcdisplay
new g_sync_lrcdisplay2
new g_MP3_lenght
new g_MP3_menu
new g_Song_menu
new g_Nom_menu
new g_Vote_menu
new g_Votes[2] = 0
new g_Nom_Song[64]
new g_Block_Spam[33] = 0
new g_MP3_running = 0
public plugin_precache(){
get_configsdir(g_ConfDir,128)
load_config()
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("MP3_version", VERSION, FCVAR_SERVER);
register_clcmd("say /mp3","view_menu",ADMIN_RESERVATION);
register_clcmd("say /mute","mp3_stop");
register_clcmd("say /vote","nom_menu");
register_clcmd("amx_mp3_player","view_menu",ADMIN_RESERVATION,"opens the MP3_Player");
register_cvar("mp3_enable", "0")
g_sync_lrcdisplay = CreateHudSyncObj()
g_sync_lrcdisplay2 = CreateHudSyncObj()
g_MP3_menu = menu_create("MP3 Player","MP3_handle")
menu_additem(g_MP3_menu, "start MP3", "0")
menu_additem(g_MP3_menu, "stop MP3", "1")
}
//AMXX wiki new menu sys tutorial
public song_handle(id , menu, item){
if( item < 0 ) return PLUGIN_CONTINUE
new cmd[64]
new access, callback
menu_item_getinfo(menu, item, access, cmd,63,_,_, callback)
start_it(cmd)
return PLUGIN_HANDLED
}
public MP3_handle(id , menu, item){
if( item < 0 ) return PLUGIN_CONTINUE
new cmd[3]
new access, callback
menu_item_getinfo(menu, item, access, cmd,2,_,_, callback)
new choice = str_to_num(cmd)
if(choice == 0){
menu_display(id,g_Song_menu,0)
}else if(choice == 1){
stop_it()
}else if(choice == 2){
set_cvar_num("MP3_enable",1)
}else{
set_cvar_num("MP3_enable",0)
}
return PLUGIN_HANDLED
}
public nom_handle(id , menu, item){
if( item < 0 ) return PLUGIN_CONTINUE
if(!equal(g_Nom_Song,"")){
client_print(id,print_chat,"sorry, another vote is in progress");
return PLUGIN_CONTINUE
}
new cmd[64]
new access, callback
menu_item_getinfo(menu, item, access, cmd,63,_,_, callback)
g_Nom_Song = cmd
start_vote(id,cmd)
g_Block_Spam[id] = 1
set_task(30.0,"block_spam",id+1024);
return PLUGIN_HANDLED
}
public vote_handle(id,menu,item){
if( item < 0 ) return PLUGIN_CONTINUE
new cmd[3]
new access, callback
menu_item_getinfo(menu, item, access, cmd,2,_,_, callback)
new choice = str_to_num(cmd)
g_Votes[choice]++
new name[33]
get_user_name(id,name,32);
if(choice == 0){
client_print(0,print_chat,"%s voted for!",name)
}else{
client_print(0,print_chat,"%s voted against!",name)
}
return PLUGIN_CONTINUE
}
public block_spam(id){
id = id-1024
g_Block_Spam[id] = 0
}
public view_menu(id){
if ((get_user_flags(id) & ADMIN_RCON) || (get_user_flags(id) & ADMIN_LEVEL_A))
{
menu_display(id,g_MP3_menu,0)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public nom_menu(id){
if(g_Block_Spam[id] == 1){
client_print(id,print_chat,"sorry, you have to wait a bit to nominate another MP3!");
return PLUGIN_CONTINUE
}
if(get_cvar_num("MP3_enable")==0){
client_print(id,print_chat,"sorry, MP3 Player isn't enabled, ask an admin!");
return PLUGIN_CONTINUE
}
if(g_MP3_running == 1){
client_print(id,print_chat,"sorry, another MP3 is running!");
return PLUGIN_CONTINUE
}
menu_display(id,g_Nom_menu,0)
return PLUGIN_CONTINUE
}
public start_vote(id,const sng[]){
new name[33]
get_user_name(id,name,32);
new head[128]
format(head,127,"%s want to play : %s",name,sng);
g_Vote_menu = menu_create(head,"vote_handle")
menu_additem(g_Vote_menu,"Okay...","0");
menu_additem(g_Vote_menu,"No way!!!!","1");
new num,players[32]
get_players(players,num,"h")
for(new i = 0;i < num;i++){
menu_display(players[i],g_Vote_menu,0);
}
set_task(10.0,"end_vote")
}
public end_vote(){
if(g_Votes[0]>g_Votes[1]){
start_it(g_Nom_Song);
client_print(0,print_chat,"Vote successful! [FOR : %d AGAINST: %d]",g_Votes[0],g_Votes[1]);
}else{
client_print(0,print_chat,"Vote failed! [FOR : %d AGAINST: %d]",g_Votes[0],g_Votes[1]);
}
g_Nom_Song = ""
g_Votes[0] = 0
g_Votes[1] = 0
menu_destroy(g_Vote_menu);
}
public load_config(){
new loadfile[128]
format(loadfile,127,"%s/mp3.cfg",g_ConfDir)
new file = fopen(loadfile,"r")
g_Song_menu = menu_create("Wich song?","song_handle")
g_Nom_menu = menu_create("wich song?","nom_handle")
if ( !file_exists(loadfile) ){
log_amx("MP3 Player : cant find settings(mp3.cfg)")
menu_additem(g_Song_menu, "No Data", "-3")
return
}
new data[128]
while(!feof(file)){
fgets(file,data,127)
new f[128],key[64]
trim(data)
if(equal(data,"")) continue
strbreak(data,key,63,f,127);
replace_all ( f, 127, "^"", "" )
replace_all ( key, 63, "^"", "" )
set_vaultdata(key,f);
log_amx("MP3 Player: Loaded %s as %s",f,key)
if(get_cvar_num("MP3_enable")==1)
engfunc(EngFunc_PrecacheGeneric,f)
menu_additem(g_Song_menu, key, key)
menu_additem(g_Nom_menu, key, key)
}
}
public mp3_stop(id){
client_cmd(id,"mp3 stop");
}
public get_MP3_run(){
return g_MP3_running
}
public announce(id){
id = id -2048
if(g_MP3_running == 0) return PLUGIN_CONTINUE
set_hudmessage(255, 255, 255, -1.0, 0.65, 0, 6.0, 5.0)
if(id == 0){
ShowSyncHudMsg(0, g_sync_lrcdisplay, "Okay let's go!!!!!!!!")
}else if( id == 1){
ShowSyncHudMsg(0, g_sync_lrcdisplay, "Attention a MP3 is now starting in %d second",id)
}else{
ShowSyncHudMsg(0, g_sync_lrcdisplay, "Attention MP3 starting in %d seconds",id)
}
return PLUGIN_CONTINUE
}
public start_MP3(str[]){
if(g_MP3_running == 1){
new text[128]
new file[128]
load_MP3(text)
get_vaultdata(text,file,127)
client_cmd(0,"mp3 play %s",file)
}
}
public stop_it(){
g_MP3_running = 0
client_cmd(0,"mp3 stop")
for(new i = 0; i <g_MP3_lenght;i++){
remove_task(i)
}
for(new i = 0;i < 17;i++){
remove_task(i+2048)
}
set_hudmessage(255, 255, 255, -1.0, 0.65, 0, 6.0, 5.0)
ShowSyncHudMsg(0, g_sync_lrcdisplay, "MP3 Aborted!!!!")
}
public start_it(const str[]){
stop_it()
g_MP3_running = 1
new param[ 1 ]
set_task(15.0,"start_MP3",16+2048,param,1);
set_task(15.0,"announce",0+2048)
set_task(14.0,"announce",1+2048)
set_task(13.0,"announce",2+2048)
set_task(12.0,"announce",3+2048)
set_task(11.0,"announce",4+2048)
set_task(10.0,"announce",5+2048)
set_task(5.0,"announce",10+2048)
announce(15+2048)
set_hudmessage(255, 255, 255, -1.0, 0.6, _, 0.2, 13.0,1.0,1.0)
ShowSyncHudMsg(0, g_sync_lrcdisplay2, "MP3 : %s",str)
}
public load_MP3(const lfile[]){
new loadfile[128]
log_amx("MP3 Player : file %s",loadfile)
new file = fopen(loadfile,"rt")
if ( !file_exists(loadfile) ){
log_amx("MP3 Player : cant find file.")
return
}
new data[128]
g_MP3_lenght = 0
while(!feof(file)){
fgets(file,data,127)
trim(data)
new tme[10], text[128]
if(containi(data,"[") == -1)
continue
if(containi(data,"[]") != -1)
continue
strtok(data,tme,9,text,127,']')
new minu[4], sec[6]
strtok(tme,minu,3,sec,5,':')
new Float:t = str_to_float(sec)
new dummy[2]
strtok(minu,dummy,1,minu,3,'[')
new Float:m = str_to_float(minu)
m = m * 60
t = t+m
trim(text)
//server_cmd("say time = %f",t);
new param[ 2 ]
param[ 1 ] = g_MP3_lenght
set_task(t,"show_MP3",g_MP3_lenght,param, 2)
g_MP3_lenght++
}
}