Raised This Month: $ Target: $400
 0% 

Menu Error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-01-2007 , 11:56   Re: Menu Error
Reply With Quote #4

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(PLUGINVERSIONAUTHOR)
    
    
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 
TOTAL_RADIOS++ )
    {
        
menu_additem(menu_handle,radio_names[i])
    }
    
menu_setprop(menu_handleMPROP_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(idprint_chat"This server is running Custom Radio Commands by X-Script!")
    
client_print(idprint_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 
TOTAL_RADIOS ++ )
        
precache_sound(sound)
    return 
PLUGIN_HANDLED
}

public 
C_RADIO(id)
{
    
menu_display(id,menu_handle)
    return 
PLUGIN_HANDLED
}

public 
SelectRadio(idmenukey)
{
    if ( 
get_pcvar_num(custom_radio) == )
    {
        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 )

Last edited by purple_pixie; 10-01-2007 at 12:00. Reason: changed hard-coded 15 to TOTAL_RADIOS
purple_pixie is offline
 



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 16:12.


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