PDA

View Full Version : give weapon using menu


SaM.ThE.MaN
06-19-2010, 16:31
hi,
this used to work for me long time ago, its just a test plugin i used, it gives you a weapon through the menu when you type /menu in chat.
Now it doesnt give players anything.

#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init()
{
register_plugin("Beasts Cusom Menu", "0.1", "SaMThEMaN")
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
register_menucmd(register_menuid("Select a Weapon"), keys, "giveWeapon")
register_clcmd("say /menu", "showWeaponMenu")
}

public showWeaponMenu(id)
{
new menu[192]
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2

format(menu, 191, "Which Weapon?^n^n1. M4A1^n2. AK47^n3. MP5^n4. GoldenAK")
show_menu(id, keys, menu)
return PLUGIN_HANDLED
}

public giveWeapon(id, key)
{
switch(key)
{
case 0:
{
give_item(id, "weapon_m4a1")
}
case 1:
{
give_item(id, "weapon_ak47")
}
case 2:
{
give_item(id, "weapon_mp5navy")
}
case 3:
{
server_cmd("amx_goldenak #%d", get_user_userid(id))
}
}
}

fysiks
06-19-2010, 17:53
A very important thing that you need to learn it debugging. This will do two things, it will minimize the number of questions you post here and it will generally make things quicker. Why wait a few days to get it to work when you can debug it and most likely solve the problem is a few hours(±)?

ConnorMcLeod
06-19-2010, 18:13
Replace :

register_menucmd(register_menuid("Select a Weapon"), keys, "giveWeapon")

with

register_menucmd(register_menuid("Which Weapon"), keys, "giveWeapon")

fysiks
06-19-2010, 18:34
That register_menuid() always confused me. Apparently this way actually compares text to find out what function is supposed to be used with the menu. This is not explicitly stated in the Wiki unfortunately.

I would think it would make more sense to use a pointer to a registered menu and then reference it using the pointer in show_menu().

ConnorMcLeod
06-19-2010, 18:38
By using register_menuid("Team_Select", true) you can hook :

Team_Select
Team_Select_Spect
IG_Team_Select
IG_Team_Select_Spect
IG_VIP_Team_Select
IG_VIP_Team_Select_Spect

fysiks
06-19-2010, 18:42
By using register_menuid("Team_Select", true) you can hook :

Team_Select
Team_Select_Spect
IG_Team_Select
IG_Team_Select_Spect
IG_VIP_Team_Select
IG_VIP_Team_Select_Spect

It doesn't have to start at index 0? I wouldn't have guessed that the last 4 would work.

SaM.ThE.MaN
06-20-2010, 02:56
hmm... yeah ive seen it in my server console , bla bla has error debug not enabled ,
but i went to plugins.ini and under the plugin i wrote : Debug, went back to my server and it still said the same stuff

RedRobster
06-20-2010, 03:40
Write it next to the plugin.

sexy_weapon_menu.amxx debug

ConnorMcLeod
06-20-2010, 04:42
Also you only register keys 1 to 3 when you need the 4th one.

grimvh2
06-20-2010, 05:24
I hate this styles of menu, its annoying and ugly :p

ConnorMcLeod
06-20-2010, 06:11
No, new menus suck hard.

Arkshine
06-20-2010, 06:25
New menu is for simple and non-dynamic menu. ^^

abdul-rehman
06-20-2010, 08:28
New menu is for simple and non-dynamic menu. ^^
New menus are also dynamic

SaM.ThE.MaN
06-20-2010, 09:11
Replace :

Code:
register_menucmd(register_menuid("Select a Weapon"), keys, "giveWeapon")


with

Code:
register_menucmd(register_menuid("Which Weapon"), keys, "giveWeapon")



hmm 1 question , why do i have to call it Which Weapon?

Arkshine
06-20-2010, 10:15
New menus are also dynamic

You have a better flexibility with the old menus. The new menus is just a pain when you do a dynamic menu.

fysiks
06-20-2010, 13:17
hmm 1 question , why do i have to call it Which Weapon?

It needs to be the same as the first few words of your menu string. Why? Because that's how it works.

SaM.ThE.MaN
06-20-2010, 13:45
oh i c i c, thanx, i was thinking why has it to be like that and not something else xD

grimvh2
06-21-2010, 04:23
You have a better flexibility with the old menus. The new menus is just a pain when you do a dynamic menu.

I think its easy to use. The only thing you need todo is a format. Not so bad?

abdul-rehman
06-21-2010, 12:07
You have a better flexibility with the old menus. The new menus is just a pain when you do a dynamic menu.

Well...I hate old menus bcoz it is difficult to make them dynamic [for me atleast] as compared to new menus
I think its easy to use. The only thing you need todo is a format. Not so bad?
Youre right and its easy...:up: