Raised This Month: $ Target: $400
 0% 

mp3 player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-19-2008 , 19:48   mp3 player
Reply With Quote #1

Hey,

i dont know ( i forget there anything but what?

its all ok but in menu,when i press 1 to play, nothing happend can anyone say what there faild ?(
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_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("MP3_version"VERSIONFCVAR_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 menuitem){
    if( 
item ) return PLUGIN_CONTINUE
    
new cmd[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,63,_,_callback)
    
start_it(cmd)
    return 
PLUGIN_HANDLED
}
public 
MP3_handle(id menuitem){
    if( 
item ) return PLUGIN_CONTINUE
    
new cmd[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 menuitem){
    if( 
item ) 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 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 ) return PLUGIN_CONTINUE
    
new cmd[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 
0;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 f127"^"", "" ) 
        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_menukeykey)
        
menu_additem(g_Nom_menukeykey)
        
    }
}

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
(255255255, -1.00.6506.05.0)
    if(
id == 0){
        
ShowSyncHudMsg(0g_sync_lrcdisplay"Okay let's go!!!!!!!!")
    }else if( 
id == 1){
        
ShowSyncHudMsg(0g_sync_lrcdisplay"Attention a MP3 is now starting in %d second",id)
    }else{
        
ShowSyncHudMsg(0g_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]
        
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 
0<g_MP3_lenght;i++){
        
remove_task(i)
    }
    for(new 
0;17;i++){
        
remove_task(i+2048)
    }
    
set_hudmessage(255255255, -1.00.6506.05.0)
    
ShowSyncHudMsg(0g_sync_lrcdisplay"MP3 Aborted!!!!")
    
}
public 
start_it(const str[]){
    
stop_it()
    
g_MP3_running 1
    
new param]
    
param] = EncodeTextstr )
    
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(255255255, -1.00.6_0.213.0,1.0,1.0)
    
ShowSyncHudMsg(0g_sync_lrcdisplay2"MP3 : %s",str)
}



EncodeText( const text[] )
{
    return 
engfuncEngFunc_AllocStringtext )
}
DecodeText( const textstring[], const length )
{
    
global_getglb_pStringBasetextstringlength )

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 12-19-2008 , 20:03   Re: mp3 player
Reply With Quote #2

This code hurts my eyes.
__________________

Community / No support through PM
danielkza is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-19-2008 , 20:17   Re: mp3 player
Reply With Quote #3

its sooooooooo bad?

u have another idea?
i have eyestrain im working on it around 5 hours
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 12-19-2008 , 20:37   Re: mp3 player
Reply With Quote #4

u didnt precache the sounds in plugin_precache...
:S
__________________
minimiller is offline
Send a message via MSN to minimiller
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 12-19-2008 , 21:23   Re: mp3 player
Reply With Quote #5

yea thx. but its not functionaly same problem (

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(PLUGINVERSIONAUTHOR)
    
register_cvar("MP3_version"VERSIONFCVAR_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 menuitem){
    if( 
item ) return PLUGIN_CONTINUE
    
new cmd[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,63,_,_callback)
    
start_it(cmd)
    return 
PLUGIN_HANDLED
}
public 
MP3_handle(id menuitem){
    if( 
item ) return PLUGIN_CONTINUE
    
new cmd[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 menuitem){
    if( 
item ) 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 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 ) return PLUGIN_CONTINUE
    
new cmd[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccesscmd,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 
0;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 f127"^"", "" ) 
        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_menukeykey)
        
menu_additem(g_Nom_menukeykey)
        
    }
}

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
(255255255, -1.00.6506.05.0)
    if(
id == 0){
        
ShowSyncHudMsg(0g_sync_lrcdisplay"Okay let's go!!!!!!!!")
    }else if( 
id == 1){
        
ShowSyncHudMsg(0g_sync_lrcdisplay"Attention a MP3 is now starting in %d second",id)
    }else{
        
ShowSyncHudMsg(0g_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 
0<g_MP3_lenght;i++){
        
remove_task(i)
    }
    for(new 
0;17;i++){
        
remove_task(i+2048)
    }
    
set_hudmessage(255255255, -1.00.6506.05.0)
    
ShowSyncHudMsg(0g_sync_lrcdisplay"MP3 Aborted!!!!")
    
}
public 
start_it(const str[]){
    
stop_it()
    
g_MP3_running 1
    
new param]
    
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(255255255, -1.00.6_0.213.0,1.0,1.0)
    
ShowSyncHudMsg(0g_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:str_to_float(sec)
        new 
dummy[2]
        
strtok(minu,dummy,1,minu,3,'[')
        new 
Float:str_to_float(minu)
        
60
        t 
t+m
        trim
(text)
        
//server_cmd("say time =  %f",t);
        
new param]
        
param] = g_MP3_lenght
        set_task
(t,"show_MP3",g_MP3_lenght,param2)
        
g_MP3_lenght++
        
    }

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:13.


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