Hi all , I'm totally a newbie about scripting...I've got a problem when creating Menus...Here's my incomplete script
PHP Code:
public plugin_init()
{
register_plugin("Menu Demo", "1.0", "BAILOPAN")
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9
register_menucmd(register_menuid("ShowHandGun"), keys, "ShowHandGun")
register_menucmd(register_menuid("Handguns"), keys, "GiveHandGun")
register_clcmd("giveme", "showWeaponMenu")
}
public showWeaponMenu(id)
{
new menu[192]
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9
format(menu, 191, "MainPage^n^n1. Handguns^n2. Shotguns^n3. Submachine guns^n4. Assault Rifles^n5. Snipers")
show_menu(id, keys, menu)
return PLUGIN_HANDLED
}
public ShowHandGun(id, key)
{
if (key == 0)
{
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9
new Hmenu[192]
format(Hmenu, 191, "Handguns^n^n1. Glock18 - $200^n2. Usp - $500^n3. p228 - $300^n4. Deagle - $900^n5. FiveSeven - $500^n6. Elite - $400")
show_menu(id,keys, Hmenu)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
//Our menu function will get the player id and the key they pressed
public GiveHandGun(id, key)
{
//key will start at zero
if (key == 0)
{
give_item(id, "weapon_glock18")
} else if (key == 1) {
give_item(id, "weapon_usp")
} else if (key == 2) {
give_item(id, "weapon_p228")
}
}
I want to create a menu that Let players chooses their guns...When I type "giveme" in console , "showWeaponMenu" comes out , but when I press "1" , it gives me a glock , instead of showing "ShowHandGun"...
can anyone tell me where's my problem? thx a lot
======================
O my god , how come I've forgotten "Switch" ... the problem's solved...