Not plays the music number 3
Hi
I made this plugin, but it have one bug.
It doesnt plays music of Key number 3.
Well i have no idea why this happens. Problem isnt song, or precache. It precache the song right, and i know problem isnt song because i tried with anothers. The problem is that it doesnt plays the song number 3.
PHP Code:
#include <amxmodx> #include <amxmisc>
#define PLUGIN "Music Menu" #define VERSION "3.5" #define AUTHOR "Jhob94"
new Trie:g_tSongs new g_iSongs
public plugin_precache() { new configsdir[200] new configfile[200] get_configsdir(configsdir,199) format(configfile,199,"%s/music_menu.cfg",configsdir) new Data[255], charnum new Left[64], Right[64] for(new i; i < g_iSongs; i++) { read_file(configfile,i,Data,255,charnum) if(strlen(Data)<2 || Data[0] == ';' || equali(Data,"//",2)) continue strbreak(Data, Left, 63, Right, 63) remove_quotes(Left) precache_generic(Left) } }
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd( "say /music", "Music_Menu" ) register_clcmd( "say_team /music", "Music_Menu" ) }
public Music_Menu( id ) { new menu = menu_create("Music Menu", "Music_Options") menu_additem(menu, "Stop The Music", "1", 0) g_tSongs = TrieCreate( ) new configsdir[200] new configfile[200] new szNum[3] get_configsdir(configsdir,199) format(configfile,199,"%s/music_menu.cfg",configsdir) g_iSongs = file_size(configfile, 1) new Data[255], charnum new Left[64], Right[64] for(new i; i < g_iSongs; i++) { read_file(configfile,i,Data,255,charnum) if(strlen(Data)<2 || Data[0] == ';' || equali(Data,"//",2)) continue strbreak(Data, Left, 63, Right, 63) remove_quotes(Left) remove_quotes(Right) TrieSetString(g_tSongs, Right, Left) num_to_str(i, szNum, 2) menu_additem(menu, Right, szNum, 0) } menu_setprop(menu, MPROP_EXIT, MEXIT_ALL) menu_display(id, menu, 0) }
public Music_Options(id, menu, item) { if (item == MENU_EXIT) { menu_destroy(menu) return PLUGIN_HANDLED } new info[3], name[64] new access, callback menu_item_getinfo(menu, item, access, info, 2, name, 63, callback) new key = str_to_num(info) if(key == 1) client_cmd(id, "mp3 stop") else { new szSongName[64] TrieGetString(g_tSongs, name, szSongName, 63) client_cmd(id, "mp3 play %s", szSongName) } return PLUGIN_CONTINUE }
Can some one help me? Need fix that for update in thread because last version have other bug that i fixed on this one.
EDIT:
It just happens with option 3 of menu. But if you go other page(more then 7 musics), 3 works. So basickly, what happens is that it doesnt loads the music that is in the line number 2 of cfg file.
Example of cfg file:
Code:
"media/Half-Life01.mp3" "Half-Life- 01"
"media/Half-Life02.mp3" "Half-Life- 02"
"media/Half-Life03.mp3" "Half-Life- 03"
"media/Half-Life04.mp3" "Half-Life- 04"
So on game when open menu it will show:
1. Stop music
2. Half-Life- 01
3. Half-Life- 02
4. Half-Life- 03
And music "Half-Life- 02" wont play. As i said isnt music problem, it happens with all songs that is on second line of cfg file.
|