Raised This Month: $ Target: $400
 0% 

give weapon using menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-19-2010 , 16:31   give weapon using menu
Reply With Quote #1

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))
        }
    }

__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2010 , 17:53   Re: give weapon using menu
Reply With Quote #2

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(±)?
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-19-2010 , 18:13   Re: give weapon using menu
Reply With Quote #3

Replace :

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

with

Code:
register_menucmd(register_menuid("Which Weapon"), keys, "giveWeapon")
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2010 , 18:34   Re: give weapon using menu
Reply With Quote #4

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().
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-19-2010 , 18:38   Re: give weapon using menu
Reply With Quote #5

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
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-19-2010 , 18:42   Re: give weapon using menu
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
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.
__________________
fysiks is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 09:11   Re: give weapon using menu
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
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?
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-20-2010 , 13:17   Re: give weapon using menu
Reply With Quote #8

Quote:
Originally Posted by SaM.ThE.MaN View Post
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.
__________________
fysiks is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 06-20-2010 , 02:56   Re: give weapon using menu
Reply With Quote #9

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
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 06-20-2010 , 03:40   Re: give weapon using menu
Reply With Quote #10

Write it next to the plugin.
Code:
    sexy_weapon_menu.amxx debug
RedRobster is offline
Reply


Thread Tools
Display Modes

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 14:49.


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