AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   give weapon using menu (https://forums.alliedmods.net/showthread.php?t=130053)

SaM.ThE.MaN 06-19-2010 16:31

give weapon using menu
 
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.

PHP Code:

#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
(menu191"Which Weapon?^n^n1. M4A1^n2. AK47^n3. MP5^n4. GoldenAK")
    
show_menu(idkeysmenu)
    return 
PLUGIN_HANDLED
 
}

public 
giveWeapon(idkey)
{
    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

Re: give weapon using menu
 
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

Re: give weapon using menu
 
Replace :

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

with

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

fysiks 06-19-2010 18:34

Re: give weapon using menu
 
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

Re: give weapon using menu
 
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

Re: give weapon using menu
 
Quote:

Originally Posted by ConnorMcLeod (Post 1213792)
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

Re: give weapon using menu
 
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

Re: give weapon using menu
 
Write it next to the plugin.
Code:

    sexy_weapon_menu.amxx debug

ConnorMcLeod 06-20-2010 04:42

Re: give weapon using menu
 
Also you only register keys 1 to 3 when you need the 4th one.

grimvh2 06-20-2010 05:24

Re: give weapon using menu
 
I hate this styles of menu, its annoying and ugly :p


All times are GMT -4. The time now is 14:49.

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