Before my answer I just want to show people how a GOOD explanation looks like.
This code won't allow you to chose "nothing" as soon as you chose something. Is that something you need?
Code:
#include <amxmodx>
#define MENUITEM_DISABLED (1<<26)
enum enumSelections {
name[32],
cost
}
new const g_Selections[][enumSelections] = {
{ "First" , 100 },
{ "Second" , 300 },
{ "Third" , 50 },
{ "Fourth" , 500 }
};
new bool:g_Unlocked[33][sizeof g_Selections];
new g_Selected[33];
new g_Points[33];
public plugin_init() {
register_plugin("Dual Action Menu", "1.0", "[ --{-@ ]");
register_clcmd("menu", "cmd_menu");
register_clcmd("say /pts", "GivePts");
}
public client_connect(id) {
g_Points[id] = 0;
g_Selected[id] = -1;
}
public GivePts(id) {
g_Points[id] += 100;
}
public cmd_menu(id) {
new menu = menu_create("\rHello pirate!", "menu_handler")
for ( new i = 0; i < sizeof g_Selections ; i++ ) {
new menuitem[64], menuitem_disable = 0;
if ( g_Selected[id] == i ) {
formatex(menuitem, charsmax(menuitem), "\d%s [SELECTED]", g_Selections[i][name])
menuitem_disable = MENUITEM_DISABLED;
}
else if ( g_Unlocked[id][i] )
formatex(menuitem, charsmax(menuitem), "\y%s", g_Selections[i][name])
else if ( g_Points[id] < g_Selections[i][cost] ) {
formatex(menuitem, charsmax(menuitem), "\d%s \d[\r%d Pts\d]", g_Selections[i][name], g_Selections[i][cost])
menuitem_disable = MENUITEM_DISABLED;
}
else
formatex(menuitem, charsmax(menuitem), "\y%s \d[\w%d Pts\d]", g_Selections[i][name], g_Selections[i][cost])
menu_additem(menu, menuitem, "", menuitem_disable);
}
menu_display(id, menu, 0)
}
public menu_handler(id, menu, item)
{
if ( item == MENU_EXIT ) {
menu_destroy(menu)
return PLUGIN_HANDLED
}
if ( g_Unlocked[id][item] ) {
g_Selected[id] = item;
client_print(id, print_chat, "You have selected %s", g_Selections[item][name]);
return PLUGIN_CONTINUE
}
g_Points[id] -= g_Selections[item][cost];
g_Unlocked[id][item] = true;
client_print(id, print_chat, "You have unlocked %s", g_Selections[item][name]);
return PLUGIN_HANDLED
}