| Wolddal[A] |
01-09-2013 16:46 |
Plugin errors
Hello!
I have this radio plugin:
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "MiniRadio by SLIMSHADY"
#define VERSION "1.0"
#define AUTHOR "slimshady"
new s_Item[256], g_MusicStatus[32], name[32], itemol[256], i
new fmst[128], txt[128], station[128]
new i_Menu, cvar
new const status[][] =
{
"http://cluster.quantumart.ru/broadcast/default.aspx?media=hitfm"
}
new const status2[][] =
{
"HIT FM"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /fm", "fmd")
cvar = register_cvar("amx_miniradio_showtime", "60.0")
radhud()
}
public fm(id)
{
new i_Menu = menu_create("\yMiniRadio \wBy \rSLIMSHADY:", "radio")
menu_additem(i_Menu, status2[0], "1",0)
menu_additem(i_Menu, status2[1], "2", 0)
menu_additem(i_Menu, status2[2], "3", 0)
menu_additem(i_Menu, status2[3], "4", 0)
menu_additem(i_Menu, status2[4], "5", 0)
menu_additem(i_Menu, status2[5], "6", 0)
menu_additem(i_Menu, status2[6], "7", 0)
menu_additem(i_Menu, status2[7], "8", 0)
menu_additem(i_Menu, status2[8], "9", 0)
menu_additem(i_Menu, status2[9], "10", 0)
menu_additem(i_Menu, status2[10], "11", 0)
menu_additem(i_Menu, status2[11], "12", 0)
menu_setprop(i_Menu, MPROP_NEXTNAME, "далее")
menu_setprop(i_Menu, MPROP_BACKNAME, "назад")
menu_setprop(i_Menu, MPROP_EXITNAME, "Выйти")
menu_setprop(i_Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, i_Menu, 0)
return PLUGIN_HANDLED
}
public client_disconnect(id)
g_MusicStatus[id] = 0
public hudradio(i)
{
name[i] = 0
itemol[0] = 0
for(i = 1; i <= get_maxplayers(); i++)
{
if(!is_user_connected(i) || !g_MusicStatus[i])
continue
get_user_name(i, name, 31)
formatex(itemol, 255, "%s %s^n", itemol, name)
}
}
public radhud()
{
if(name[i] == 0)
{
set_hudmessage(127, 0, 255, 0.85, 0.31, 2, 6.0, 12.0, 0.0, 0.0, 1)
show_hudmessage(0, "Слушай FM радио!^nНапиши /fm в чат =)")
}
else
{
set_hudmessage(127, 0, 255, 0.85, 0.31, 2, 6.0, 12.0, 0.0, 0.0, 1)
show_hudmessage(0, "Слушай FM радио!^nНапиши /fm в чат =)^nРадио слушают:^n%s", itemol)
}
set_task(get_pcvar_float(cvar), "radhud")
}
public fmd(id)
{
formatex(s_Item, charsmax(s_Item), "%s", g_MusicStatus[id] ? "\yОтключить" : "\yВключить случайное")
if(g_MusicStatus[id] == 1)
{
formatex(txt, charsmax(txt), "\yMiniRadio \wBy \rSLIMSHADY^n\wВы слушаете: \y%s", station[id])
i_Menu = menu_create(txt, "radiod")
menu_additem(i_Menu, s_Item, "1", 0)
menu_additem(i_Menu, "Случайная станция", "3", 0)
menu_additem(i_Menu, "\wСписок станций", "2", 0)
}
else
{
i_Menu = menu_create("\yMiniRadio \wBy \rSLIMSHADY", "radiod")
menu_additem(i_Menu, s_Item, "1", 0)
menu_additem(i_Menu, "\wСписок станций", "2", 0)
}
menu_setprop(i_Menu, MPROP_NEXTNAME, "далее")
menu_setprop(i_Menu, MPROP_BACKNAME, "назад")
menu_setprop(i_Menu, MPROP_EXITNAME, "Выйти")
menu_setprop(i_Menu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, i_Menu, 0)
return PLUGIN_HANDLED
}
public radiod(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new s_Data[6], s_Name[64], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
new i_Key = str_to_num(s_Data)
switch(i_Key)
{
case 1:
{
if(g_MusicStatus[id] > 0)
{
g_MusicStatus[id] = 0
hudradio(i)
ShowInfMotd(id)
}
else
{
randomize(id)
}
}
case 2:
{
fm(id)
}
case 3:
{
randomize(id)
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public ShowInfMotd(id)
{
static buffer[4096], len;
if(g_MusicStatus[id] == 0)
{
len = format(buffer, charsmax(buffer), "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
len += format(buffer[len], charsmax(buffer) - len, "<title>play</title></head><body bgcolor='black'>")
len += format(buffer[len], charsmax(buffer) - len, "<p align='center'>")
len += format(buffer[len], charsmax(buffer) - len, "<font color='red'><big><b>Radio by SLIMSHADY is DISABLED</b></big></font><br>")
len += format(buffer[len], charsmax(buffer) - len, "</p></body></html>")
}
else
{
len = format(buffer, charsmax(buffer), "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
len += format(buffer[len], charsmax(buffer) - len, "<title>play</title></head><body bgcolor='black'>")
len += format(buffer[len], charsmax(buffer) - len, "<p align='center'>")
len += format(buffer[len], charsmax(buffer) - len, "<font color='red'><big><b>Playing: </b></big></font><font color='lawngreen'><big><b>%s</b></big></font><br>", station[id])
len += format(buffer[len], charsmax(buffer) - len, "<p align='left'>")
len += format(buffer[len], charsmax(buffer) - len, "<font color='yellow'><b>Идет буферизация... Вы можете закрыть окно.</b></font><br>")
len += format(buffer[len], charsmax(buffer) - len, "<font color='red'>(Если не включится в течении 30-ти секунд, нужно перезагрузить - отключить и заново включить.)</font><br>")
len += format(buffer[len], charsmax(buffer) - len, "<!--h--><DIV align=center><EMBED style='WIDTH: 298px; HEIGHT: 100px' height=500 type=application/x-mplayer2 pluginspage=http://www.microsoft.com/Windows/MediaPlayer/ ")
len += format(buffer[len], charsmax(buffer) - len, "width=500 src='%s' ShowStatusBar='1' showtracker='0' ", fmst[id])
len += format(buffer[len], charsmax(buffer) - len, "displaysize='0' autosize='1' showcontrols='true' animationatstart='0' transparentatstart='0' autostart='true'></DIV>")
len += format(buffer[len], charsmax(buffer) - len, "</p></body></html>")
}
show_motd(id, buffer, "RADIO BY SLIMSHADY")
}
public radio(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new s_Data[6], s_Name[64], i_Access, i_Callback
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
new i_Key = str_to_num(s_Data)
formatex(fmst[id], charsmax(fmst), "%s", status[i_Key-1])
formatex(station[id], charsmax(fmst), "%s", status2[i_Key-1])
g_MusicStatus[id] = 1
ShowInfMotd(id)
hudradio(i)
menu_destroy(menu)
return PLUGIN_HANDLED
}
public randomize(id)
{
new rrand = random_num(0, 11)
formatex(fmst[id], charsmax(fmst), status[rrand])
formatex(station[id], charsmax(fmst), status2[rrand])
g_MusicStatus[id] = 1
ShowInfMotd(id)
hudradio(i)
return PLUGIN_HANDLED
}
And it gives me some errors:
Code:
Displaying debug trace (plugin "radios.amxx")
Run time error 4: index out of bounds
[0] radio.sma::hudradio (line 84)
[1] radio.sma::randomize (line 222)
[2] radio.sma::radiod (line 161)
Code:
AMXX] Run time error 4: index out of bounds
[AMXX] [0] radio.sma::client_disconnect (line 76)
What should I edit in order to work perfectly ?
Thanks a lot!
|