Really?
I would have thought that
PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Custom Radio Commands"
#define VERSION "1.0"
#define AUTHOR "X-Script"
#define TOTAL_RADIOS 15
new custom_radio;
new menu_handle ;
new radio_files[TOTAL_RADIOS][]=
{
"RADIO/roger.wav"
,"RADIO/negative.wav"
,"RADIO/go.wav"
,"RADIO/followme.wav"
,"RADIO/stormfront.wav"
,"RADIO/locknload.wav"
,"RADIO/matedown.wav"
,"RADIO/com_reportin.wav"
,"RADIO/fireinhole.wav"
,"RADIO/imhit.wav"
,"RADIO/needbackup.wav"
,"RADIO/position.wav"
,"RADIO/regroup.wav"
,"RADIO/blow.wav"
,"RADIO/clear.wav"
}
new radio_names[TOTAL_RADIOS][]=
{
"Roger"
,"Negative"
,"Go"
,"Follow Me"
,"Move It"
,"Move Out"
,"Man Down"
,"Status"
,"Fire in the Hole"
,"Taking Fire"
,"Need Backup"
,"Cover Area"
,"Return to Base"
,"Get Down"
,"Clear"
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /radio", "C_RADIO")
register_clcmd("say /radio1", "C_RADIO1")
register_concmd("/radio", "C_RADIO")
register_concmd("/radio1", "C_RADIO1")
custom_radio = register_cvar("amx_newradio", "1")
create_menu()
}
create_menu()
{
menu_handle = menu_create("Radio","SelectRadio")
for ( new i ; i < TOTAL_RADIOS; i ++ )
{
menu_additem(menu_handle,radio_names[i])
}
menu_setprop(menu_handle, MPROP_PERPAGE,9)
menu_setprop(menu_handle,MPROP_EXIT,MEXIT_ALL)
}
public client_putinserver(id)
{
set_task(10.0, "connectmessage", id)
}
public connectmessage(id)
{
client_print(id, print_chat, "This server is running Custom Radio Commands by X-Script!")
client_print(id, print_chat, "Bind two keys to the commands: /radio and /radio1 then press the keys for the Radio Menus")
return PLUGIN_HANDLED
}
public plugin_precache()
{
new sound[64];
for ( new i ; i < TOTAL_RADIOS ; i ++ )
precache_sound(sound)
return PLUGIN_HANDLED
}
public C_RADIO(id)
{
menu_display(id,menu_handle)
return PLUGIN_HANDLED
}
public SelectRadio(id, menu, key)
{
if ( get_pcvar_num(custom_radio) == 0 )
{
return PLUGIN_HANDLED
}
if ( key == MENU_EXIT )
{
return PLUGIN_HANDLED ;
}
client_cmd(0,"spk %s",radio_files[key])
return PLUGIN_HANDLED ;
}
public C_RADIO1(id)
{
menu_display(id,menu_handle,1)
return PLUGIN_HANDLED
}
this is a fair bit simpler and should work fine ... want to try it out?
-Pixie
EDIT: Oh, and sorry to completely rip out your switch statements ... I just vastly prefer arrays to switches.
Switches are awesome when you need one, but if you could get away with an array, I prefer the array method.
Notice how much smaller my "build menu" and "press menu key" functions are :-P
(and precache, since it can use the same array as the menu select one )