Raised This Month: $ Target: $400
 0% 

(help) What's wrong with my menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
keyblade
Member
Join Date: Nov 2010
Location: China
Old 11-27-2010 , 05:46   (help) What's wrong with my menu
Reply With Quote #1

This is my code:

Code:
 
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "weapons shop"
#define VERSION "1.0"
#define AUTHOR "Ice-Action |#KeyBlade"

public plugin_init()
{
      register_plugin(PLUGIN, VERSION, AUTHOR)
      new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
      register_menucmd(register_menuid("choose weapons"), keys, "giveWeapon")
      register_clcmd("say /bw", "showWeaponMenu")
}

public showWeaponMenu(id)
{
    new menu[192]
    new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
    format(menu, 191, "choose weapons^n^n1-AK47^n2-M4A1^n3-AWP^n^n^n^n^n^n^n^n0-Exit")
    show_menu(id, keys, menu)
    return PLUGIN_HANDLED
}

public giveWeapon(id, key)
{
    if (key == 0)
    {
         give_item(id, "weapon_ak47")
    } else if (key == 1) {
         give_item(id, "weapon_m4a1")
    } else if (key == 2) {
         give_item(id, "weapon_awp")
    }
}
I press 3 in the game but I can't get AWP.What's wrong?

I'm a script beginner.Sorry for my bad english.
keyblade is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-27-2010 , 05:59   Re: (help) What's wrong with my menu
Reply With Quote #2

you forgot MENU_KEY_3 on both keys list.
Also, you have to return PLUGIN_HANDLED in menu handler.

In menu handler, use a switch statement

Code:
switch( key )
{
    case 0:give_item(id, "weapon_ak47")
    case 1:give_item(id, "weapon_XXX")
    case 2:give_item(id, "weapon_XXX")
}

Also, i think you are a bit confused :

MENU_KEY_1 represent slot1

but in handler, key : 0 represent slot 1



MENU_KEY_0 represent slot 0 (exit)
key : 9 is slot 0 (exit)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
keyblade
Member
Join Date: Nov 2010
Location: China
Old 11-27-2010 , 06:50   Re: (help) What's wrong with my menu
Reply With Quote #3

Thank you very much!
keyblade is offline
Reply



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 11:17.


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